Jump to content

What's wrong with my upload script?


kirkh34

Recommended Posts

It says error unexpecting T_ELSE on line 50...Any help is appreciated

 

<?php



if (is_uploaded_file($file_tmp)){

///SUPPORTED IMAGE TYPES

$tgif = "IMAGETYPE_GIF";
$tjpeg = "IMAGETYPE_JPEG";
$tpng = "IMAGETYPE_PNG";
$twsf = "IMAGETYPE_SWF";
$tbmp = "IMAGETYPE_BMP";

$file_size = $_FILES["file"]["size"];
$file_tmp = $_FILES['file']['tmp_name'];
$file_name = $_FILES["file"]["name"] ;
$file_type = $_FILES["file"]["type"];
$file = $file_name . $file_type;


$path = "images/" . $title_id . "/";
$path - $path . basename($file_name);



   if (exif_imagetype('$file') != $tgif || $tjpeg || $tjpng || $twsf || $tbmp){ 


   		  		 if ($file_size < 20000000){     /////20mb/////
   			       					

					if (file_exists($path . $file_name)){


								if (move_uploaded_file($file_tmp,$path)){

								$msg = "File upload successful";	
								}

								else{
								$msg = "There was an error";
								}

					}else{
						$msg = "This file already exists on the server";
						{


			}else{
			 $msg = "File size is too large";
				  }				 

	}else{
		$msg = "File type not supported";
	}	


}else{
$file = "";
}







?>

Link to comment
https://forums.phpfreaks.com/topic/216196-whats-wrong-with-my-upload-script/
Share on other sites

thanks duh i should have seen that...been looking at code for too long..... it is work but I am getting another error from my mysql syntax......near 'desc = '', img = '' WHERE id = ''' at line 17

 

mysql_query("UPDATE titles SET title = '$title', desc = '$desc', img = '$file' WHERE id = '$title_id' ")
	 	or die (mysql_error()); 

desc is a reserved word (DESC, or DESCENDING)

 

I strongly suggest that you change that column name. If you prefer to keep it that way, add back-ticks to the column name in the sql:

 

mysql_query("UPDATE titles SET title = '$title', `desc` = '$desc', img = '$file' WHERE id = '$title_id' ")
	 	or die (mysql_error()); 

 

fyi: i typically use descr or whatever_desc for the column name for description.

Archived

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

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