Jump to content

[SOLVED] Parse error


MDanz

Recommended Posts

Parse error: syntax error, unexpected $end in /home/ustackc1/public_html/insert.php on line 57

 

 

Heres my code.. can't figure it out

 

<?php // Create MySQL login values and

// set them to your login information.

$username = "Master";

$password = "Password";

$host = "localhost";

$database = "database";

 

// Make the connect to MySQL or die

// and display an error.

$link = mysql_connect($host, $username, $password);

if (!$link) {

    die('Could not connect: ' . mysql_error());

}

 

// Select your database

mysql_select_db ($database);

 

// Make sure the user actually

// selected and uploaded a file

if (isset($_FILES['image']) && $_FILES['image']['size'] > 0) {

 

      // Temporary file name stored on the server

      $tmpName  = $_FILES['image']['tmp_name']; 

     

      // Read the file

      $fp      = fopen($tmpName, 'r');

      $data = fread($fp, filesize($tmpName));

      $data = addslashes($data);

      fclose($fp);

     

 

      // Create the query and insert

      // into our database.

      $query = "INSERT INTO Upload ";

      $query .= "(image) VALUES ('$data')";

 

      $results = mysql_query($query, $link);

     

      $hyperlink = $_POST['hyperlink'];

$currency = $_POST['currency'];

$name = $_POST['name'];

$info = $_POST['info'];

$keywords = $_POST['keywords'];

 

$sql = @"'INSERT INTO 'Upload' ('hyperlink','currency','name','info','keywords') VALUES ('$hyperlink','$currency','$name','$info','$keywords')";

$query = @mysql_query($sql);

if($query){ print "Your image details have been uploaded to the database"; }

else {

print "No image selected/uploaded";

}

     

 

 

// Close our MySQL Link

mysql_close($link);

?>

Link to comment
https://forums.phpfreaks.com/topic/168749-solved-parse-error/
Share on other sites

$sql = @"'INSERT INTO 'Upload' ('hyperlink','currency','name','info','keywords') VALUES ('$hyperlink','$currency','$name','$info','$keywords')";

 

 

remove the "@" symbol... thats for supressing error reporting, basically infront of a function that returns a value. Not for strings

Link to comment
https://forums.phpfreaks.com/topic/168749-solved-parse-error/#findComment-890297
Share on other sites

thx i did that now it says "no image selected/uploaded" and i checked the database it has uploaded the image but it hasn't uploaded the details written in the text fields?

 

 

<?php // Create MySQL login values and

// set them to your login information.

$username = "Master";

$password = "password";

$host = "localhost";

$database = "database";

 

// Make the connect to MySQL or die

// and display an error.

$link = mysql_connect($host, $username, $password);

if (!$link) {

    die('Could not connect: ' . mysql_error());

}

 

// Select your database

mysql_select_db ($database);

 

// Make sure the user actually

// selected and uploaded a file

if (isset($_FILES['image']) && $_FILES['image']['size'] > 0) {

 

      // Temporary file name stored on the server

      $tmpName  = $_FILES['image']['tmp_name']; 

     

      // Read the file

      $fp      = fopen($tmpName, 'r');

      $data = fread($fp, filesize($tmpName));

      $data = addslashes($data);

      fclose($fp);

     

 

      // Create the query and insert

      // into our database.

      $query = "INSERT INTO Upload ";

      $query .= "(image) VALUES ('$data')";

 

      $results = mysql_query($query, $link);

     

      $hyperlink = $_POST['hyperlink'];

$currency = $_POST['currency'];

$name = $_POST['name'];

$info = $_POST['info'];

$keywords = $_POST['keywords'];

 

$sql = "INSERT INTO 'Upload' ('hyperlink','currency','name','info','keywords') VALUES ('$hyperlink','$currency','$name','$info','$keywords')";

$query = mysql_query($sql);

if($query){ print "Your image details have been uploaded to the database"; }

else {

print "No image selected/uploaded";

}

}

 

 

it displays no image selected/uploaded but it has uploaded an image but it hasn't uploaded the details..

 

here is the upload.php

 

<?php

session_start();

 

if ($_SESSION['username'])

 

echo "Welcome, ".$_SESSION['username']."!<br><a href='Logout.php'>Log Out</a>

 

<form enctype='multipart/form-data' action='insert.php' method='post' name='changer'>

<input name='MAX_FILE_SIZE' value='102400' type='hidden'>

<input name='image' accept='image/jpeg' type='file'>

<input type='text' name='hyperlink'value='hyperlink'>  <br>

<input type='text' name='currency' value='currency'> <br>

<input type='text' name='name' value='name'> <br>

<input type='text' name='info' value='info'> <br>

<input type='text' name='keywords' value='keywords'> <br>

<input type='submit' value='Submit'<br>

 

"

 

;

else

die("You must be logged in!");

 

?>

 

any ideas?

Link to comment
https://forums.phpfreaks.com/topic/168749-solved-parse-error/#findComment-890306
Share on other sites

it says this

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''Upload' ('hyperlink','currency','name','info','keywords') VALUES ('hyperlink','' at line 1

 

 

I think i gave you this part of the code... let me fix that

 

 

$sql = "INSERT INTO 'Upload' ('hyperlink','currency','name','info','keywords') VALUES ('$hyperlink','$currency','$name','$info','$keywords')";

 

 

to

 

 

$sql = "INSERT INTO `Upload` (`hyperlink',`currency`,`name`,`info`,`keywords`) VALUES ('$hyperlink','$currency','$name','$info','$keywords')";

 

 

 

for the column names i used single quotes instead of ticks

Link to comment
https://forums.phpfreaks.com/topic/168749-solved-parse-error/#findComment-890313
Share on other sites

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.