RE: MySQL query executes outside of PHP, but not in PHP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



<snip>

>  error_log("Hey, the SQL is: $sql");
>
>  Then look in your php error log (you do have error logging enabled,
>  right?)
[McGovern, Dave] Enabled, yes.  Usefully enabled, no (correcting this
helped a lot).
>
>  If that SQL in the error log is fine, then your problem is
>  $client2->multi_query($sql) -- what does THAT return?  What SHOULD it
>  return?  What are you expecting it to return?  Does it return what
you
>  thought it did?
[McGovern, Dave] It was returning ''.  I was expecting 1.
>
>  When you do "if ($var)" it can sometimes have unexpected results.  If
$var
>  is an empty string, it's still true, and executes.  I don't know that
>  multi_query SHOULD return, or how to determine if it throws an error,
but
>  that's one place to start.
>
>  Next, if multi_query worked, then this line is suspect:
>
>    if ($result = $client2->use_result()) {
>
>  This will always result in TRUE, as the assignment will always
succeed.
>  Change it to:
>
>    if (($result = $client2->use_result())) {
>
>  (added parenthesis)
> What DB library are you using?
[McGovern, Dave] php_mysqli.dll

>-----------------------------------------------------------------------
----
>Peter Beckman                                                  Internet
Guy
>beckman@xxxxxxxxxxx
http://www.angryox.com/
>-----------------------------------------------------------------------
----

[McGovern, Dave] 
Hi, Peter -
Thanks for the suggestions.  I did have error logging enabled, but I
wasn't writing any of my own errors to the log, so it wasn't doing me
much good. Once I started doing this, I was able to trace the source of
the error to the fact that this particular SQL script was meant to be
aimed at a different schema. The reason it worked in MySQL Query Browser
was that the required schema was already selected in the Query Browser
(ouch).

Sorry to have wasted the list's time with what turned out to be a silly
human error.
Dave


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux