Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

php and MySql problem with strings 1

Status
Not open for further replies.

mrmtek

Programmer
Oct 13, 2002
109
AU
I can save strings into the mysql database, however if I have a string with a space in it such as 'MARY HAD A LITTLE LAMB' when I call the string back up to display in a text box only MARY will display the rest of the string does not, yet it is in the database when I go into mysql and view the table. What have I done wrong ????
 
using the insert command via php -

insert into tablename (field name) values ????, works ok no errors at all perfect in all - values are stored correctly when I look in sql, but when out putting to html only the first word of a string is displayed -

display string as follows :

echo "<td align=center bgcolor=#E2D8BF><input type=text size=25 name=s3[] value=$ordername style=\"font-size: 1em\"></td>";

again only the first word of a string displayed???
 
Your produced code looks like this:
<td align=center bgcolor=#E2D8BF><input type=text size=25 name=s3[] value=MARY HAD A LITTLE LAMB style="font-size: 1em"></td>

HTML requires quotes around values that have spaces in them or it will simply use the first word and ignore the rest. XHTML however requires double quotes around all values, so I would say it is a good practice to start doing that. I would revise your echo statement to produce something like this:
Code:
echo '<td align="center" bgcolor="#E2D8BF"><input type="text" size="25" name="s3[]" value="' . $ordername . '" style="font-size: 1em;"></td>';
 
perfect - once again thank you, most helpful -
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top