Jump to content

for some reason mysql query not working, not inserting, please check it out


louis_coetzee

Recommended Posts

This code is not inserting anything into my db, don't know why, the $_SESSION variable does contain data.

 

Please have a look.


function add_user_to_db()
{
	//print_r($_SESSION['user_reg']);
	$username = $_SESSION['user_reg']['username'];
	$password = $_SESSION['user_reg']['password'];
	$email = $_SESSION['user_reg']['email'];
	$first_name = $_SESSION['user_reg']['first_name'];
	$last_name = $_SESSION['user_reg']['last_name'];
	$pharmacyname = $_SESSION['user_reg']['pharmacyname'];
	$contact_number = $_SESSION['user_reg']['contact_number'];

	$connection = db_connect();	
    $query = "INSERT INTO `pharma_edu`.`users` (`user_id`, `username`, `password`, `email`, `first_name`, `last_name`, `pharmacy_name`, `contact_number`, `user_access`, `active`) VALUES (NULL, '$username','$password', '$email', '$first_name', '$last_name', '$pharmacyname', '$contact_number', '1', 'n')";

	if (mysql_query($query))
	{
		return true;
	}else{
		return false;
	}
}
add_user_to_db();

any errors?

 

change to:

 

      if (mysql_query($query))
      {
         return true;
      }else{
         die('Invalid query: ' . mysql_error());
      }

 

to check for errors then make sure you turn it back to return false;

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.