I am making a msg board with PHP + MySql, and when a person posts a comment, I want to take their $HTTP_HOST address and check if it is in the database. If it IS in, then I just want to use it, but if it isint, then I want to add it.
I am having trouble making mysql see that users are not in the DB, and it should add them.
Here is my code:
// Check if user does not exist
$pulluserid = mysql_query("SELECT ID FROM Users WHERE Name = '$commentname' ;");
if (!$pulluserid) {
echo("pulleserid = false");
$insertnewuser = mysql_query("INSERT INTO Users SET " .
"Name='$commentname' ;");
if (!$insertnewuser) {
echo("<p>Error adding new user: " . mysql_error() . "</p>");
exit();
}
}
I am having trouble making mysql see that users are not in the DB, and it should add them.
Here is my code:
// Check if user does not exist
$pulluserid = mysql_query("SELECT ID FROM Users WHERE Name = '$commentname' ;");
if (!$pulluserid) {
echo("pulleserid = false");
$insertnewuser = mysql_query("INSERT INTO Users SET " .
"Name='$commentname' ;");
if (!$insertnewuser) {
echo("<p>Error adding new user: " . mysql_error() . "</p>");
exit();
}
}