illuz1on Posted July 31, 2007 Share Posted July 31, 2007 Hey getting this error, cant seem to see why - anyone know ? The file CTA Domains.txt has been uploadedYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc)VALUES ('NULL', 'CTA Domains.txt', 'sadsadsa')' at line 1 <?php include "db.php"; $target_path = "uploads/"; $name = basename( $_FILES['uploadedfile']['name']); $desc1 = $_POST["desc1"]; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; } $addoffer = MYSQL_QUERY("INSERT INTO uploaddb (id,name,desc1)". "VALUES ('NULL', '$name', '$desc1')") or die (mysql_error ()); echo "Upload Successful:"; echo "Name: $name"; echo "Description: $desc1"; ?> Link to comment https://forums.phpfreaks.com/topic/62638-syntax-error-cant-seem-to-fix/ Share on other sites More sharing options...
mrjcfreak Posted July 31, 2007 Share Posted July 31, 2007 Maybe you want a space between ')' and 'VALUES' ? You also need to put validation on the $_POST['descl'] if this is a public page because otherwise folks can inject SQL commands into your database. Link to comment https://forums.phpfreaks.com/topic/62638-syntax-error-cant-seem-to-fix/#findComment-311765 Share on other sites More sharing options...
illuz1on Posted July 31, 2007 Author Share Posted July 31, 2007 Cool thanks I fixed it, but now im having trouble getting the desc1 to be inserted, the $name is going in but not $desc1 <form enctype="multipart/form-data" action="uploader.php" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="100000" /> Choose a file to upload: <input name="uploadedfile" type="file" /><br /> Description: </b><input type="text" name="desc1" size="40" maxlength="80" value="" /> <input type="submit" value="Upload File" /> </form> <?php /* Created on: 7/27/2007 */ ?> <html> <body> <?php include "db.php"; $target_path = "uploads/"; $name = basename( $_FILES['uploadedfile']['name']); $desc1 = $_POST["desc1"]; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; } $addoffer = MYSQL_QUERY("INSERT INTO uploaddb (id,name,desc1) VALUES ('NULL', '$name', '$desc1')") or die (mysql_error ()); echo "Upload Successful:<br>"; echo "Name: $name<br>"; echo "Description: $desc1<br>"; ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/62638-syntax-error-cant-seem-to-fix/#findComment-311768 Share on other sites More sharing options...
mrjcfreak Posted July 31, 2007 Share Posted July 31, 2007 Check you have valid data in $_POST by echoing it out to the browser. Also; try and stick to using only one thread Link to comment https://forums.phpfreaks.com/topic/62638-syntax-error-cant-seem-to-fix/#findComment-311776 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.