Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMUZ140306 Blessing Muhakichi
1,627 PointsHow can i correct this error
Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in C:\xampp\htdocs\manifestcode\connect.php on line 31
#of the below code
$connect = mysql_connect("localhost","root", "");
mysql_select_db("manifestdb",$connect);
$submit = $_POST['submit'];
$first_name = $_POST['first_name'];
$surname = $_POST['surname'];
$DOB = $_POST['DOB'];
$brief_description = $_POST['brief_description'];
$birth_place = $_POST['birth_place'];
if ($submit)
{
$connect = mysql_connect("localhost","root","");
mysql_select_db("manifestdb",$connect);
$query = mysql_query("INSERT INTO spouse_details VALUES('$first_name','$surname','$DOB','$brief_description','$birth_place')");
die(mysql_error());
}
echo("<script language=javascript> alert('data saved, Fill the following forms'); location=('recruitment_page.php');</script>")
the first line of code is line 31
Ele Thompson
8,420 PointsThe code you provided seems to be good. It's possible you're missing a comma or semi-colon earlier in the code that is causing this error. A good resource for simple syntax errors is phpcodechecker.com
You may also want to start using mysqli_query and mysqli_connect rather than mysql_query and mysql_connect since those functions are deprecated.
1 Answer
Jorge Felico
15,543 PointsYou are missing a semicolon at the end of the last line.
echo("<script language=javascript> alert('data saved, Fill the following forms'); location=('recruitment_page.php');</script>") // <---- Semicolon Here!!
See my comment at the end of line above.
Donnie Reese
17,211 PointsDonnie Reese
17,211 PointsI don't think that the code snippet goes to line 31. Could you provide us with the line an the first few before and after?