Jump to content

Can't use SQL Quert INSERT INTO and upload an image in the same file


Username:

Recommended Posts

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

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 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"

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.