Re: A problem in mysql_fetch_array

From: Date: Tue, 09 Jul 2002 08:38:17 +0000
Subject: Re: A problem in mysql_fetch_array
Groups: php.general 
Request: Send a blank email to php-general+get-106308@lists.php.net to get a copy of this message
>I have insert some text with space to mysql DB with varchar() > >When I use mysql_fetch_array function to retrieve the data from DB . I >found only the first session text can be shown . It means if any space >there . It will split like session by session. for example. my DB have a >text "Hello World" , It can retrieve only "HELLO" by using mysql_fetch_array >. Wild Guess: Somewhere, you have something like this: echo "<INPUT TYPE=HIDDEN NAME=hello VALUE=$hello>"; (Where $hello is your variable with "Hello World" in it.) This turns into this in the HTML <INPUT TYPE=HIDDEN NAME=hello VALUE=Hello World> Which, in HTML terms, means that "World" is part of the *TAG*, not the data -- It's an attribute, because there is a space and no quotes around your data. You need to convince the HTML to look like this: <INPUT TYPE=HIDDEN NAME=hello VALUE="Hello World"> so the PHP should be: echo "<INPUT TYPE=HIDDEN NAME=hello VALUE=\"$hello\">"; And, just in case $hello might some day contain < or > or " or & or anything else that has special meaning in HTML, it should *really* be this: echo "<INPUT TYPE=HIDDEN NAME=hello VALUE=\"", htmlentities($hello), "\">"; http://php.net/htmlentities -- Like Music? http://l-i-e.com/artists.htm

« previous php.general (#106308) next »