Jump to content

Recommended Posts

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());
}

?>

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);	
}

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 ?

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 ?

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);	
}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.