Jump to content

Parse Error: Syntax Error, Unexpected End Of File


dekon

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>');
  }
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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