louis_coetzee Posted October 13, 2009 Share Posted October 13, 2009 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(); Link to comment https://forums.phpfreaks.com/topic/177543-for-some-reason-mysql-query-not-working-not-inserting-please-check-it-out/ Share on other sites More sharing options...
GKWelding Posted October 13, 2009 Share Posted October 13, 2009 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; Link to comment https://forums.phpfreaks.com/topic/177543-for-some-reason-mysql-query-not-working-not-inserting-please-check-it-out/#findComment-936134 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.