Jump to content

Parse error: syntax error, unexpected T_STRING : Help


o_oe

Recommended Posts

Hi Friends,Please I have a form on my website designed to deposite filled content to a database. Everything has been set-up but onclicking on the submit button, an error message occurs.This is the error message:Parse error: syntax error, unexpected T_STRING in /home/beamz/public_html/career.php on line 4This is the content of line 4:$full name = $_POST['full name'];Thanks for your time.

Link to comment
Share on other sites

Variables can only be one word long. Use $fullname, or perhaps $fullName or $full_name. You decide, but keep it a single word - no spaces.

Link to comment
Share on other sites

But I don't find the data in my database. This the the code that I used.<?php// Pick up the form data and assign it to variables$position = $_POST['position'];$full_name = $_POST['full_name'];$e_mail = $_POST['e_mail'];$phone = $_POST['phone'];$address = $_POST['address'];$city = $_POST['city'];$country = $_POST['country'];$comment = $_POST['comment'];// Open database connection$conn = mysql_connect('localhost', 'username', 'password');mysql_select_db('database');// Insert data$query = "INSERT INTO table (position,full_name, e_mail, phone, address, city, country, comment) ... VALUES ('$position','$full_name', '$e_mail', '$phone', '$address', '$city', '$country', '$comment')";mysql_query($query);// Close connectionmysql_close($conn);// Redirectheader("Location: confirmation.htm");

Link to comment
Share on other sites

does it show any error message?and what are these three ... doing there?$query = "INSERT INTO table (position,full_name, e_mail, phone, address, city, country, comment) ...VALUES ('$position','$full_name', '$e_mail', '$phone', '$address', '$city', '$country', '$comment')";

Link to comment
Share on other sites

You need to escape all of the variables from $_POST. If there is a single quote anywhere the SQL statement will fail.$position = mysql_real_escape_string($_POST['position']);$full_name = mysql_real_escape_string($_POST['full_name']);etc

Link to comment
Share on other sites

You need to escape all of the variables from $_POST. If there is a single quote anywhere the SQL statement will fail.$position = mysql_real_escape_string($_POST['position']);$full_name = mysql_real_escape_string($_POST['full_name']);etc
Do you mean that $position = $_POST['position'];for instance should be replaced with$position = mysql_real_escape_string($_POST['position']);Thanks for your time.
Link to comment
Share on other sites

Archived

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

×
×
  • Create New...