I have been over and over this but I can not find why it is giving this error. Parse error: syntax error, unexpected $end in /home/valerie2/public_html/elinkswap/snorris/file.php on line 78. Maybe if there was more eyes on it maybe be able to find where I didnt do something right. Thanks for looking.
<?php
session_start();
include "connect.php";
if ($_POST["submit"])
{
//Coding
if($_SESSION["name"])
{
//variables
$name = $_FILES["file"]["name"];
$type = $_FILES["file"]["type"];
$size = $_FILES["file"]["size"];
$tmp_name = $_FILES["file"]["tmp_name"];
$error = $_FILES["file"]["error"];
if ($type =="image/jpeg" || $type =="image/gif")
{
if ($size >1100000 && $size <1700000)
{
if($error > 0)
{
echo "Error!!!!!!".$error;
}
else
{
if(file_exists("upload/".$name))
{
echo $name." already exists.";
}
else
{
$location ="upload/".$name;
move_uploaded_file($tmp_name,$location);
$user = $_SESSION["name"];
$sqlcode = mysql_query("INSERT INTO imageupload (id,user,location) VALUES ('','$user','$location')");
echo "<a href='$location'>Click here to view your image.</a>";
}
}
}
else
{
echo "Please check the size of your File..";
}
}
else
{
echo "Invalid file format.";
}
Change you code to:
<?php
session_start();
include "connect.php";
if ( $_POST[ "submit" ] ) {
if ( $_SESSION[ "name" ] ) {
$name = $_FILES[ "file" ][ "name" ];
$type = $_FILES[ "file" ][ "type" ];
$size = $_FILES[ "file" ][ "size" ];
$tmp_name = $_FILES[ "file" ][ "tmp_name" ];
$error = $_FILES[ "file" ][ "error" ];
if ( $type == "image/jpeg" || $type == "image/gif" ) {
if ( $size > 1100000 && $size < 1700000 ) {
if ( $error > 0 ) {
echo "Error!!!!!!" . $error;
} else {
if ( file_exists( "upload/" . $name ) ) {
echo $name . " already exists.";
}
}
} else {
$location = "upload/" . $name;
move_uploaded_file( $tmp_name , $location );
$user = $_SESSION[ "name" ];
$sqlcode = mysql_query( "INSERT INTO imageupload (id,user,location) VALUES ('','$user','$location')" );
echo "<a href='$location'>Click here to view your image.</a>";
}
}
} else {
echo "Please check the size of your File..";
}
} else {
echo "Invalid file format.";
}
?>
And please use the practice to indent your code, it will be a quick and easy way to correct these errors.
Change this:
if ($size >1100000 && $size <1700000)
{
if($error > 0)
{
echo "Error!!!!!!".$error;
}
to....
if ($size >1100000 && $size <1700000)
{
if($error > 0)
{
echo "Error!!!!!!".$error;
}
}
Line 78 is just before the ?>
It is difficult to follow with so many nested IF staements, but it looks like you have failed to close 2 IFs (if submit and if name)