Jump to content


Error trying to write to MySQL

  • Please log in to reply
2 replies to this topic

#1 Kevo

  • Members
  • Pip
  • Newbie
  • 1 posts

Posted 28 June 2004 - 08:20 AM

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:

//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[eMail]', '$_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? :(

#2 Bza

  • Members
  • Pip
  • Newbie
  • 2 posts

Posted 28 June 2004 - 08:35 AM

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


#3 cocazoulou

  • Members
  • Pip
  • Newbie
  • 1 posts
  • LocationMontréal

Posted 28 June 2004 - 09:36 AM

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[eMail]}', '${_POST[cupSize]}', '${_POST[chest]}', '${_POST[hTel]}', '${_POST[wTel]}', '${_POST[cTel]}','${_POST[financeReq]}', ${_POST[patientsubscribe]}','${_POST[comments]}')";


public static int[] solutionEquationDeuxVariable(int[] equationUn, int[] equationDeux)[br]	{[br]  int variable[][] = new int[2][equationUn.length];[br]  for(int i = 0; i < equationUn.length; i++)[br]  {[br]  	variable[0][i] = equationUn[i];[br]  	variable[1][i] = equationDeux[i];[br]  }[br]  int varSol[] = new int[equationUn.length-1];[br]  for(int i = 1; i < varSol.length; i++)[br]  {[br]  	int tmp = 0;[br]  	varSol[i] = 0;[br]  	if((variable[0][i]-variable[1][i])!=0)[br]  	{[br]    for(int j = i+1; j < varSol.length; j++)[br]    {[br]    	tmp+=variable[1][j]-variable[0][j];[br]    }[br]    tmp+=variable[0][0]-variable[1][0];[br]    varSol[i] = tmp/(variable[0][i]-variable[1][i]);[br]  	}[br]  }[br]  return(varSol);[br]	}

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users