Page 1 of 1
Issue adding stuff into a database
Posted: Thu Feb 24, 2005 7:17 pm
by Terencentanio
Yo.
I have a form with some text boxes. If people put more than one thing in it, seperated by spaces or other symbols, when it's added to the database or displayed on a page, it enters newlines.
Anyone know how I can stop this?
MT,
me
Posted: Thu Feb 24, 2005 7:22 pm
by feyd
care to show us how your text boxes are set up?
Posted: Thu Feb 24, 2005 7:28 pm
by Terencentanio
Code: Select all
<tr>
<td valign="top"><font face="arial" size="1" color="000000"><B>Support:</B></td>
<td valign="top"><input type="text" name="support" maxlength="50" value="PHP, Perl"></td>
</tr>
That was taken from the table where they are. This is one of the ones which adds newlines.
Posted: Thu Feb 24, 2005 7:54 pm
by feyd
got a live example of this problem, because I don't see how unless you are replacing the symbols/spaces with carriage returns..
Posted: Thu Feb 24, 2005 9:13 pm
by Terencentanio
Hmm. The memberlist at root32.com is a "live example" ..
Posted: Thu Feb 24, 2005 9:17 pm
by feyd
got one that's public?
Posted: Thu Feb 24, 2005 9:18 pm
by Terencentanio
That one is -
http://root32.com/users/profile.php should be viewable by anyone. Look at #33
Posted: Thu Feb 24, 2005 9:22 pm
by Burrito
try outputting your sql to see what it looks like...
Posted: Thu Feb 24, 2005 9:22 pm
by feyd
I'm not seeing anything out of the ordinary...
Posted: Thu Feb 24, 2005 9:29 pm
by Terencentanio
User #33's name is on 3 lines... it should be on 1.
Posted: Thu Feb 24, 2005 9:30 pm
by Burrito
got sql?
Posted: Thu Feb 24, 2005 9:41 pm
by Terencentanio
SQL? How do you mean?
Posted: Thu Feb 24, 2005 9:42 pm
by feyd
...not on my browser..
Posted: Thu Feb 24, 2005 9:44 pm
by Burrito
$sql = "insert into mytable (field1, field2) values ('".$_POST['field1']."','".$_POST['field2']."');
echo $sql;
mysql_query($sql)
or die(mysql_error());
sry for no code tags...but I wanted to emphasize the echo with bold

Posted: Thu Feb 24, 2005 10:03 pm
by smpdawg
In the HTML that you generate you have the cell width set to 10. That's 10 pixels - how would you expect it to render properly? It's going to word wrap at the first whitespace that it encounters which is why you see multiple lines but those of us that use FireFox see it the way you intended.
Change each ocurrence of 10 to something more reasonable and you should be OK.
Code: Select all
<TR>
<TD width=10 bgColor=#ffffff><FONT face=verdana color=#000000
size=2>42 </FONT></TD>
<TD width=10 bgColor=#ffffff><FONT face=verdana size=2><A
href="http://root32.com/users/profile.php?u=42">eclipse</A>
</FONT></TD></TR>