PHP trimming string upon POST?

  • Thread starter Thread starter Jeremy G
  • Start date Start date
J

Jeremy G

Guest
When submitting a form, PHP trims the input of a textbox to the first word before a space.

Ex:
I type in: "The Mummy Returns"
And upon submitting the form, PHP reads the variable as "The"

Code is as below:

if($id && $title) {
mysql_query("delete from story where id=$id");
mysql_query("insert into story values($id, '$title')");
}

echo("
<form method=post action=setup.php>
ID: <input type=text name=id size=10 value=$id>
Title: <input type=text name=\"title\" size=25 value=$story[title]>
<input type=submit name=task value=Save>
<input type=submit name=task value=Delete>
</form>
");
That didn't work either.

NVM, I found the problem though.

Title: <input type=text name=\"title\" size=25 value=\"$story[title]\">

I needed to add \" around $story[title]

Thanks for your help though!
 
mysql_query("delete from story where id=$id");
mysql_query("insert into story values($id, '$title')");

these two are wrong

mysql_query("DELETE FROM story where id='$id'");
mysql_query("INSERT INTO story (id,title) VALUES('$id', '$title')");

and i would addslashes() like

mysql_query("INSERT INTO story (id,title) VALUES('$id', '" . addslashes($title) . "')");
 
Back
Top