Jump to content

[SOLVED] file upload help...


ardyandkari

Recommended Posts

hi.  i am trying to get a file upload script to work, but it doesn't.

 

i am using php 4.1 i believe (godaddy) not 5.

 

what i am trying to do is upload a file and then put the file name into a database where i can simply echo the name like this

echo "<img src = "upload/$foo">" or whatever...i am probably wrong on the syntax or something but you get the point.

 

i have the following script:

 

<?php
$target = "upload/";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
echo "<a href='fileupload.htm'>CLICK HERE to return.</a>";
}
else {
echo "Sorry, there was a problem uploading your file.";
echo "<a href='fileupload.htm'>CLICK HERE to return.</a>"

}
?>
<?php
$hostname="sqlserver";
$username="username";
$password="password";
$dbname="database";
$usertable="table";

mysql_connect($hostname,$username, $password) OR DIE ("Unable to connect to database! Please try again later.");
mysql_select_db($dbname);
$query="INSERT INTO `customers` (file) VALUES ('{$target}') ";
$result = mysql_query($query) or die(mysql_error());

?>

 

i get the following error:

 

Parse error: parse error, unexpected '}', expecting ',' or ';' in /home/content/r/y/a/ryancyschultz/html/fileupload.php on line 17

 

15:  echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";

16:  echo "<a href='fileupload.htm'>CLICK HERE to return.</a>";

17:  }

 

i tried taking out the echo lines completely and nothing...any help is GREATLY appreciated.  thanks a lot.

 

also, i am making this script for a site, but it will be password protected, so dont worry about telling me how insecure this is i already know.

 

thanks again.

Link to comment
Share on other sites

<?php
$target = "upload/";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
echo "<a href='fileupload.htm'>CLICK HERE to return.</a>";
}
else {
echo "Sorry, there was a problem uploading your file.";
echo "<a href='fileupload.htm'>CLICK HERE to return.</a>"; // you're missing a semi-colon

}
?>

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.