0

hello pleas help me ,

it says i have a suntax error in line 19 ";"

<?php 
// if something was posted, start the process... 
if(isset($_POST['upload'])) 
{ 

// define the posted file into variables 
$name = $_FILES['picture']['name']; 
$tmp_name = $_FILES['picture']['tmp_name']; 
$type = $_FILES['picture']['type']; 
$size = $_FILES['picture']['size']; 

// get the width & height of the file (we don't need the other stuff) 
list($width, $height, $typeb, $attr) = getimagesize($tmp_name); 

// if width is over 600 px or height is over 500 px, kill it     
if($width>600 || $height>500) 
{ 
echo $name . "'s dimensions exceed the 600x500 pixel limit."; 
echo ?> <a href="form.html">Click here</a> to try again. <? ; 
die(); 
} 

// if the mime type is anything other than what we specify below, kill it     
if(!( 
$type=='image/jpeg' || 
$type=='image/png' || 
$type=='image/gif' 
)) { 
echo $type .  " is not an acceptable format."; 
echo ?> <a href="form.html">Click here</a> to try again. <? ; 
die(); 
} 

// if the file size is larger than 350 KB, kill it 
if($size>'350000') { 
echo $name . " is over 350KB. Please make it smaller."; 
echo ?> <a href="form.html">Click here</a> to try again. <? ; 
die(); 
}



// if your server has magic quotes turned off, add slashes manually 
if(!get_magic_quotes_gpc()){ 
$name = addslashes($name); 
} 

// open up the file and extract the data/content from it 
$extract = fopen($tmp_name, 'r'); 
$content = fread($extract, $size); 
$content = addslashes($content); 
fclose($extract); 




// connect to the database 
include "connect.php"; 

// the query that will add this to the database 
$addfile = "INSERT INTO files (name, size, type, content ) ". 
           "VALUES ('$name', '$size', '$type', '$content')"; 

mysql_query($addfile) or die(mysql_error()); 

// get the last inserted ID if we're going to display this image next 
$inserted_fid = mysql_insert_id(); 

mysql_close(); 



echo "Successfully uploaded your picture!"; 

// we still have to close the original IF statement. If there was nothing posted, kill the page. 
}else{die("No uploaded file present"); 
} 
?>  





header( "Location: form.html"); 

// we still have to close the original IF statement. If there was nothing posted, kill the page. 
}else{die("No uploaded file present"); 
} 
?>  



// display the image 
?> 
<div align="center"> 
    <strong><? echo $name; ?><br> 
    </strong><img name="<? echo $name; ?>" src="getpicture.php?fid=<? echo $inserted_fid; ?>" alt="Unable to view image #<? echo $inserted_fid; ?>"> 
    <br> 
    <a href="form.html">upload more images</a> 
</div> 
<? 
// we still have to close the original IF statement. If there was nothing posted, kill the page. 
}else{die("No uploaded file present"); 
} 
?>

thank you for your kind help

3
Contributors
2
Replies
17
Views
3 Years
Discussion Span
Last Post by Bachu
0

your missing "PHP" from your tag:

echo ?> <a href="form.html">Click here</a> to try again. <? ;
Should be:

echo ?> <a href="form.html">Click here</a> to try again.
<?php

Or change the line completely:

echo "<a href='form.html'>Click here</a> to try again";

Edited by Squidge

0

Hai;

I have done some changes on your code. Please check.I think it will help you.

<?php 
// if something was posted, start the process... 
if(isset($_POST['upload'])) 
{ 

// define the posted file into variables 
$name = $_FILES['picture']['name']; 
$tmp_name = $_FILES['picture']['tmp_name']; 
$type = $_FILES['picture']['type']; 
$size = $_FILES['picture']['size']; 

// get the width & height of the file (we don't need the other stuff) 
list($width, $height, $typeb, $attr) = getimagesize($tmp_name); 

// if width is over 600 px or height is over 500 px, kill it     
if($width>600 || $height>500) 
{ 
    echo $name . "'s dimensions exceed the 600x500 pixel limit."; 
    echo '<a href="form.html">Click here</a> to try again.';
    die(); 
} 

// if the mime type is anything other than what we specify below, kill it     
if(!($type=='image/jpeg' || $type=='image/png' || $type=='image/gif' )) { 
    echo $type .  " is not an acceptable format."; 
    echo '<a href="form.html">Click here</a> to try again.';
    die(); 
} 

// if the file size is larger than 350 KB, kill it 
if($size>'350000') { 
    echo $name . " is over 350KB. Please make it smaller."; 
    echo '<a href="form.html">Click here</a> to try again.'; 
    die(); 
}



// if your server has magic quotes turned off, add slashes manually 
if(!get_magic_quotes_gpc()){ 
$name = addslashes($name); 
} 

// open up the file and extract the data/content from it 
$extract = fopen($tmp_name, 'r'); 
$content = fread($extract, $size); 
$content = addslashes($content); 
fclose($extract); 




// connect to the database 
include "connect.php"; 

// the query that will add this to the database 
$addfile = "INSERT INTO files (name, size, type, content ) ". 
           "VALUES ('$name', '$size', '$type', '$content')"; 

mysql_query($addfile) or die(mysql_error()); 

// get the last inserted ID if we're going to display this image next 
$inserted_fid = mysql_insert_id(); 

mysql_close(); 



echo "Successfully uploaded your picture!"; 
?>
<div align="center"> 
    <strong><? echo $name; ?><br> 
    </strong><img name="<? echo $name; ?>" src="getpicture.php?fid=<? echo $inserted_fid; ?>" alt="Unable to view image #<? echo $inserted_fid; ?>"> 
    <br> 
    <a href="form.html">upload more images</a> 
</div> 
<?php
// we still have to close the original IF statement. If there was nothing posted, kill the page. 
}
else{die("No uploaded file present"); 
} 

?>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.