Jump to content

file upload error


chris_rulez001

Recommended Posts

hi ive got a problem with my file uploader:

 

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/www/hostsareus.awardspace.co.uk/file_upload2.php on line 49

 

my code:

 

<?php
$id = $_POST['id'];
$username = $_POST['username'];
if( $_FILES["file"]["type"] == "image/gif" 
|| $_FILES["file"]["type"] == "image/pjpeg" 
|| $_FILES["file"]["type"] == "image/png" 
|| $_FILES["file"]["type"] == "image/bmp" 
|| $_FILES["file"]["type"] == "movie/swf" 
|| $_FILES["file"]["type"] == "image/jpeg" 
|| $_FILES["file"]["type"] == "music/mp3" 
|| $_FILES["file"]["type"] == "music/wma" 
&& $_FILES["file"]["size"] < 5000 )
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "<h4>Upload Successful!</h4><br/>";
echo "<strong>Upload:</strong> " . $_FILES["file"]["name"] . "<br /><br />";
echo "<strong>Type:</strong> " . $_FILES["file"]["type"] . "<br /><br />";
echo "<strong>Size:</strong> " . ($_FILES["file"]["size"] / 1024) . " Kb<br /><br />";
echo "<strong>Temp file:</strong> " . $_FILES["file"]["tmp_name"] . "<br /><br />";

if (file_exists("memberuploads/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{

move_uploaded_file($_FILES["file"]["tmp_name"],
"memberuploads/" . $_FILES["file"]["name"]);
echo "<strong>Stored in:</strong> " . "http://hostsareus.awardspace.com/memberuploads/" . $_FILES["file"]["name"];
echo "<br/><br/><strong>ALL</strong> inappropriate images, movies, music <strong>WILL</strong> be deleted!";
echo "<br/><br/>Click <a href='index.php'>here</a> to return to the homepage.";
$filename = $_FILES["file"]["name"];

mysql_connect("fdb1.awardspace.com", "******************", "****************")
or die ('Connection to database failed: ' . mysql_error());
mysql_select_db("************");

$today = date("D M d Y");
$filetype = $_FILES["file"]["type"];
$filesize = $_FILES["file"]["size"];
$ip = $_SERVER['REMOTE_ADDR'];

mysql_query("INSERT INTO tracking(id, username, date, ipaddress, filename, filetype, filesize) VALUES ('$id', '$_SESSION['username']', '$today', '$ip', '$filename', '$filetype', '$filesize')");

}
}
}
else
{
echo "Invalid file";
}
?>

Link to comment
Share on other sites

Try replacing this

mysql_query("INSERT INTO tracking(id, username, date, ipaddress, filename, filetype, filesize) VALUES ('$id', '$_SESSION['username']', '$today', '$ip', '$filename', '$filetype', '$filesize')");

with this

$username = $_SESSION['username'];
mysql_query("INSERT INTO tracking(id, username, date, ipaddress, filename, filetype, filesize) VALUES ('$id', '$username', '$today', '$ip', '$filename', '$filetype', '$filesize')");

the single quote in your $_SESSION['username'] is breaking the SQL string I think.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.