Jump to content

Syntax error help


slj90

Recommended Posts

I am trying to write to a mysql database but I am getting an error.

Here is the code:

 

<?php

$Username = $_POST['Username'];
$Password = $_POST ['Password'];
$Email = $_POST ['Email'];
$Goal = $_Goal ['Goal'];


$dbhost="mysql4.000webhost.com";
$username="a7564065_si";
$password="*****";
$database="a7564065_food";

mysql_connect($dbhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query="INSERT INTO Users (id, Username, Password, Email, Goal)

mysql_query($query) or die ('Error creating account')

echo "Account created: " .$Username. " .$Goal ;

?>

 

Error mesage is:

 

 

Parse error: syntax error, unexpected T_STRING in /home/a7564065/public_html/add.php on line 21

 

Any ideas?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/218686-syntax-error-help/
Share on other sites

$query="INSERT INTO Users (id, Username, Password, Email, Goal)

mysql_query($query) or die ('Error creating account')

 

is missing a "; on the first line, and ; on the second. It should be like this

 

$query="INSERT INTO Users (id, Username, Password, Email, Goal)";

mysql_query($query) or die ('Error creating account');

 

Also, is $_GOAL a valid variable, Shouldn't it $_POST?

Link to comment
https://forums.phpfreaks.com/topic/218686-syntax-error-help/#findComment-1134247
Share on other sites

Thanks for those errors. However it now says 'Error making account' when I run the script..

 

<?php

$Username = $_POST['Username'];
$Password = $_POST['Password'];
$Email = $_POST['Email'];
$Goal = $_POST['Goal'];


$dbhost="mysql4.000webhost.com";
$username="a7564065_si";
$password="simple989";
$database="a7564065_food";

mysql_connect($dbhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query="INSERT INTO Users (id, Username, Password, Email, Goal)";

mysql_query($query) or die ('Error creating account');


?>

 

Here is the page with the form on..

 

<HTML>
<HEAD>
<TITLE>Form Handling with PHP</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<FORM METHOD=POST ACTION="add.php">
<input type="hidden" name="id" value="NULL">
<TABLE>
<TR height="20">
<TD colspan="2"><FONT SIZE="+0" face="verdana"> Register</TD>
</TR>
<TR height="50">
<td></td>
</TR>
<TR>
<TD align="left"><FONT SIZE="+0" face="verdana"><b>Username <br>
Password<br>
Email<br>
Goal</b></td>
<td><INPUT TYPE="text" NAME="Username">
<br>
<INPUT TYPE="text" NAME="Password">
<br>
<INPUT TYPE="text" NAME="Email"><br>
<select name="Goal">
  <option value="WeightLoss">Weight Loss</option>
  <option value="GainMuscle">Gain Muscle</option>
  <option value="Fitness">Fitness</option>
</select></TD>
</TR>
<tr>
<td colspan="2"><center>
  <INPUT TYPE="submit" value="Submit">
</td>
</tr>
</TABLE>
</FORM>
</BODY>
</HTML>

 

Thanks  :D

Link to comment
https://forums.phpfreaks.com/topic/218686-syntax-error-help/#findComment-1134259
Share on other sites

Archived

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

×
×
  • Create New...

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.