Forum Moderators: coopster
function add_user($username, $cryptedpass, $type, $firstname, $surname, $gender, $email)
{
// see if there is already a user with the username of '$username'
$query = "SELECT 1 FROM `users` WHERE `username`='$username'";
$query = @query($query) or die("Error checking the database.");
if(num_rows($query) > 0){ cust_die("The requested username is already in the database. Please select another one."); }
$add_query = "INSERT INTO `users` (`username`, `password`, `type`, `firstname`, `surname`, `gender`, `email`) VALUES ('$username', '$cryptedpass', '$type', '$firstname', '$surname', '$gender', '$email')";
query($add_query) or die("Error adding the user's information into the database.");
}
cause everytime i press register it always says "Error adding the user's information into the database" is there anything wrong with my query?
query($add_query) or die("Error adding the user's information into the database.");
to
query($add_query) or die("Error adding the user's information into the database: " . mysql_error());
that will give you the error, if there was one, from mysql
the other thing would be to echo your query as well to see if it looks correct
look at ALTER TABLE [dev.mysql.com]
CREATE TABLE `users` (`ID` int(11) NOT NULL, `username` text NOT NULL, `password` varchar(32) NOT NULL default '', `type` int(11) NOT NULL default '0', `firstname` text NOT NULL, `surname` text NOT NULL, `gender` char(1) NOT NULL default '', `email` text NOT NULL, PRIMARY KEY (`ID`));
how can i alter this one?