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!
I'm trying to create a script for registering new users on my sim site,
but everytime I try to test it out and add a new user to the database,
I get the error:
Error: Unknown column 'username' in 'field list'
I've been led to believe this part of my coding would be where the problem is coming from:
// Finally, create the record.
$newPlayer = @mysql_query("INSERT INTO players (`username`, `password`, `registered`)
VALUES ('$uname', '$pass', '$date')") or die("Error: ".mysql_error());
echo 'You have been registered! You may now <a href=index.php>Log in</a>.';
Mythical wrote:I'm trying to create a script for registering new users on my sim site,
but everytime I try to test it out and add a new user to the database,
I get the error:
Error: Unknown column 'username' in 'field list'
I've been led to believe this part of my coding would be where the problem is coming from:
// Finally, create the record.
$newPlayer = @mysql_query("INSERT INTO players (`username`, `password`, `registered`)
VALUES ('$uname', '$pass', '$date')") or die("Error: ".mysql_error());
echo 'You have been registered! You may now <a href=index.php>Log in</a>.';
Anyway to fix this?
Try to remove single quotes for the field names in the insert statement.Hope this helps!!
$newPlayer = @mysql_query("INSERT INTO players (username, password, registered)
VALUES ('$uname', '$pass', '$date')") or die("Error: ".mysql_error());
$query = " INSERT into BloomIndex (bloomindexID,startmonth,endmonth,bloomyear,departmentID,title,subtitle)
values(null,'$startmonth','$endmonth','$bloomyear','$departmentID','$title', '$subtitle')";
mysql_query($query);
// get the last auto incremented value
$bloomindexID = mysql_insert_id();