Username: Posted October 18, 2010 Share Posted October 18, 2010 Code I'm using if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 20000)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Successfully uploaded image!"; if (file_exists("img/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "img/" . $_FILES["file"]["name"]); echo "<a href='img/$filename'>Your File</a>; } } } else { echo "Invalid file"; } mysql_query("INSERT INTO $tbl (body, name, subject, ip, timestamp, img) VALUES ('$body', '$name', '$subject', '$ip', '$timestamp', '$imglink')"); mysql_query("INSERT INTO total (ip, subject, name, board) VALUES ('$ip','$subject','$name','$dfg')"); echo "<font color='red'><font size='15'><strong><center>Successfully posted to /$tbl/"; //print("<meta http-equiv='REFRESH' content='0;url=index.php?board=$tbl'>"); If I have the query on the top it runs, and the upload img doesn't && vice versa Link to comment https://forums.phpfreaks.com/topic/216142-cant-use-sql-quert-insert-into-and-upload-an-image-in-the-same-file/ Share on other sites More sharing options...
RussellReal Posted October 18, 2010 Share Posted October 18, 2010 uhh.. yes you can.. where does $tbl get set @? Link to comment https://forums.phpfreaks.com/topic/216142-cant-use-sql-quert-insert-into-and-upload-an-image-in-the-same-file/#findComment-1123300 Share on other sites More sharing options...
Username: Posted October 18, 2010 Author Share Posted October 18, 2010 uhh.. yes you can.. where does $tbl get set @? Above the script to upload the img. Should I move it below the script? edit> did it, same result Link to comment https://forums.phpfreaks.com/topic/216142-cant-use-sql-quert-insert-into-and-upload-an-image-in-the-same-file/#findComment-1123301 Share on other sites More sharing options...
Buddski Posted October 18, 2010 Share Posted October 18, 2010 I am going to assume that you do not have error_reporting turned on? error_reporting(E_ALL); ini_set('display_errors',1); I say this because you have missed a quote in your code. echo "<a href='img/$filename'>Your File</a>; Link to comment https://forums.phpfreaks.com/topic/216142-cant-use-sql-quert-insert-into-and-upload-an-image-in-the-same-file/#findComment-1123316 Share on other sites More sharing options...
Username: Posted October 18, 2010 Author Share Posted October 18, 2010 I am going to assume that you do not have error_reporting turned on? error_reporting(E_ALL); ini_set('display_errors',1); I say this because you have missed a quote in your code. echo "<a href='img/$filename'>Your File</a>; I fixed the missing quote. Sorry, typo. "Notice: Undefined variable: subject in /hosted/domains/t/e/testchan.org/public_html/create.php on line 80" Link to comment https://forums.phpfreaks.com/topic/216142-cant-use-sql-quert-insert-into-and-upload-an-image-in-the-same-file/#findComment-1123322 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.