Jump to content

Php and MS Access Help Needed!


logitechcam

Recommended Posts

Hi there

 

I am trying to save the picture names to a access 2000 database. but i got this error as following

 

Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression '2006.JPG'., SQL state 37000 in SQLExecDirect in C:\Inetpub\wwwroot\FanWeb\ADO\Fan\upload_file.php on line 38

 

 

Can anyone give me a help?

 

 

Here is the code.

 

 

<?php

 

if (($_FILES["file"]["type"] == "image/gif")

|| ($_FILES["file"]["type"] == "image/pjpeg")

|| ($_FILES["file"]["type"] == "image/jpeg")

|| ($_FILES["file"]["type"] == "image/png")

&& ($_FILES["file"]["size"] < 20000))

  {

  if ($_FILES["file"]["error"] > 0)

    {

      echo "Return Code: " . $_FILES["file"]["error"] . "

";

    }

  else

    {

      echo "Upload: " . $_FILES["file"]["name"] . "

";

        echo "Type: " . $_FILES["file"]["type"] . "

";

      echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb

";

      echo "Temp file: " . $_FILES["file"]["tmp_name"] . "

";   

     

      if (file_exists("Image/pictures/" . $_FILES["file"]["name"]))

        {

            echo $_FILES["file"]["name"] . " already exists. ";

        }

      else

        {

            move_uploaded_file($_FILES["file"]["tmp_name"],

            "Image/pictures/". $_FILES["file"]["name"]);

            echo "Stored in: " . "Image/pictures/" . $_FILES["file"]["name"];

       

        $conn=odbc_connect('image','','');

        if (!$conn)

        {

            exit("Connection Failed: " . $conn);

        }

        $fname=$_FILES["file"]["name"];

        $sql="INSERT INTO url(fileName) values($fname)";

        $rs=odbc_exec($conn,$sql);

 

       

 

 

 

      }

    }

  }

else

  {

    echo " <a href= uploadPic.html> Invalid file ,click to upload again[/url]";

 

  }

 

?>

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/37776-php-and-ms-access-help-needed/
Share on other sites

i think that

 

       $sql="INSERT INTO url(fileName) values($fname)";

 

has to be

 

       $sql="INSERT INTO url(fileName) values('$fname')";

 

 

 

 

tried that, doesnot work. But i got new error for it.

 

Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query., SQL state S1000 in SQLExecDirect in C:\Inetpub\wwwroot\FanWeb\ADO\Fan\upload_file.php on line 38

 

80004005--Operation must use an updateable query

This error occurs when an event is updating a recordset or inserting data in a recordset.

 

Here are possible causes and solutions:

 

The permissions set on the folder containing the database are too restrictive. IUSR privileges must be set to read/write. (See Troubleshooting permissions problems.)

The permissions on the database file itself does not have full read/write privileges in effect. (See Troubleshooting permissions problems.)

The database might be located outside the Inetpub/wwwroot directory. Though you can view and search the data, you might not be able to update it unless the database is located in the wwwroot directory.

The recordset is based on a non-updateable query. Joins are good examples of non-updateable queries within a database. Restructure your queries so they are updateable.

For more information on this error, see "PRB: ASP 'Error The Query Is Not Updateable' When You Update Table Record," in the Microsoft Knowledge Base at http://support.microsoft.com/default.aspx?scid=kb;en-us;Q174640.

 

--------------------------------------------------------------------------------

 

permission problems link too much to paste

http://livedocs.macromedia.com/dreamweaver/8/using/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=31_trou7.htm

 

 

 

 

if none of that works I don't know about  access 2000 db but if its similar to SQL Server

then the query could be missing not only quotes but also  " ; " symbol

INSERT INTO url(fileName) values('$fname');   

 

you should just test this query try to get it to work off your access 2000 query manager tool.

It is not the permissions problem. i donot know how to fix it. sad!!!

 

80004005--Operation must use an updateable query

This error occurs when an event is updating a recordset or inserting data in a recordset.

 

Here are possible causes and solutions:

 

The permissions set on the folder containing the database are too restrictive. IUSR privileges must be set to read/write. (See Troubleshooting permissions problems.)

The permissions on the database file itself does not have full read/write privileges in effect. (See Troubleshooting permissions problems.)

The database might be located outside the Inetpub/wwwroot directory. Though you can view and search the data, you might not be able to update it unless the database is located in the wwwroot directory.

The recordset is based on a non-updateable query. Joins are good examples of non-updateable queries within a database. Restructure your queries so they are updateable.

For more information on this error, see "PRB: ASP 'Error The Query Is Not Updateable' When You Update Table Record," in the Microsoft Knowledge Base at http://support.microsoft.com/default.aspx?scid=kb;en-us;Q174640.

 

--------------------------------------------------------------------------------

 

permission problems link too much to paste

http://livedocs.macromedia.com/dreamweaver/8/using/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=31_trou7.htm

 

 

 

 

if none of that works I don't know about  access 2000 db but if its similar to SQL Server

then the query could be missing not only quotes but also  " ; " symbol

INSERT INTO url(fileName) values('$fname');     

 

you should just test this query try to get it to work off your access 2000 query manager tool.

run a query man the query from your own script

 

INSERT INTO url(fileName) values($fname)

 

 

run it in access database program and keep trying to fiddle with it in your database program until it works.. than just see whats the problem with it.. atleast try to make some query work even if it's not fileName query... try ANY query just make it work.. and post maybe some hints will come from it..

 

than again fileName could be reserved name.. you could try to put  []'s around it.. But than again just try to make a query work in your database tool..

Dude

 

the first answer from you is right, the forder was having the permission, but not the .mdb file. i was not checking it. thank you , man. u rock!!!!

 

 

run a query man the query from your own script

 

INSERT INTO url(fileName) values($fname)

 

 

run it in access database program and keep trying to fiddle with it in your database program until it works.. than just see whats the problem with it.. atleast try to make some query work even if it's not fileName query... try ANY query just make it work.. and post maybe some hints will come from it..

 

than again fileName could be reserved name.. you could try to put  []'s around it.. But than again just try to make a query work in your database tool..

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.