pyke96 Posted February 12, 2008 Share Posted February 12, 2008 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 More sharing options...
marcus Posted February 12, 2008 Share Posted February 12, 2008 What's the error you have? Try selecting the database before executing a query, and for queries check for errors $result = mysql_query($query) or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/90738-database-not-accepting-values/#findComment-465094 Share on other sites More sharing options...
pyke96 Posted February 12, 2008 Author Share Posted February 12, 2008 What's the error you have? Try selecting the database before executing a query, and for queries check for errors $result = mysql_query($query) or die(mysql_error()); The database just isn't accepting the values is all. Link to comment https://forums.phpfreaks.com/topic/90738-database-not-accepting-values/#findComment-465097 Share on other sites More sharing options...
revraz Posted February 12, 2008 Share Posted February 12, 2008 Change the line like he showed you and it will tell you why. Link to comment https://forums.phpfreaks.com/topic/90738-database-not-accepting-values/#findComment-465100 Share on other sites More sharing options...
pyke96 Posted February 12, 2008 Author Share Posted February 12, 2008 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 Link to comment https://forums.phpfreaks.com/topic/90738-database-not-accepting-values/#findComment-465105 Share on other sites More sharing options...
marcus Posted February 12, 2008 Share Posted February 12, 2008 Can you confirm the values you are trying to process to the database coincide with the database indefinite value? INT, VARCHAR, TEXT, etc.. Link to comment https://forums.phpfreaks.com/topic/90738-database-not-accepting-values/#findComment-465107 Share on other sites More sharing options...
revraz Posted February 12, 2008 Share Posted February 12, 2008 Now echo your $query to see which field is blank. Link to comment https://forums.phpfreaks.com/topic/90738-database-not-accepting-values/#findComment-465109 Share on other sites More sharing options...
pyke96 Posted February 12, 2008 Author Share Posted February 12, 2008 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 Link to comment https://forums.phpfreaks.com/topic/90738-database-not-accepting-values/#findComment-465133 Share on other sites More sharing options...
revraz Posted February 12, 2008 Share Posted February 12, 2008 That would indicate it's not fine. Post the echo'd query. Link to comment https://forums.phpfreaks.com/topic/90738-database-not-accepting-values/#findComment-465137 Share on other sites More sharing options...
pyke96 Posted February 12, 2008 Author Share Posted February 12, 2008 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 Link to comment https://forums.phpfreaks.com/topic/90738-database-not-accepting-values/#findComment-465140 Share on other sites More sharing options...
revraz Posted February 12, 2008 Share Posted February 12, 2008 Missing the closing ) Link to comment https://forums.phpfreaks.com/topic/90738-database-not-accepting-values/#findComment-465143 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.