fitchic77
09-13-2002, 01:24 AM
My address record being queried is '555 Disney Lane"
echo($address1) ;
===============
This display 555 Disney Lane
echo("<br><input name='address' value=" .$address1.">" ) ;
==========================================
This displays 555
Somehow the spaces in the record don't show up in an input field???
Any help would be greatly appreciated.
Thanks,
Andrea
Spookster
09-13-2002, 02:40 AM
Do you have that field set to datatype varchar? What length is the field? Have you verified through some other means that the entire address is actually stored in the table? Use phpMyAdmin if you have it to check the value.
Alex Vincent
09-13-2002, 02:42 AM
What language is this written in?
fitchic77
09-13-2002, 02:57 AM
was written in php.
Believe me...it is in the dbase and the length is 200 varchar. like I said it prints correctly outside on an input field.
This shows correctly 555 Disney Lane
echo($row[address]) ;
This cuts off the address to 555
echo("<br><input name='address' value=" .$row[address].">" ) ;
All the other fields are populating such as first name, last name. There are no spaces in them like the address field.
The spaces are somehow affecting the input field value. I think it has something to do with the array and how it is parsing. I think it is parsing each record looking for a space???
Hell. I don't know...I'm new at php...Cold fusion and ASP are so much easier...ARGGGG
Any response would be wonderful.
Thanks,
Andrea
fitchic77
09-13-2002, 02:58 AM
Here is the code..hope it shows up here..
$result = @mysql_query("Select * from customers where id=99999");
if (!$result) {
echo("<p>Error in query: " .mysql_error(). "</p>");
exit();
}
if ($row = mysql_fetch_array($result))
{
echo($row[address]) ;
echo("<br><input name='address' value=" .$row[address].">" ) ;
Spookster
09-13-2002, 03:10 AM
Ok out of curiosity try it like this:
<input name="address" value="<?php echo $row["address"]; ?>">
This is also a little quicker to render as the php engine doesn't have to print out the entire html string. When you have many of these it the time it takes to parse everything starts adding up. Typically it's best to only print exactly what you need to print hence the ability to jump in and out of php mode.
echo("<br><input name='address' value=" .$row[address].">" ) ;
let's have a think about what is echoed there
...value=555 Disney Lane
You see, because there are NO quotes around the html output of the value, the browser cannot understand anything beyond 555. The rest would still be echoed into the source code, it just wouldn't show.
I always tend to echo out strings encased in single quotes, so that double quotes are shown in the html
echo '<br><input name="address" value="'.$row["address"].'">';
would yield
...value="555 Disney Lane"
which html would accept. :)
I hope that explains it properly for you.
Spookster's version would also output quotes into the html and would also work
Spookster
09-13-2002, 01:12 PM
Good eye Okii. I didn't notice the missing quotes. :) Without the quotes the php engine is printing out integers as it should hence the 555. With quotes the engine prints out the string as it should hence the entire address.
fitchic77
09-13-2002, 01:56 PM
well guys it was late and plus I'm a newbie...so I'm sure this is the answer. I will test later on today and let ya know.
Thanks A MILLION !!!
:thumbsup:
We were all newbies once - one day you'll be the one to answer some other newbies question.
PS - kudos on the attractive model whose images adorn your signature link.
fitchic77
09-13-2002, 08:50 PM
Okii
Those photos are me...Andrea. My hubby is a photographer...so he took some photos of me and my sweety pie doggie. Isn't he so sweet!!
Thanks for the compliment though.
Cheers
Andrea