php mysql insert

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
birdie
Forum Newbie
Posts: 22
Joined: Thu Sep 15, 2005 4:37 pm

php mysql insert

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it's because you used == instead of =.
= is assignment
== is checking equality
=== is checking equality and type match
birdie
Forum Newbie
Posts: 22
Joined: Thu Sep 15, 2005 4:37 pm

Post by birdie »

wow youve made my day :D . thanks
Post Reply