Hypersource Posted November 20, 2012 Share Posted November 20, 2012 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. 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. 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 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". 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!! Link to comment https://forums.phpfreaks.com/topic/270955-mysql-query-code-help/#findComment-1393949 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.