'insert into' with vars

software development

#1

i have these lines:
$massage = $_GET[“massage”];
$nick = $_GET[“nick”];
$result=“INSERT INTO itest ( nick , massage ) VALUES ( ‘$nick’ , ‘$massage’ );”;
if (mysql_query($result)){
echo “success.”;
}

when i run it, it shows “success”,
but it does not insert (i checked the database from phpmyadmin)
what can i do ?


#2

is that all the code for your mysql connection and query?

blueorder


#3

Try removing the ; from the end of the SQL statement (not the terminating line semi-colon).


#4

You could also try changing the $result line to:

$result=“INSERT INTO itest (‘nick’,‘massage’) VALUES (’$nick’ , ‘$massage’ )”;

I haven’t had very good luck with the ` mark in MySQL on DH, even when it’s supposed to work perfectly; they’re not necessary, anyhow.

Edit: And you could change if(mysql_query($RESULT)) to if(mysql_QUERY($RESULT) != ‘’) – and there really ought to be a or die(mysql_error()); in there, which would probably let you know exactly what the problem was in the first place.