Issue adding stuff into a database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Terencentanio
Forum Commoner
Posts: 27
Joined: Mon Dec 06, 2004 10:32 am
Location: England

Issue adding stuff into a database

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

care to show us how your text boxes are set up?
Terencentanio
Forum Commoner
Posts: 27
Joined: Mon Dec 06, 2004 10:32 am
Location: England

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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..
Terencentanio
Forum Commoner
Posts: 27
Joined: Mon Dec 06, 2004 10:32 am
Location: England

Post by Terencentanio »

Hmm. The memberlist at root32.com is a "live example" ..
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

got one that's public?
Terencentanio
Forum Commoner
Posts: 27
Joined: Mon Dec 06, 2004 10:32 am
Location: England

Post by Terencentanio »

That one is - http://root32.com/users/profile.php should be viewable by anyone. Look at #33
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

try outputting your sql to see what it looks like...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I'm not seeing anything out of the ordinary...
Terencentanio
Forum Commoner
Posts: 27
Joined: Mon Dec 06, 2004 10:32 am
Location: England

Post by Terencentanio »

User #33's name is on 3 lines... it should be on 1.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

got sql?
Terencentanio
Forum Commoner
Posts: 27
Joined: Mon Dec 06, 2004 10:32 am
Location: England

Post by Terencentanio »

SQL? How do you mean?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

...not on my browser..
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post 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 :P
User avatar
smpdawg
Forum Contributor
Posts: 292
Joined: Thu Jan 27, 2005 3:10 pm
Location: Houston, TX
Contact:

Post 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. :D

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>
Post Reply