php - How Insert two table -
i write code this:
$password = md5($password); mysql_query("insert `users` (username,password,email,pnum,hintque,hintans) values('$username','$password','$email','$cnum','$hintque','$hintans')"); mysql_query("insert `personal` (userid,fname,lname,address,dob,country,state,city,poscode) values(last_insert_id(),'$fname','$lname','$address','$dob','$country','$state','$city'.'$zip')"); header("location: ../register.php?feedback=registration complete. may login");
but first sql success insert data. second 1 fail. want both query triggered on same time.
the second query fails because have syntax error (see last value, .
should ,
):
mysql_query("insert `personal` (userid,fname,lname,address,dob,country,state,city,poscode) values(last_insert_id(),'$fname','$lname','$address','$dob','$country','$state','$city','$zip')");
also, please avoid using mysql_*
. family of functions deprecated, , should using more up-to-date such mysqli or pdo.
Comments
Post a Comment