Jump to content

Archived

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

dekon

Parse Error: Syntax Error, Unexpected End Of File

Recommended Posts

i keep getting this error all the time i don't understand why this is happening could someone please help me.

<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb">
<body>
<h1>image upload to freecycle</h1><p>
<?php
require 'auth.php';
if(isset($_SESSION['loggedin'])){ 
//session is set, user is logged in 
}else{ 
header("http://stuweb.cms.gre.ac.uk/~sn027/login.html"); 
if ( !isset($_FILES['userFile']['type']) ) {
  die('<p>No image submitted</p></body></html>');
}
?>
<body>
<h1>Uploading Images to MySQL</h1><p>
<?php
if ( !isset($_FILES['userFile']['type']) ) {
  die('<p>No image submitted</p></body></html>');
}
?>
You submitted this file:<br /><br />
Temporary name: <?php echo $_FILES['userFile']['tmp_name'] ?><br />
Original name: <?php echo $_FILES['userFile']['name'] ?><br />
Size: <?php echo $_FILES['userFile']['size'] ?> bytes<br />
Type: <?php echo $_FILES['userFile']['type'] ?></p>


<?php
require 'mysql.php';
// Validate uploaded image file
if ( !preg_match( '/gif|png|x-png|jpeg/', $_FILES['userFile']['type']) ) {
  die('<p>Only browser compatible images allowed</p></body></html>');
} else if ( strlen($_POST['altText']) < 9 ) {
  die('<p>Please provide meaningful alternate text</p></body></html>');
} else if ( $_FILES['userFile']['size'] > 16384 ) {
  die('<p>Sorry file too large</p></body></html>');
// Connect to database
} else if ( !($link=mysql_connect($host, $user, $passwd)) ) {
  die('<p>Error connecting to database</p></body></html>');
} else if ( !(mysql_select_db($dbName)) ) {
  die('<p>Error selecting database</p></body></html>');
// Copy image file into a variable
} else if ( !($handle = fopen ($_FILES['userFile']['tmp_name'], "r")) ) {
  die('<p>Error opening temp file</p></body></html>');
} else if ( !($image = fread ($handle, filesize($_FILES['userFile']['tmp_name']))) ) {
  die('<p>Error reading temp file</p></body></html>');
} else {
  fclose ($handle);
  // Commit image to the database
  $image = mysql_real_escape_string($image);
  $alt = htmlentities($_POST['altText']);
  $query = 'INSERT INTO image (title,type,name,alt,img,description) VALUES ("' . $_FILES['userFile']['type'] . '","' . $_FILES['userFile']['name']  . '","' . $alt  . '","' . $image . '")';
  if ( !(mysql_query($query,$link)) ) {
     die('<p>Error writing image to database</p></body></html>');
  } else {
     die('<p>Image successfully copied to database</p></body></html>');
  }
}

Share this post


Link to post
Share on other sites

You have an insufficient amount of closing tags: }

 

As well as you are not closing your <?php syntax

Share this post


Link to post
Share on other sites

thanks was making me think for a while that i done something wrong works now cheers

Share this post


Link to post
Share on other sites

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