ardyandkari Posted October 14, 2007 Share Posted October 14, 2007 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 https://forums.phpfreaks.com/topic/73190-solved-file-upload-help/ Share on other sites More sharing options...
mattal999 Posted October 14, 2007 Share Posted October 14, 2007 <?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 https://forums.phpfreaks.com/topic/73190-solved-file-upload-help/#findComment-369184 Share on other sites More sharing options...
ardyandkari Posted October 14, 2007 Author Share Posted October 14, 2007 wow...i guess that when you look at a bunch of letters for too long, they all look the same. Thanks so much! Link to comment https://forums.phpfreaks.com/topic/73190-solved-file-upload-help/#findComment-369516 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.