Forum Moderators: coopster

Message Too Old, No Replies

How do I display an entire string from MYSQL using PHP

         

col the beginner

1:06 pm on Oct 7, 2004 (gmt 0)

10+ Year Member



I am stuck...I have a form that allows a user to update their contact information in a mysql database.
Some of the mysql records are strings with spaces, eg Address: 15 Some St..

When I display the record on the form I get 15, everything after the space is not displayed.

the HTML code for the form is:

<td width="31%"><input name="Address" type="text" size="40" value=<?php echo $record['ResAddress'];?>></td>

This has come from a mysql query which works fine. I just can't echo the entire string.
Any help would be greatly appreciated.

Timotheos

3:16 pm on Oct 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi col the beginner and welcome to WebmasterWorld!

You need quotes around your value.

<td width="31%"><input name="Address" type="text" size="40" value="<?php echo $record['ResAddress'];?>"></td>

mincklerstraat

3:35 pm on Oct 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



for this kind of thing it often helps to view source. In firefox, right click, 'View page source'. Another one I use lots every day is 'View selection source' - ff and moz the only browsers I know that have got this one.

col the beginner

7:46 pm on Oct 7, 2004 (gmt 0)

10+ Year Member



Thanks Timotheos..I have tried the quotes as suggested, and still only get values up till the first space. Will look at the links you sent..

tomda

8:08 pm on Oct 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Strange, are you sure they are only letters, numbers and space?

As said above, check the data in Mysql and check the value in html format (view source).

jatar_k

8:27 pm on Oct 7, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



well you could do a couple of things

I would look at the data in mysql and see if it really is a space and see if all the data exists there.

I would then look at the array $record and see what you see there, in the source as well as in the browser, using something like this

echo '<pre>';
print_r($record);
echo '</pre>';

see if all that gives you any clues as to what is actually happening.

yowza

8:28 pm on Oct 7, 2004 (gmt 0)

10+ Year Member



Could the problem be with data insertion?

Is the column set to varchar or another type that accepts numbers and letters?

Just a thought...

col the beginner

1:09 pm on Oct 9, 2004 (gmt 0)

10+ Year Member



Timotheos...thanks again for the advice, not sure if it was due to long hours in front of the monitor, and not in bed...but came back to the problem, viewed html source, and inserted " " around the value field, and have solved problem. As a 3rd year software eng student, I am learning all the time..thanks again to all who offered assistance.

Timotheos

3:14 pm on Oct 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Oh thank goodness! I was really scratching my head after you said that wasn't it.