T_CONSTANT_ENCAPSED_STRING
Posted: Mon Aug 28, 2006 7:30 pm
I'm getting the following error
I've done a search and there in an equal number of [`] ['] and ["] throughout the code, so it's not an odd one out.
Everything around and above this line hasn't been changed in awhile, I've only made some changes later on in the code.Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/*****/public_html/*****/uploadingimg2.php on line 42
I've done a search and there in an equal number of [`] ['] and ["] throughout the code, so it's not an odd one out.
Code: Select all
<html>
<head>
<title>
Image upload test site: Upload and confirm
</title>
</head>
<body>
<?php
//Common header
include "header.inc";
?>
<h3>
Uploading File.
</h3>
<?php
//Assign something from somewhere
$picture = $_FILES["mainPic"]["name"];
$thumbnail = $_FILES["thumbPic"]["name"];
$description = $_POST["picDesc"];
//Directory to upload file
$uploadDir = "pics/";
//Database to log into
Line 42> $database = mysql_connect "*****", "*****", "*****";
if(!empty($_FILES["mainPic"]))
{
//Upload main pic and get the id number of the database entry.
$pictureId = uploadMainPic($picture, $uploadDir, $database);
uploadThumbnail($thumbnail, $uploadDir, $database, $pictureId);
uploadDescription($description, $database, $pictureId);
}
else
{
//Display error message
echo "Error!";
echo "<br / >";
echo "<a href = \"uploadingimg.php\">Back</a>";
}
/******************************************************************************
End of main code
******************************************************************************/
/******************************************************************************
Functions
******************************************************************************/
/******************************************************************
function: uploadMainPic
This function checks for and uploads the main image.
******************************************************************/
function uploadMainPic($picture, $uploadDir, $database)
{
//Upload the file
if (move_uploaded_file($_FILES["mainPic"]["tmp_name"], $uploadDir . $_FILES["mainPic"]["name"]))
{
//Database to insert the file details into.
mysql_select_db "*****",$database);
//Insert file into the database table 'pics', so it can be accessed.
mysql_query "INSERT INTO `pics` ( `id` , `image` , `thumb` , `desc` ) VALUES ('', '$picture', '', '');",$database);
//Scan entries in database to find the id number of the pic just uploaded.
//Get entries in database and put them in an array
$picArray = mysql_query "select * from pics order by id", $database);
//Find out how many rows in the array
$rows = mysql_num_rows($picArray);
//Step through the array to find an entry that matches the pic just uploaded and get the id number
for ($count=0; $count < $rows; $count++)
{
$myrow = mysql_fetch_row($picArray);
if ($myrow[1] == $picture)
{
$pictureId = $myrow[0];
}
}
}
else
{
//Display error message
echo "Error!";
echo "<br / >";
echo "<a href = \"uploadingimg.php\">Back</a>";
}
return $pictureId;
}
/******************************************************************
end function: uploadMainPic
******************************************************************/
/******************************************************************
function: uploadThumbnail
This function adds the thumbnail.
******************************************************************/
function uploadThumbnail($thumbnail, $uploadDir, $database, $pictureId)
{
//Upload the file
if (move_uploaded_file($_FILES["thumbPic"]["tmp_name"], $uploadDir . $_FILES["thumbPic"]["name"]))
{
//Database to insert the file details into.
mysql_select_db "*****",$database);
//Modify the entry for the pic just uploaded and enter the thumbnail file into the database table 'pics', so it can be accessed.
mysql_query "update pics set thumb = '$thumbnail' where id = '$pictureId'", $database);
}
else
{
//Display error message
echo "Error!";
echo "<br / >";
echo "<a href = \"uploadingimg.php\">Back</a>";
}
}
/******************************************************************
end function: uploadThumbnail
******************************************************************/
/******************************************************************
function: uploadDescription
This function adds the picture description.
******************************************************************/
function uploadDescription($description, $database, $pictureId)
{
//Database to insert the description into.
mysql_select_db "*****",$database);
//Modify the entry for the pic just uploaded and enter the description into the database table 'pics', so it can be accessed.
mysql_query "update pics set desc = '$description' where id = '$pictureId'", $database);
}
/******************************************************************
end function: uploadDescription
******************************************************************/
/******************************************************************************
End functions
******************************************************************************/
?>
</body>
</html>