Hypersource Posted November 20, 2012 Share Posted November 20, 2012 (edited) heres my code: $sql=" INSERT INTO `a8392424_pets`.`users` ( `user_id` , `user_name` , `user_pass` , `user_email` , `user_date` , `user_level` , `posts` , `married` , `cash` , `tokens` ) VALUES ( NULL, '" . mysql_real_escape_string($_POST['user_name']) . "', '" . sha1($_POST['user_pass']) . "', '" . mysql_real_escape_string($_POST['user_email']) . "', NOW(),'0', 'noone', '10000', '10')"; $result = mysql_query($sql); if(!$result) { //something went wrong, display the error echo 'Something went wrong while registering. Please try again later.'; //echo mysql_error(); //debugging purposes, uncomment when needed } When I execute it, using my signup form, the query fails. my connection to database is GOOD. Edited November 20, 2012 by Hypersource Quote Link to comment https://forums.phpfreaks.com/topic/270955-mysql-query-code-help/ Share on other sites More sharing options...
mrMarcus Posted November 20, 2012 Share Posted November 20, 2012 "the query fails" is quite vague. Luckily, it's a simple fix. You have 10 `columns` to your 9 values to be inserted. I would recommend using mysql_error(), y'know, for debugging purposes. Quote Link to comment https://forums.phpfreaks.com/topic/270955-mysql-query-code-help/#findComment-1393921 Share on other sites More sharing options...
play_ Posted November 20, 2012 Share Posted November 20, 2012 (edited) As mrMarcus said. user_id is probably an auto increment field, so you can delete the line `user_id` , if it still doesn't work, uncomment "//echo mysql_error(); //debugging purposes, uncomment when needed". and comeback with a decent error message. it even says right there. "debugging purposes. uncomment when needed". Edited November 20, 2012 by play_ Quote Link to comment https://forums.phpfreaks.com/topic/270955-mysql-query-code-help/#findComment-1393931 Share on other sites More sharing options...
Hypersource Posted November 21, 2012 Author Share Posted November 21, 2012 Thanks but I just now realized that the "posts" field had nothing included. Thanks for telling me about the mysql error thing. Thanks SO much!! Quote Link to comment https://forums.phpfreaks.com/topic/270955-mysql-query-code-help/#findComment-1393949 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.