php - Enter variable into sql table Problems -



php - Enter variable into sql table Problems -

ok having problems insert variable sql table. heres code

if (isset ($_get['comment'])) $commententered = $_get['comment']; else $commententered = "refuse";

above variable seek pass database code below

$sql = "insert $db_table (comment) values('$commententered');"; $res = mysql_query($sql,$con) or die(mysql_error()); mysql_close($con); if ($res) { echo "success"; }else{ echo "faild"; }// end else

my problem is, when pass single word works, when text box comment received has spaces in it, not insert?

i.e - user enters hello - works

the user enters hello world - doesn't work

any help much appreciated!

try

$sql = "insert " . $table . " (comment) " . "values ('" . mysql_real_espace_string($commententered) . "')";

also, dump var $commententered before "$sql = ..." line see outputs screen.

var_dump($commententered);

and thing, seek switching request method post , grab info $_post.

php sql

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -