php-windows Digest 3 Mar 2001 15:49:14 -0000 Issue 472

Topics (messages 5801 through 5805):

Microsoft Access prepared statement with parameters problem
        5801 by: Chris Poirier
        5805 by: Gonzalo Vera

Re: Cash Offer!!
        5802 by: hollyjacobsemail77.excelonline.com
        5803 by: jannetfreebish67.juno.com

$PHP_SELF not producing the goods.
        5804 by: Jess Perez

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


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


Hi there,

I'm attempting to execute prepared statements with parameters against an
Access 97 database, and am having some trouble.  I'm sure I'm missing
something really obvious, but I just can't see it, and I'm hoping someone
out there can help.

In the following code, assume that $connection holds a valid and otherwise
working connection to a database in which there exists a table named
System.  Column A is a text column.

$statement = odbc_prepare( $connection, "select * from System where A=?" );
if( odbc_execute( $statement, array( "MachineID" )))
{
  odbc_fetch_row( $statement );
  print odbc_result( $statement, "A" ) . "<br/>";
}


I have tried many variations on this code, and if there are any ? marks in
the query, regardless what I pass as the second parameter to
odbc_execute(), odbc_execute() always dies with the following message:

Warning:  SQL error: [Microsoft][ODBC Microsoft Access Driver]COUNT field
incorrect , SQL state 07001 in SQLExecute in ...


Can anyone tell me what I'm doing wrong?

Thanks, Chris.






Some possibilities:

> $statement = odbc_prepare( $connection, "select * from System where A=?" );

Probably you would be better off using single quotes in the condition,
since you are tryng to match strings, like:

$statement=odbc_prepare($connection,"select * from System where A='?'");
                                                             here-^ ^

Also, I'm not sure that wildcards are allowed for string matching
unless you use "like":

$statement = odbc_prepare( $connection, "select * from System where A
like '?'" );

Inside access, wildcards are * and ?, but when invoked through ODBC, *
turns to %, and I think ? turns to _, but I'm not sure. Try the manual
on that.

And last, to eliminate possibilities, enclose any table or field names
that might by far chance be a reserved word, in sqare brackets. I
don't think that "A" is a reserved word, and am not sure about
"System", but just to make sure... and end your statement with a
semicolon. The final result would be:

$statement = odbc_prepare( $connection, "select * from [System] where
[A] like '?';" );

That, for syntax. But going further, "?" (or "_") is the single
character matching wildcard. Why would your comparison use only a
single character? If "A" is a single char field, use "like '%'", it
would be safer and probably faster. But, there might be the chance
that you're NOT trying to do a wildcard comparison, but are trying to
search for the literal "?". Then you would use your actual syntax, but
adding a backslash to escape the special char: "[A]='\?'".

Some wild shots... hope it works.
Gonzalo.







hi there,
please take a moment to check out the newest cash offer.
cash is waiting for you!  Click Below 
Or copy the link and paste it in your browser

http://www.geocities.com/omega777799/





Hey...Janet Here... We Haven't Talked In So Long!!  
How Have You Been?  Thought I would Forward you this email!

I usually delete these but I opened this one, like what I saw, 
and thought you would like to see this.

http://www.geocities.com/rush009900/

IF THE LINK IS NOT HIGHLIGHTED OR YOU CANNOT CLICK ON IT.
COPY AND PASTE IT IN YOUR BROWSER.












Hi,
I am using
PHP4.0.4pl1 in cgi mode
Apache 1.3.14
WIN2000


I point my browser at www.domain.com/phpinfo.php  and the $PHP_SELF variable
to contains "/php/php.exe/phpinfo.php" instead of just "phpinfo.php".

Anyone know what is causing this and how to correct it?  The manual says it
is supposed to contain only "phpinfo.php"


--
Regards
Jess Perez





Reply via email to