Jump to content

Archived

This topic is now archived and is closed to further replies.

Kevo

Error trying to write to MySQL

Recommended Posts

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? :(

Share this post


Link to post
Share on other sites

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]')";

Share this post


Link to post
Share on other sites

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

 

Share this post


Link to post
Share on other sites

×

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.