I get it when trying to store binary files i mysql db. I've searched for what there type of error codes means, but I can't find anything. Dows anyone know?

    Hi,

    It may help if you post some code which causes the error.

    The resource id is -as far as I understand- a mysql reference to objects, such as a query output.

    J.

      ok, more info:

      I know files upload work correctly. I get correct values in $_FILES['objectname']['name'] and so on. I get the file to the webservers temp directory, then I'm stuck with this error. Here's the code:

      $filehandle = fopen($_POST['pic1']['tmp_name'], "r");
      $data = fread($filehandle, $_FILES['pic1']['size']);
      fclose($filehandle);
      
      mysql_query("INSERT INTO v2_products (pic1) VALUES ('$data')") or die (mysql_error());
      

        What does your mysql_connect() statement look like?

          mysql_connect('site', 'username', 'password');

          Is there another way...?

            I don't unserstand these Resource messeges at all, what are they? Some kind of error code from mysql? Doesn't seem to be to well documented...

              I've solved the resource problem, but ran into another one:

              The picture to be stored in the db appear in the variable $data as a long string of crap. I recieve a mysql syntax error message. Code:

              $data = addslashes($data);
              mysql_query("INSERT INTO v2_products (pic1) VALUES ('$data'") or die (mysql_error());

              Error message: Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

                You have a double-quote too many in the values ()

                J.

                  I don't see any error in my query. It works with other variables, e. g. one with a simple name stored in it. My guess is that sins the $data variable contains an image certains signs like quotes appear every here and there and mess the SQL syntax up. This issue is discussed at php.net and there seems to be several ways to fix it, but everyone has their drawbacks. Funktions like addslashes(), mysql_escape_string() and several replacement funktions are discussed but none of them works for me. I can't replace every quote with something else sins it would destroy the image.

                  As you might have guessed this is the first time I do scripts handling file upload, so consider me a newbee...

                    Oops sorry, I see it now. However it's an error that seaked in when I pasted the code in the reply window, the double quote is in the correct position in my code. (The missing ")" is also there.)

                      Write a Reply...