jazzman1 Posted August 2, 2012 Share Posted August 2, 2012 You have a error here -> $result_verify_mobileno = mysqli_query($dbc, $query_verify_mobileno); What's $dbc ? Post out database_connection.php, too ? Quote Link to comment https://forums.phpfreaks.com/topic/266570-php-script-just-inserts-one-row-there-is-an-auto-increment-id/page/2/#findComment-1366189 Share on other sites More sharing options...
rahul19dj Posted August 2, 2012 Author Share Posted August 2, 2012 this is my database_connection.php <?php /*Define constant to connect to database */ DEFINE('DATABASE_USER', 'xxxxxxxx'); DEFINE('DATABASE_PASSWORD', 'xxxxxxxx'); DEFINE('DATABASE_HOST', 'localhost'); DEFINE('DATABASE_NAME', 'xxxxxxxxx'); /*Default time zone ,to be able to send mail */ date_default_timezone_set('Asia/Calcutta'); //This is the address that will appear coming from ( Sender ) define('EMAIL', 'rahul19dj@gmail.com'); /*Define the root url where the script will be found such as http://website.com or http://website.com/Folder/ */ DEFINE('WEBSITE_URL', 'xxxxxxxxxxxxx'); // Make the connection: $dbc = @mysqli_connect(DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD,DATABASE_NAME); if (!$dbc) { trigger_error('Could not connect to MySQL: ' . mysqli_connect_error()); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/266570-php-script-just-inserts-one-row-there-is-an-auto-increment-id/page/2/#findComment-1366193 Share on other sites More sharing options...
jazzman1 Posted August 2, 2012 Share Posted August 2, 2012 it seems like everything is ok. What error message did you get ? Quote Link to comment https://forums.phpfreaks.com/topic/266570-php-script-just-inserts-one-row-there-is-an-auto-increment-id/page/2/#findComment-1366196 Share on other sites More sharing options...
rahul19dj Posted August 2, 2012 Author Share Posted August 2, 2012 If the fname is same like the one in database it gives me error Query Failed and You could not be registered due to a system error. We apologize for any inconvenience. Quote Link to comment https://forums.phpfreaks.com/topic/266570-php-script-just-inserts-one-row-there-is-an-auto-increment-id/page/2/#findComment-1366197 Share on other sites More sharing options...
Drummin Posted August 2, 2012 Share Posted August 2, 2012 Besides dealing with your current issue with the query failing (more than likely due to $_POST['mobileno']), the value $_POST['checkbox'] is an array and needs to be handled as such. This should work. if (isset($_POST['checkbox'])){ $mumbai=(in_array("mumbai",$_POST['checkbox']) ? 1 : 0); $pune=(in_array("pune",$_POST['checkbox']) ? 1 : 0); $banglore=(in_array("banglore",$_POST['checkbox']) ? 1 : 0); $mysore=(in_array(1,$_POST['checkbox']) ? 1 : 0); } Quote Link to comment https://forums.phpfreaks.com/topic/266570-php-script-just-inserts-one-row-there-is-an-auto-increment-id/page/2/#findComment-1366198 Share on other sites More sharing options...
jazzman1 Posted August 2, 2012 Share Posted August 2, 2012 If the fname is same like the one in database it gives me error Query Failed and You could not be registered due to a system error. We apologize for any inconvenience. But.... this one is not true, right ? Quote Link to comment https://forums.phpfreaks.com/topic/266570-php-script-just-inserts-one-row-there-is-an-auto-increment-id/page/2/#findComment-1366199 Share on other sites More sharing options...
rahul19dj Posted August 2, 2012 Author Share Posted August 2, 2012 it should not happen, as I havent given any such condition Quote Link to comment https://forums.phpfreaks.com/topic/266570-php-script-just-inserts-one-row-there-is-an-auto-increment-id/page/2/#findComment-1366200 Share on other sites More sharing options...
rahul19dj Posted August 2, 2012 Author Share Posted August 2, 2012 hey jazzman1 thanks for the last help for the checkbox. I was scratching my head for the same too. Thanks, now just that fname mystery Quote Link to comment https://forums.phpfreaks.com/topic/266570-php-script-just-inserts-one-row-there-is-an-auto-increment-id/page/2/#findComment-1366203 Share on other sites More sharing options...
jazzman1 Posted August 2, 2012 Share Posted August 2, 2012 Ok, I think that you have an logically error. You use in the same if statement mysqli_num_rows and after that inside in this statement you called mysqli_affected_rows. There is nothing unusual Why did you use mysqli_num_rows and mysqli_affected_rows ? Quote Link to comment https://forums.phpfreaks.com/topic/266570-php-script-just-inserts-one-row-there-is-an-auto-increment-id/page/2/#findComment-1366204 Share on other sites More sharing options...
rahul19dj Posted August 2, 2012 Author Share Posted August 2, 2012 That is used for 2 reasons. 1. if no one has registered with that mobile number then do the insert 2. if the insert gets complete then send an email to the registered user Quote Link to comment https://forums.phpfreaks.com/topic/266570-php-script-just-inserts-one-row-there-is-an-auto-increment-id/page/2/#findComment-1366205 Share on other sites More sharing options...
rahul19dj Posted August 2, 2012 Author Share Posted August 2, 2012 hey how do I add a prefix to the mobileno and also limit them only for 10 digit and give error if more than 10 digit Quote Link to comment https://forums.phpfreaks.com/topic/266570-php-script-just-inserts-one-row-there-is-an-auto-increment-id/page/2/#findComment-1366206 Share on other sites More sharing options...
Drummin Posted August 2, 2012 Share Posted August 2, 2012 IF you echo $query_insert_user by adding this line below setting the variable, does it show expected variables for each field? echo "$query_insert_user"; By the way, you don't need all that extra markup in there. $query_insert_user = "INSERT INTO userdtls (mobileno,pass,fname,lname,email,MUM,PUN,BNG,MYS) VALUES ('$mobile','$password','$fname','$lname','$email','$mumbai','$pune','$banglore','$mysore')"; And if you haven't fixed the "checkbox" section with this code, then all those variables may not be getting set, also causing the query to fail. Echo the query to see if all values are passed to the query. if (isset($_POST['checkbox'])){ $mumbai=(in_array("mumbai",$_POST['checkbox']) ? 1 : 0); $pune=(in_array("pune",$_POST['checkbox']) ? 1 : 0); $banglore=(in_array("banglore",$_POST['checkbox']) ? 1 : 0); $mysore=(in_array(1,$_POST['checkbox']) ? 1 : 0); } Quote Link to comment https://forums.phpfreaks.com/topic/266570-php-script-just-inserts-one-row-there-is-an-auto-increment-id/page/2/#findComment-1366226 Share on other sites More sharing options...
rahul19dj Posted August 2, 2012 Author Share Posted August 2, 2012 hey i solved tht problem thanks a tonn for your help Quote Link to comment https://forums.phpfreaks.com/topic/266570-php-script-just-inserts-one-row-there-is-an-auto-increment-id/page/2/#findComment-1366227 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.