Kevo Posted June 28, 2004 Share Posted June 28, 2004 I'm busy trying to do my first php to MySQL project using Dreamweaver MX. I have a pretty straight forward form, but when I hit the "submit" button, I get the following error: Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in /home/breforml/public_html/patientSubmissionScript.php on line 14 Now, the code in my INSERT script looks like this: <?php //open the connection $conn = mysql_connect("localhost", "breforml_kevin", "joshcam1"); //pick the database to use mysql_select_db ("breforml_main", $conn); //create the sql statment $sql = "INSERT INTO main values('','$_POST[fName]','$_POST[sName]', '$_POST['patientAge'], '$_POST', '$_POST[cupSize]', '$_POST[chest]', '$_POST[hTel]', '$_POST[wTel]', '$_POST[cTel]', '$_POST[financeReq]', $_POST[patientsubscribe]','$_POST[comments]')"; //execute the sql statement if (mysql_query($sql, $conn)){ echo "Thank you! You have been added to our database and we will contact you shortly."; } else{ echo "Sorry, but something went wrong with your enquiry. Please go back and ensure that all fields have been completed."; } ?> Can anybody help me with this? Quote Link to comment https://forums.phpfreaks.com/topic/1882-error-trying-to-write-to-mysql/ Share on other sites More sharing options...
Bza Posted June 28, 2004 Share Posted June 28, 2004 You've got an error at the $_POST[patientAge] variable. Try this: $sql = "INSERT INTO main values('','$_POST[fName]','$_POST[sName]', '$_POST[patientAge]', '$_POST[eMail]', '$_POST[cupSize]', '$_POST[chest]', '$_POST[hTel]', '$_POST[wTel]', '$_POST[cTel]', '$_POST[financeReq]', $_POST[patientsubscribe]','$_POST[comments]')"; Quote Link to comment https://forums.phpfreaks.com/topic/1882-error-trying-to-write-to-mysql/#findComment-6122 Share on other sites More sharing options...
cocazoulou Posted June 28, 2004 Share Posted June 28, 2004 it's only because you use array in string..... just add {} after the $ for var is array $sql = "INSERT INTO main values('','${_POST[fName]}','${_POST[sName]}', '${_POST[patientAge]}', '${_POST}', '${_POST[cupSize]}', '${_POST[chest]}', '${_POST[hTel]}', '${_POST[wTel]}', '${_POST[cTel]}','${_POST[financeReq]}', ${_POST[patientsubscribe]}','${_POST[comments]}')"; cocazoulou Quote Link to comment https://forums.phpfreaks.com/topic/1882-error-trying-to-write-to-mysql/#findComment-6123 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.