Jump to content

database not accepting values


pyke96

Recommended Posts

if ($connection){

      $query = "INSERT INTO patients (patient_first_name, patient_last_name, patient_user_name, patient_pass_word, patient_address, patient_county, patient_country) VALUES ('".$_SESSION['firstname']."', '".$_SESSION['lastname']."', '".$_SESSION['username']."', '".$_SESSION['password']."', '".$_SESSION['address']."', '".$_SESSION['county']."', '".$_SESSION['country']."'";

      $result = mysql_query($query);

echo "New record added to the database";}

else

      echo "connection failed";

 

$db = mysql_select_db("pykesjdb") or die(mysql_error());

echo "<p>Database selected</p>";

 

include ('./templates/footer.php')

?>

</div> <!--end of bodycontent div -->

 

Can anyone see why the database isn't accepting these values?

All the variables are correct and are picking up the info from the form.

 

 

Link to comment
https://forums.phpfreaks.com/topic/90738-database-not-accepting-values/
Share on other sites

Change the line like he showed you and it will tell you why.

 

Ya I have that done and this is what im getting back:

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

Now echo your $query to see which field is blank.

 

Ya $query is coming out fine. Everything is in there.

The error im getting is as follows: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

That would indicate it's not fine.

 

Post the echo'd query.

 

This is the echoed query:

Database selected

INSERT INTO patients (patient_first_name, patient_last_name, patient_user_name, patient_pass_word, patient_address, patient_county, patient_country) VALUES ('joe', 'pyke', 'pykej', '12345', 'model farm road', 'cork', 'ireland'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

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.