LiamProductions Posted August 15, 2007 Share Posted August 15, 2007 Hey... Im getting a error on my script code: <?php if(!isset($_POST['submitReg'])) { if(!isset($_POST['username'])) { echo "Please enter a username"; } else { if(!isset($_POST['pass'])) { echo "Please enter a password"; } else { if(!isset($_POST['passConf'])) { echo "Please enter a confirm password"; } else { if(!isset($_POST['email'])) { echo "Please enter a email address"; } else { $user = $_POST['username']; $user = strip_tags($user); $pass = $_POST['pass']; $passConf = $_POST['passConf']; $email = $_POST['email']; $email = strip_tags($email); if(strlen($user) < 4 || strlen($user) > 15) { echo "You entered a too long or short username"; } elseif(strlen($pass) < 6 || strlen($pass) > 50) { echo "You entered a too long or short username"; } elseif(strlen($email) < 5 || strlen($pass) > 60) { echo "You entered a too long or short username"; } else { if(!isset($_POST['sport'])) { echo "Please enter a favourite sport"; } elseif ($pass != $passConf) { echo "Password did not match"; } else { $sport = $_POST['sport']; if($sport != 'Football' && $sport != 'Basketball' && $sport != 'Tennis' && $sport != 'Hockey' && $sport != 'Rugby' && $sport != 'Bike Riding' && $sport != 'Swimming') { echo "Please pick a favourite sport"; } else { $IP = $_SERVER['REMOTE_ADDR']; $date = date('d/m/y'); $connection = mysql_connect('localhost', 'liam_liam', 'code090'); $storedata = mysql_query('INSERT INTO liam_database(Username, Password, Email,Favourite Sport,IP,date); VALUES ( "'.addslashes($user).'" "'.md5($pass).'" "'.addslashes($email).'" "'.addslashes($sport).'" "'.addslashes($IP).'" "'.addslashes($date).'" ') or die(mysql_error()); echo "Successfully Registered!"; mysql_close($connection); } } } } } } } } else { echo "Please enter the fields!"; } ?> The error is: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Sport, IP, date); VALUES ( "liam" ' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/65018-error/ Share on other sites More sharing options...
AndyB Posted August 15, 2007 Share Posted August 15, 2007 Field names cannot have spaces. Try using an underscore ... favourite_sport Quote Link to comment https://forums.phpfreaks.com/topic/65018-error/#findComment-324474 Share on other sites More sharing options...
LiamProductions Posted August 15, 2007 Author Share Posted August 15, 2007 I just tried what you say and now i'm getting this error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '; VALUES ( "liam" ' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/65018-error/#findComment-324476 Share on other sites More sharing options...
gurroa Posted August 15, 2007 Share Posted August 15, 2007 Try your sql command without ; sign. See http://dev.mysql.com/doc/. INSERT INTO liam_database(Username, Password, Email, Favourite_Sport, IP, date) VALUES (....) Quote Link to comment https://forums.phpfreaks.com/topic/65018-error/#findComment-324477 Share on other sites More sharing options...
LiamProductions Posted August 15, 2007 Author Share Posted August 15, 2007 I took the ; off and now im getting a new errror :'( You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 7 Quote Link to comment https://forums.phpfreaks.com/topic/65018-error/#findComment-324481 Share on other sites More sharing options...
AndyB Posted August 15, 2007 Share Posted August 15, 2007 Finding errors will be enormously simplified if you use a code arrangement like this: define the querystring execute the query with sensible error trapping $query = "INSERT into ..... whatever it is ....."; // define querystring $result = mysql_query($query) or die("Error: ". mysql_error(). " with query ". $query); // show error details Quote Link to comment https://forums.phpfreaks.com/topic/65018-error/#findComment-324484 Share on other sites More sharing options...
gurroa Posted August 15, 2007 Share Posted August 15, 2007 Sorry to miss all the others... $storedata = mysql_query('INSERT INTO liam_database(Username, Password, Email,Favourite Sport,IP,date); VALUES ( "'.addslashes($user).'", "'.md5($pass).'", "'.addslashes($email).'", "'.addslashes($sport).'", "'.addslashes($IP).'", "'.addslashes($date).'")') or die(mysql_error()); Missing , in values set and ) at the end. Quote Link to comment https://forums.phpfreaks.com/topic/65018-error/#findComment-324485 Share on other sites More sharing options...
LiamProductions Posted August 15, 2007 Author Share Posted August 15, 2007 Argh, Another error :@ You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '; VALUES ( "liammonks", ' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/65018-error/#findComment-324487 Share on other sites More sharing options...
AndyB Posted August 15, 2007 Share Posted August 15, 2007 You need to take more responsibilty for your own errors, not keep dumping them on us. How long did you look for the problem? Why didn't you implement error trapping as I recommended two posts ago - then you could have seen the entire querystring that was causing the error. Take a deep breath. Check your code. Check it again. Add error-trapping. Test it. And if you really can't see the problem, then post again in ten minutes, not ten seconds. Quote Link to comment https://forums.phpfreaks.com/topic/65018-error/#findComment-324495 Share on other sites More sharing options...
LiamProductions Posted August 15, 2007 Author Share Posted August 15, 2007 You need to take more responsibilty for your own errors, not keep dumping them on us. How long did you look for the problem? Why didn't you implement error trapping as I recommended two posts ago - then you could have seen the entire querystring that was causing the error. Take a deep breath. Check your code. Check it again. Add error-trapping. Test it. And if you really can't see the problem, then post again in ten minutes, not ten seconds. I've just tried to do the error finding and i fixed some things well i think so now this is something im getting: Error: Query was empty with query from: $query = mysql_query("INSERT into liam_database(Username, Password, Email,fsport,IP,date"); // define querystring $result = mysql_query($query) or die("Error: ". mysql_error(). " with query ". $query); // show error details does that mean its working now? Quote Link to comment https://forums.phpfreaks.com/topic/65018-error/#findComment-324500 Share on other sites More sharing options...
LiamProductions Posted August 15, 2007 Author Share Posted August 15, 2007 Right i think it might work if i fix this error but i've never come accross it before: Parse error: syntax error, unexpected $end in /home/liam/public_html/registerdone.php on line 76 on line 76 is the PHP closing tag ?> Quote Link to comment https://forums.phpfreaks.com/topic/65018-error/#findComment-324506 Share on other sites More sharing options...
trq Posted August 15, 2007 Share Posted August 15, 2007 This query.... $query = mysql_query("INSERT into liam_database(Username, Password, Email,fsport,IP,date"); Is missing the VALUES. Also note that Passowrd and date are reserved words on mysql. Seems you need to find some tutorials. Theres a great link in my signiture. As for your parse error. We'd need to see some code. Quote Link to comment https://forums.phpfreaks.com/topic/65018-error/#findComment-324522 Share on other sites More sharing options...
LiamProductions Posted August 15, 2007 Author Share Posted August 15, 2007 SOrry i made a new post look in there. Quote Link to comment https://forums.phpfreaks.com/topic/65018-error/#findComment-324526 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.