Tech Support > Computers & Technology > Regarding SQL and PHP and functions
Regarding SQL and PHP and functions
Posted by psion on February 21st, 2006


Hi,
Regarding SQL and PHP: I have a function called sqlquery, and Im passing an
argument to it, as in:

sqlquery($argument);

and want to use the $argument in an sql call, as in:

$query= "SELECT * FROM table";
$query2= "SELECT Names FROM table";
$result=odbc_exec($odbc, $argument);
while($row = odbc_fetch_array($result))
{...

The argument is either query or query2, but I get an error like:
Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT',
or 'UPDATE'., SQL state 37000 in SQLExecDirect

The code works if I replace argument with either $query or $query2 in the
$result value.

Why wouldn't this work?

Thanks,
Krzysztof


*** Free account sponsored by SecureIX.com ***
*** Encrypt your Internet usage with a free VPN account from http://www.SecureIX.com ***

Posted by why? on February 22nd, 2006



On Tue, 21 Feb 2006 15:28:27 -0600, psion wrote:

Try a PHP / SQL newsgroup, someone may know which version of SQL/PHP you
are having problems with, without asking.

So $argument is magically set to the value of $query or $query2 between
1 of the above lines and the line below, or did you remove some code.

www.google.com
Results 1 - 10 of about 20,100 English pages for
SQL state 37000 in SQLExecDirect
.. (0.30 seconds)

or change the query a bit,

Results 1 - 10 of about 1,700 English pages for
SQLstate 37000 in SQLExecDirect
.. (0.19 seconds)

You replace what with which?

Like
$result=odbc_exec($odbc, $argument);

changes to

$result=odbc_exec($odbc, "SELECT * FROM table");

<snip>

Me


Similar Posts