i got following error in my php program
error: Parse error: syntax error, unexpected $end in D:\xampp\htdocs\php\project\sample\upload.php on line 85

<?php /** 
* Upload an image to mysql database. * *
* * @author Mr. Vivek Chaurasia * @copyright www.techshri.com * @license LGPL 
*/ // Check for post data. 
if ($_POST && !empty($_FILES)) 

{
$formOk = true; 
//Assign Variables 
$path = $_FILES['image']['tmp_name']; 
$name = $_FILES['image']['name']; 
$size = $_FILES['image']['size']; 
$type = $_FILES['image']['type']; 
if ($_FILES['image']['error'] || !is_uploaded_file($path)) 
{ 
$formOk = false; 
echo "Error: Error in uploading file. Please try again.";
 }
  //check file extension 
  if ($formOk && !in_array($type, array('image/png', 'image/x-png', 'image/jpeg', 'image/pjpeg', 'image/gif'))) 

  { 
  $formOk = false; 
  echo "Error: Unsupported file extension. Supported extensions are JPG / PNG.";
   } 
   // check for file size. 
   if ($formOk && filesize($path) > 500000)
    { 
    $formOk = false; echo "Error: File size must be less than 500 KB.";
    }
     } if ($formOk)
      { 
      // read file contents 
      $content = file_get_contents($path); 
      //connect to mysql database 
      if ($conn = mysqli_connect('localhost', 'root', '', 'sample_db')) 
      { 
      $content = mysqli_real_escape_string($conn, $content); 
      $sql = "insert into images (name, size, type, content) values ('{$name}', '{$size}', '{$type}', '{$content}')";
       if (mysqli_query($conn, $sql)) 
       { 
       $uploadOk = true; $imageId = mysqli_insert_id($conn); 
       } 
       else 
       { 
       echo "Error: Could not save the data to mysql database. Please try again.";
        } 
        mysqli_close($conn);
       } 
       else 
       { 
       echo "Error: Could not connect to mysql database. Please try again.";
        } 
      } 


?> 
<html> 
<head> 
<title>
Upload image to mysql database.
</title> 
<style type="text/css"> 
img
{ margin: .2em; border: 1px solid #555; padding: .2em; vertical-align: top;
 } 
</style> 
</head> 
<body> 
<?php 
if (!empty($uploadOk)): ?>

 <div> <h3>Image Uploaded:</h3> </div>
  <div> <img src="image.php?id=<?=$imageId ?>" width="150px"> 

  <strong>Embed</strong>: <input size="25" value='<img src="http://localhost/php/project/sample/image.php?id=<?=$imageId ?>">'>
   </div> 
   <hr> <? endif; ?> 

   <form action="<?=$_SERVER['PHP_SELF']?>" method="post" enctype="multipart/form-data" > 

   <div> <h3>Image Upload:</h3> </div> 
   <div> <label>Image</label> <input type="hidden" name="MAX_FILE_SIZE" value="500000">
    <input type="file" name="image" /> <input name="submit" type="submit" value="Upload"> </div> 
    </form> </body> </html>

Without reading your code, if I had to guess, you are missing a closing } somewhere.

Is your php short tag is open in php.ini?

Ah, yes, vibhaJ.

If you're not sure what he's referring to, change <?=$_SERVER['PHP_SELF']?> on line 80 to <?php echo $_SERVER['PHP_SELF']; ?>

<?php
$submit = @$_POST['submit'];
//form data
$fullname = strip_tags (@$_POST['fullname']);
$username = strip_tags (@$_POST['username']);
$password= strip_tags(@$_POST['password']);
$repeatpassword = strip_tags(@$_POST['repeatpassword']);
$date =("Y-m-d");
if ($submit);
{
// check for existance
if($fullname&&$username&&$password&&$repeatpassword)
{
//encrypt password
$password = md5 ($password);
$repeatpassword =md5 ($repeatpassword);

if ($password==$repeatpassword)
{
// check char length of username and fullname
if (strlen($username)>25||strlen($fullname)>25)
{
echo ("Length of username or fullname is too long");
}
else
{
//check password length
if (strlen($password)>25|| strlen($password)<6)
{
 echo ("Password mus be betwen 6 and 25 characters");
}
else
{
//register the user!!
echo ("Success!!");
}

}
else
 echo ("Your password do not match");
}
else
echo("Please fill in <b>all</b> fields!");
}


?>

parse error: syntax error, unexpected end of file

can ypu please give me your image.php file

Member Avatar for diafol

You do realise that the last post was a year ago. Was there any specific reason why you wanted to resurrect this dead thread?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.