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. Quote 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()); Quote 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. Quote 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. Quote 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 Quote 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.. Quote 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. Quote 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 Quote 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. Quote 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 Quote 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 ) Quote Link to comment https://forums.phpfreaks.com/topic/90738-database-not-accepting-values/#findComment-465143 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.