I have spent the last week trying to figure this out.
At home: Win2k Pro. IIS Running. Access 2000.
Table: NAME text
PIC OLE Insert
PHP Code---------------------This works at home
<?php
$dbConn = odbc_connect("MYDB","","");
$b_pic = addslashes( fread( fopen($userPicFile, "r"), filesize($userPicFile)));
$insQry = "INSERT INTO MyTable (NAME,PIC) VALUES ('$name','$b_pic')";
odbc_exec($dbConn, $insQry);
?>
--------------------------------------
At work: WinNT 4.0. Running IIS. Access 2000.
Table: FIRST text
LAST text
PIC OLE Insert
PHP Code------------------------This returns an error
<?php
$dbConn = odbc_connect("MYDB","","");
$b_pic = addslashes( fread( fopen($userPicFile, "r"), filesize($userPicFile)));
$insQry = "INSERT INTO MyTable (FIRST,LAST,PIC) VALUES
('$firstName','$lastName','$b_pic')";
odbc_exec($dbConn, $insQry);
?>
------------------------------------------
The error (it is always this error when the binary data is part of the string):
Warning: SQL error: [Microsoft][ODBC Microsoft Access Driver]COUNT field incorrect ,
SQL state 07001 in SQLExecDirect in c:\inetpub\wwwroot\mailjob-upload.php on line 6
This is the same code with one extra field. At work if I make it the same as my
databse at home, it still generates this error.
The database is being accessed via a SystemDSN Microsoft Access Driver (*.mdb). No
user, no password.
I've done a search on the net for SQL 07001 and found NOTHING useful.
If I eliminate ALL the binary variables (like $b_pic) the query works. I.e. INSERT
INTO MyTable (FIRST,LAST) VALUES ('$firstName','$lastName');
I have a database that has 30 elements to insert, of which, 6 are binary fields
(files).
Thanks in advance.
Randall Barber
P.S. - I even used Access Qry builder and cut/paste the statement into the script. No
go. I can print the string (after substitution) and everything looks ok. All special
characters are escaped (i.e. \').