jamesxg1 Posted May 26, 2009 Share Posted May 26, 2009 <?php session_start(); include 'Utilitys/Connection.php'; include 'Utilitys/Functions.php'; RedLogin(); $role = "1"; $id = mt_rand(0, 9999999999); $time = date("F j, Y, g:i a"); $signup = date("F j, Y, g:i a"); $username = protect($_POST['username']); $password = protect($_POST['password']); $firstname = protect($_POST['FirstName']); $lastname = protect($_POST['LastName']); $email = protect(validateEmail($_POST['Email'])); $ip = $_SERVER['REMOTE_ADDR']; $gender = protect($_POST['gender']); $dobday = protect($_POST['dobday']); $dobmonth = protect($_POST['dobmonth']); $dobyear = protect($_POST['dobyear']); if (isset($_POST['submit'])) { if (isset($username) && isset($password) && isset($firstname) && isset($lastname) && isset($email) && isset($gender) && isset($dobday) && isset($dobmonth) && isset($dobyear)) { $flag = "INSERT INTO `users` (`id`, `username`, `password`, `firstname`, `lastname`, `email`, `role`, `time`, `signup`, `gender`, `ip`, `dobmonth`, `dobday`, `dobyear`) VALUES('$id', '$username', md5('$password'), '$firstname', '$lastname', '$email', '$role', '$time', '$signup', '$gender', '$ip', '$dobmonth', '$dobday', '$dobyear')" or die (mysql_error()); $run = mysql_query($flag); header('Location: Login.php?i=1'); } else { print "<p align='center'>Please Fill All Required Fields.</p>"; } } ?> the insert is not working is just doing the refferal, does anyone know why ?, Thanks. James. Quote Link to comment https://forums.phpfreaks.com/topic/159688-solved-mysql-insert-not-working/ Share on other sites More sharing options...
aashcool198 Posted May 26, 2009 Share Posted May 26, 2009 don't put single quote mark while writing table or column's name e.g. INSERT INTO users (id, username, password.....etc) Quote Link to comment https://forums.phpfreaks.com/topic/159688-solved-mysql-insert-not-working/#findComment-842205 Share on other sites More sharing options...
jamesxg1 Posted May 26, 2009 Author Share Posted May 26, 2009 didnt work Quote Link to comment https://forums.phpfreaks.com/topic/159688-solved-mysql-insert-not-working/#findComment-842209 Share on other sites More sharing options...
kickstart Posted May 26, 2009 Share Posted May 26, 2009 Hi I take it you mean the header('Location: Login.php?i=1'); doesn't work? Do you get an error? All the best Keith PS - why the random ID? Quote Link to comment https://forums.phpfreaks.com/topic/159688-solved-mysql-insert-not-working/#findComment-842212 Share on other sites More sharing options...
MiCR0 Posted May 26, 2009 Share Posted May 26, 2009 $flag = "INSERT INTO `users` (`id`, `username`, `password`, `firstname`, `lastname`, `email`, `role`, `time`, `signup`, `gender`, `ip`, `dobmonth`, `dobday`, `dobyear`) VALUES('$id', '$username', md5('$password'), '$firstname', '$lastname', '$email', '$role', '$time', '$signup', '$gender', '$ip', '$dobmonth', '$dobday', '$dobyear')" or die (mysql_error()); ??? your setting a string not querying yet Quote Link to comment https://forums.phpfreaks.com/topic/159688-solved-mysql-insert-not-working/#findComment-842213 Share on other sites More sharing options...
jamesxg1 Posted May 26, 2009 Author Share Posted May 26, 2009 Hi I take it you mean the header('Location: Login.php?i=1'); doesn't work? Do you get an error? All the best Keith PS - why the random ID? hiya, no it doesnt do the insert all it does is reffer me. James. Quote Link to comment https://forums.phpfreaks.com/topic/159688-solved-mysql-insert-not-working/#findComment-842215 Share on other sites More sharing options...
jamesxg1 Posted May 26, 2009 Author Share Posted May 26, 2009 $flag = "INSERT INTO `users` (`id`, `username`, `password`, `firstname`, `lastname`, `email`, `role`, `time`, `signup`, `gender`, `ip`, `dobmonth`, `dobday`, `dobyear`) VALUES('$id', '$username', md5('$password'), '$firstname', '$lastname', '$email', '$role', '$time', '$signup', '$gender', '$ip', '$dobmonth', '$dobday', '$dobyear')" or die (mysql_error()); ??? your setting a string not querying yet am i :S, it used to work and then i changed it a bit and it dont and thats just a error trigger its working on all of my other script perfectly dont understand why this isnt working :S Quote Link to comment https://forums.phpfreaks.com/topic/159688-solved-mysql-insert-not-working/#findComment-842217 Share on other sites More sharing options...
jamesxg1 Posted May 26, 2009 Author Share Posted May 26, 2009 @kickstart PS - why the random ID? i need it to be random long winded lol Quote Link to comment https://forums.phpfreaks.com/topic/159688-solved-mysql-insert-not-working/#findComment-842218 Share on other sites More sharing options...
kickstart Posted May 26, 2009 Share Posted May 26, 2009 am i :S, it used to work and then i changed it a bit and it dont and thats just a error trigger its working on all of my other script perfectly dont understand why this isnt working :S If there is an error in your SQL then that or die is not going to notice it. All the best Keith PS - Random ID will cause problems if Id is the primary key and by chance you land up with a duplicate. Might be a million to one chance, but million to one chances seem to occur 9 times out of 10. Quote Link to comment https://forums.phpfreaks.com/topic/159688-solved-mysql-insert-not-working/#findComment-842219 Share on other sites More sharing options...
jamesxg1 Posted May 26, 2009 Author Share Posted May 26, 2009 am i :S, it used to work and then i changed it a bit and it dont and thats just a error trigger its working on all of my other script perfectly dont understand why this isnt working :S If there is an error in your SQL then that or die is not going to notice it. All the best Keith PS - Random ID will cause problems if Id is the primary key and by chance you land up with a duplicate. Might be a million to one chance, but million to one chances seem to occur 9 times out of 10. oh :S what trigger can i use that will work ?, and agreed i will be making a ID checker soon where it will check if the random generated id exists already and if it does it will re-generate Quote Link to comment https://forums.phpfreaks.com/topic/159688-solved-mysql-insert-not-working/#findComment-842222 Share on other sites More sharing options...
kickstart Posted May 26, 2009 Share Posted May 26, 2009 Hi <?php session_start(); include 'Utilitys/Connection.php'; include 'Utilitys/Functions.php'; RedLogin(); $role = "1"; $id = mt_rand(0, 9999999999); $time = date("F j, Y, g:i a"); $signup = date("F j, Y, g:i a"); $username = protect($_POST['username']); $password = protect($_POST['password']); $firstname = protect($_POST['FirstName']); $lastname = protect($_POST['LastName']); $email = protect(validateEmail($_POST['Email'])); $ip = $_SERVER['REMOTE_ADDR']; $gender = protect($_POST['gender']); $dobday = protect($_POST['dobday']); $dobmonth = protect($_POST['dobmonth']); $dobyear = protect($_POST['dobyear']); if (isset($_POST['submit'])) { if (isset($username) && isset($password) && isset($firstname) && isset($lastname) && isset($email) && isset($gender) && isset($dobday) && isset($dobmonth) && isset($dobyear)) { $flag = "INSERT INTO `users` (`id`, `username`, `password`, `firstname`, `lastname`, `email`, `role`, `time`, `signup`, `gender`, `ip`, `dobmonth`, `dobday`, `dobyear`) VALUES('$id', '$username', md5('$password'), '$firstname', '$lastname', '$email', '$role', '$time', '$signup', '$gender', '$ip', '$dobmonth', '$dobday', '$dobyear')"; $run = mysql_query($flag) or die(mysql_error()); header('Location: Login.php?i=1'); } else { print "<p align='center'>Please Fill All Required Fields.</p>"; } } ?> Strictly speaking if you want to check the ID then you should do it locking the table, or just catch a duplicate key error and retry. All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/159688-solved-mysql-insert-not-working/#findComment-842229 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.