Page 1 of 1

php mysql insert

Posted: Sun Oct 09, 2005 4:58 pm
by birdie
ive made this script and it just dont know why it doesnt work.. it should.

Code: Select all

<?
$commenttextposter == "test";
$commenttext == "test script 23";
mysql_connect("localhost","root","password");
mysql_select_db("dave");
mysql_query("INSERT INTO comments (commenttextposter, commenttext) VALUES ('$commenttextposter', '$commenttext')");
mysql_close();
echo "Comment added";
?>


any ideas at all? thanks

ps. it might be because $commenttext has spaces in it

Posted: Sun Oct 09, 2005 5:08 pm
by feyd
it's because you used == instead of =.
= is assignment
== is checking equality
=== is checking equality and type match

Posted: Sun Oct 09, 2005 5:12 pm
by birdie
wow youve made my day :D . thanks