I am new to PHP and have written the following php code for an entry form on my website:
if ($_FILES['photo']['error'] == 0) {
// Move the file to the target upload folder
$target = WS_UPLOADPATH . $photo;
if (move_uploaded_ file($_FILES[('photo']['tmp_name'], $target)) {
// Connect to the database
$dbc = mysqli_connect( DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
// Write the data to the database
$query = "INSERT INTO contest_list (first_name, last_name, street_address, city, state, zip_code, " . "daytime, mobile, weight, feet, inches, email, birthdate, comments, photo') " .
"VALUES (0, '$first_name', '$last_name', '$street_addres s', '$city', '$state', '$zip_code', " . "'$daytime' , '$mobile', '$weight', '$feet', '$inches', '$email', '$birthdate', " .
"'$comments ', '$photo')";
$result = mysqli_query($d bc, $query)
or die('Error querying database.');
// Confirm success with the user
echo '<p>Thanks for participating in the Weight Shop's "New You" contest. </p>';
mysqli_close($d bc);
}
else {
echo '<p>Sorry, there was a problem uploading your photo image.</p>';
}
}
}
When I view the code in a browser I get the following error message:
Parse error: syntax error, unexpected T_ENCAPSED_AND_ WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING
The error is said to be in this line of code:
if ($_FILES['photo']['error'] == 0) {
above.
Will you please assist me?
if ($_FILES['photo']['error'] == 0) {
// Move the file to the target upload folder
$target = WS_UPLOADPATH . $photo;
if (move_uploaded_ file($_FILES[('photo']['tmp_name'], $target)) {
// Connect to the database
$dbc = mysqli_connect( DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
// Write the data to the database
$query = "INSERT INTO contest_list (first_name, last_name, street_address, city, state, zip_code, " . "daytime, mobile, weight, feet, inches, email, birthdate, comments, photo') " .
"VALUES (0, '$first_name', '$last_name', '$street_addres s', '$city', '$state', '$zip_code', " . "'$daytime' , '$mobile', '$weight', '$feet', '$inches', '$email', '$birthdate', " .
"'$comments ', '$photo')";
$result = mysqli_query($d bc, $query)
or die('Error querying database.');
// Confirm success with the user
echo '<p>Thanks for participating in the Weight Shop's "New You" contest. </p>';
mysqli_close($d bc);
}
else {
echo '<p>Sorry, there was a problem uploading your photo image.</p>';
}
}
}
When I view the code in a browser I get the following error message:
Parse error: syntax error, unexpected T_ENCAPSED_AND_ WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING
The error is said to be in this line of code:
if ($_FILES['photo']['error'] == 0) {
above.
Will you please assist me?
Comment