Re: [PHP-DB] retaining and displaying line returns in a text field
The function you need is called nl2br: http://us2.php.net/nl2br -Jordan On Jan 6, 2006, at 5:34 AM, swoll2 wrote: Good morning - I'm trying to get a text field with line returns in it to be stored, retrieved, and displayed the way it gets entered. Specifically, my users use a form field (html textarea) to enter some remarksas they enter their remarks, they can hit Enter to insert a hard return, which is reflected in the textarea on their screen. Example entry: this is line1. this is line2. this is line3. Those remarks get uploaded into a mysql db, into a field defined as a text field named rmks. If I use PhpMyAdmin to browse the table, it shows the entry with the lines separated, but there are no /n's or other control characters visible. Later, the field is retrieved from the db using a php script and assigned to a variable $rmkswhen I echo $rmks, it displays on a single line without the line returns, like this: this is line1.this is line2.this is line3. I have tried to work with addslashes and stripslashes, but neither has worked. I think I'm just missing something basic Appreciate any help or points to previous discussions..thanks...Steve -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] var_dump and sizeof database entry?
whoa, that was EXACTLY what I needed. Thanks!! Jordan On Jan 5, 2006, at 6:14 PM, Bastien Koert wrote: select *, (length(image_fiedl)/1024) as Kb from table [where clause] to get the size Bastien -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] var_dump and sizeof database entry?
Hello, This is stumping me something awful. I have searched the archive of this mailing list and google and the php and mysql websites with everything i can think of. I have a simple mysql table with some basic columns and a blob column that holds an image file. What I need to get is the size of this image file for use with an rss feed (the enclosure "length" parameter). In the simplest case, I thought I would just read the entire blob into a variable, and then I would be able to get the size of this variable. However, php does not seem to have a function to do this. Inexplicably, the "var_dump" command will actually dump the information I want, but it is very memory inefficient, because I get something like: ["preview"]=> string(17888) "ENTIRE CONTENTS OF BLOB HERE" where all I really want is the 17888 value (for a 17.5 KB file). What I was wondering is if there is a simple way to get this information from mysql directly without having to 1) select the blob column and 2) do a var_dump with output buffering and parsing for the parenthetical file size, which seems very inefficient to me. any insight is greatly appreciated. Jordan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Getting Started..
Man, he was just asking a simple question, no need to criticize every little aspect of etiquette. Please allow me to be a hypocrite and critique your criticism: 1) If his question gets buried in Yui's thread, no big deal, no one will answer and he will ask it again in a few days. If someone does answer, no second email needed. No harm, no foul. 2) No, the confidentiality notice is not *necessary* according to a strict definition. However, many people that work in the 'real world' actually have *no* control over this as it is automagically added to the end of every email leaving their email servers, **regardless** of user-settings. This is server-side code, not client-side. No harm, no foul. And yes, as you can probably tell by now, I don't have a problem with top posting either. I apologize if I have offended someone. Nevertheless, no need to point me to the Usenet diatribes... you won't sway me. Jordan On Sep 19, 2005, at 7:26 PM, Miles Thompson wrote: People don't like top posting, but I'm doing it for a reason. See what's at the end 1. Clint - Don't hijack threads. Some people use threaded mail clients, and your "getting started" will end up under Yui's thread. 2. Is it *necessary* to have a confidentiality notice that's just about equal in bulk to your message? If it's part of a canned sig, why not create a little simple one for this list. On to your question. Since you don't have all the code posted here, I suspect something is going on earlier in the file. Maybe you have an opening PHP tag, and a line without a semi-colon to terminate it. Why not try again, with just a single line file: Once that works, then expand it. Regards - Miles Thompson -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Question on CURDATE()
Micah, Oh, my bad. I was trying to remember how I did something like this before, stringing together a lot of "WHERE"s. You're right, though, it wasn't "WHERE", it was "OR". Rich, I think you need "OR" instead of "AND", OR else I'm just totally out to lunch tonight: SELECT * FROM WEEKS WHERE BEGIN >= CURDATE() OR END <= CURDATE(); The syntax error is that something cannot be >= AND <= the same thing at the same time! I have had this problem before in the past. You say to yourself, well, I need all of the records, so that intuitively makes you choose "AND" when in SQL it should technically be "OR" (you want the records that are true for each of these operators separately, NOT at the same time, which for most records is impossible). Also, you may want to take away one of the "=" signs, or you may get something "=" to CURDATE() twice (not sure how SQL handles this). Maybe try (taking out one of the "="): SELECT * FROM WEEKS WHERE BEGIN >= CURDATE() OR END < CURDATE(); Maybe it's just late over here. Has anyone else run into this same thing? Jordan On Sep 13, 2005, at 10:36 PM, Micah Stevens wrote: You can't do that in SQL, that would give you a big fat syntax error. On Tuesday 13 September 2005 7:45 pm, Jordan Miller wrote: Rich, Did you try putting "WHERE" twice? try: SELECT * FROM WEEKS WHERE BEGIN >= CURDATE() and WHERE END <= CURDATE; Jordan On Sep 13, 2005, at 9:08 PM, reclmaples wrote: I am trying to write a statement that will basically do this: SELECT * FROM WEEKS WHERE BEGIN >= CURDATE() and END <= CURDATE; But for some reason I can only use one CURDATE() reference in my sql statement, does anyone know why? Is there a way I can get around this? Any help would be greatly appreciated. Thanks -Rich -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Question on CURDATE()
Rich, Did you try putting "WHERE" twice? try: SELECT * FROM WEEKS WHERE BEGIN >= CURDATE() and WHERE END <= CURDATE; Jordan On Sep 13, 2005, at 9:08 PM, reclmaples wrote: I am trying to write a statement that will basically do this: SELECT * FROM WEEKS WHERE BEGIN >= CURDATE() and END <= CURDATE; But for some reason I can only use one CURDATE() reference in my sql statement, does anyone know why? Is there a way I can get around this? Any help would be greatly appreciated. Thanks -Rich -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] DATE(r)
You need to use: date('Y-m-d H:i:s'); It's in the comments at: http://www.php.net/date Jordan On Sep 9, 2005, at 12:52 PM, Ron Piggott wrote: Question: I am trying to for the first time create a table with a column that is defined as datetime I wanted to populate that column with the date(r) command. date(r) on my web site gives this response: Fri, 9 Sep 2005 13:32:19 -0400 How may I manipulate date(r) to give a format which is compatable to the column type -00-00 00:00:00 -MM-DD 24:59:59 Ron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: [PHP] Help: Get the value of pi up to 200+ digits?
strange, with your code, mine cuts out at 49 significant digits: 3.141592653589793115997963468544185161590576171875 it must be a system-specific limitation. we need more information on what you are trying to do, *exactly*. be as detailed and specific as possible. On Sep 1, 2005, at 10:57 AM, Wong HoWang wrote: Dear Jordan, I know what you mean. But you may try this one and you will know: the result is the same as 16!!! So that's why I ask this question! I am not stupid like that! Please help, thx! "Jordan Miller" <[EMAIL PROTECTED]> wrote:[EMAIL PROTECTED] http://us3.php.net/manual/en/ini.core.php#ini.precision precision sets the number of significant digits, *NOT* the number of digits displayed after the decimal point. If you want to get pi out to 16 decimal places you need a precision of *17* because the beginning 3 is a significant digit. Your code does exactly this, displaying pi with 15 decimal places. Jordan On Sep 1, 2005, at 8:06 AM, Wong HoWang wrote: Dear all, I'm trying to do like this but failed: How can I get more digits after . ? Can anyone help? Thx! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Storing an array on a table?
Yes, this has been mentioned in this thread. But with serialize/ unserialize, you can run into other problems that may be more confusing/difficult to troubleshoot. e.g.: http://www.php.net/serialize >As you can see, the original array : >$arr["20041001103319"] = "test" > >after serialize/unserialize is: >$arr[683700183] = "test" yepp, and i can explain it. the internal compiler of php does not hit anys rule wich foces him to make that number a string during serialisation. since it becomes an integer and php supports 32bit interger not arbitary bitwidth this is what happens: "20041001103319" equals hexadecimal: 0x123A28C06FD7h if you cut away the frontpart cutting down to 32bis, you get: 0x28C06FD7h wich equals 683700183. For simple arrays, I prefer storing everything as a simple imploded string. YMMV. Jordan On Sep 1, 2005, at 10:18 AM, <[EMAIL PROTECTED]> [EMAIL PROTECTED]> wrote: Sorry, didn't catch this thread from the beginning, but did anyone recommend trying the serialize() and unserialize() commands? They'll convert the array to a block of text that can be stored, retrieved and unserialized. My gut instinct is that if you're trying to store any array in a database, you may not have thought through your design very well. BUT.. I also know that there are cases where you might want to (I've actually done it before... being lazy in that case..hah) so dont take that as criticism, just wondering if there's a "more right" way to do it. If that's what you need to do though, definitely check out serialize (unless someone knows something I don't). Serialize() should do essentially what's being proposed below, just without having to figure out what string may not be in your array. good luck! -TG = = = Original message = = = if you just have a simple array with automatic numeric keys and text you could just implode the data to a string with a separator not found in your data: $dataArray = array("hello", "goodbye", "etc."); $storable = implode("", $dataArray); // $storable becomes "hellogoodbyeetc." //then, use explode to get the original array back again $dataArray = explode("", $storable); you could use a similar technique if you want to put the keys in as well, albeit slightly more complicated (e.g. use "" to separate each element in the array and "||" to separate each key from its value). Just find a divider you know your data will not contain, such as a pipe: "|". This has worked well for me. Jordan On Sep 1, 2005, at 8:55 AM, Miguel Guirao wrote: I want to store an array into a field on a MySQL table, Is it posible to save it? Maybe into a string field? ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Storing an array on a table?
if you just have a simple array with automatic numeric keys and text you could just implode the data to a string with a separator not found in your data: $dataArray = array("hello", "goodbye", "etc."); $storable = implode("", $dataArray); // $storable becomes "hellogoodbyeetc." //then, use explode to get the original array back again $dataArray = explode("", $storable); you could use a similar technique if you want to put the keys in as well, albeit slightly more complicated (e.g. use "" to separate each element in the array and "||" to separate each key from its value). Just find a divider you know your data will not contain, such as a pipe: "|". This has worked well for me. Jordan On Sep 1, 2005, at 8:55 AM, Miguel Guirao wrote: I want to store an array into a field on a MySQL table, Is it posible to save it? Maybe into a string field? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Brain not working, help needed :-)
you can also do this to save room without having to create $varname: ${"id".$num} = "some text"; Jordan On Aug 29, 2005, at 12:10 AM, Micah Stevens wrote: Hi Chris, You can use variable variables.. like this: $num = 2 $varname = "id".$num; $$varname = "id2 is stored here!"; It's in the docs in the variables section.. HTH, -Micah On Sunday 28 August 2005 11:45 pm, Chris Payne wrote: Hi there everyone, I have the following code: while ($row = mysql_fetch_array($sql_result)) { $id = $row["id"]; $video_link = $row["video_link"]; $video_thumbnail = $row["video_thumbname"]; $video_title = $row["video_title"]; $video_description = $row["video_description"]; }; Now I’ll be shifting through my MySQL array 6 items at a time, what I’d LIKE to be able to do is store each item in a number string on each pass. In other words, the first loop would see $id being called something like $id1, the second pass in the loop it would be $id2 and so on. I THOUGHT I could do this by putting a $count ++ in the loop and then doing something like $id$count or something like $id.$count but neither worked, this may sound odd but I REALLY need to be able to do this so how can I name a string that has to contain the data from a row successively higher on each loop so that it doesn’t overwrite the data on the previous loop? I have 6 items on the page so I can hardcode for item 1 and for item 2 etc …. But with the layout of the page being able to do it THIS way would be MUCH better than having to set the table itself up to handle it. Any help on this (Probably very easy) but annoying problem would be REALLY appreciated ;-) Chris -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: maximum number of records in a db?
Dan, Wow, thank you very much for an actual answer. It is much appreciated. I am sorry that people like to ridicule noobs on this list. It was a simple question with a simple answer. Thank you!! Jordan On Aug 26, 2005, at 10:45 AM, Dan Baker wrote: "Jordan Miller" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] I was just wondering what is the maximum number of records that can be successfully handled with a db. any db will do. it doesn't have to be the fastest or best, just one that can hold the maximum number of records and still be able to interact well with php. any ideas? Using MySQL with PHP: I believe that a MyISAM table has a maximum row count of 2^32 (4,294,967,296) rows. I believe that an InnoDB table *may* not have this limit. PostgreSQL: There is no limit on the # of rows in a table, see: http://www.postgresql.org/docs/faqs.FAQ.html#4.4 Remember that there are other limits (like diskspace, and the time it takes to perform a query on the data, indexing the data ...) If you are concerning about the row limit, you may need to re-think the problem. DanB -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] maximum number of records in a db?
i am talking about individual records, not putting all records into a very long string, if that's what you are saying. i know people routinely use millions of records... but how about billions or more? Jordan On Aug 26, 2005, at 10:29 AM, Miles Thompson wrote: At 12:11 PM 8/26/2005, Jordan Miller wrote: I was just wondering what is the maximum number of records that can be successfully handled with a db. any db will do. it doesn't have to be the fastest or best, just one that can hold the maximum number of records and still be able to interact well with php. any ideas? thanks, Jordan This is a useless question. Here's the matching answer: The number of records any database can hold matches the length of a piece of string. Seriously - do some homework, visit the host sites and read the specs. A lot depends on what you intend to store. As for "interacting well" - push the string. MT -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] maximum number of records in a db?
I was just wondering what is the maximum number of records that can be successfully handled with a db. any db will do. it doesn't have to be the fastest or best, just one that can hold the maximum number of records and still be able to interact well with php. any ideas? thanks, Jordan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] SQL Injection attack
NOTE: http://www.php.net/mysql_escape_string "Version: 4.3.0 Description: This function became deprecated, do not use this function. Instead, use mysql_real_escape_string()." Jordan On Aug 25, 2005, at 2:15 PM, <[EMAIL PROTECTED]> [EMAIL PROTECTED]> wrote: Using mysql_escape_string should be good enough by itself. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php