Forum Moderators: coopster
I am developing a signup system. The problem is that...
no new entry gets created in the table..
no error shown, and it shows 'Success' msg instead while nothing is stored in the table actually
Here is the code
if($password == $password2) {
$query1 = "SELECT * FROM login WHERE username = '$username'";
$result1 = mysqli_query($con,$query1);
if(mysqli_num_rows($result1) == 0) {
//the new username chosen is unique so proceed
$query2 = "INSERT INTO login (username,password,join_date,email,day,month,year,gender,location) VALUES" .
"(\"$username\" , SHA('$password'), NOW(), \"$email\", \"$day\", \"$month\", \"$year\", \"$gender\", \"$location\")";
$result2 = mysqli_query($con,$query2);
//Confirm success with the user
echo '<p> Welcome <span style="color:green; font-size:150%"> '. $username .'</span>, <br/> your new account has been succesfully created. You are now ready to <a href="login.php">log in</a> </p>';
---------------------------------------
so I put this code after $result2
if(!$result2) {
die ('error:' . mysqli_error());
}
it gives a warning this way..
Warning: mysqli_error() expects exactly 1 parameter, 0 given in D:\xampp\htdocs\project\signup.php on line 69
error:
-------------------
any problem with the code ? and what is the warning all about?
Thanks!
PS> in the table login,
username,password,,email,,gender,location are VARCHAR
join_date is DATE
day,month, year are INT
but just out of curiosity.. when I check for error with a statement like 'if($result)', what I could make out is that it checks if $result carries a value which is NULL if an error occurs thats why the warning 'mysqli_error() expects exactly 1 parameter, 0 given in..'
(is this so ?)
but when its if(!$result) {... and if something goes wrong then this should be true .. so why this error again?..
Pls correct me.. is my understanding correct?