From:             exaton at free dot fr
Operating system: WinXP
PHP version:      5CVS-2005-01-23 (dev)
PHP Bug Type:     MySQLi related
Bug description:  multi_query works exactly every other time

Description:
------------
Using PHP 5.0.4-dev WinXP snapshot from Jan 23 2005 10:14:07, running
Apache 2.0.52 and MySQL 4.1.9 .

I've seen other bugs possibly relating to this issue, e.g.
http://bugs.php.net/bug.php?id=29272 or
http://bugs.php.net/bug.php?id=28860 , but I think I have something more
precise to describe. The querying works half the time anyway, so it's not
an evident MySQL error.

I find that when I run a MySQLi multi_query, the first time the results
are perfectly correct, then on browser reload the multi-query fails with
an SQL error pertaining to the query concatenation. Reload again, fine.
Reload again, same error. Etc.

I'm doing this : (table 'faq' is simply an AUTO_INCREMENT 'indx' field,
then 'question' and 'answer' TEXT fields) :

$SQL = new mysqli(/*...connection information...*/);

$SQL -> multi_query('
  SELECT indx FROM faq;
  SELECT question, answer FROM faq
');

do {
  $res = $SQL -> store_result();
        
  if ($SQL -> errno == 0)
  {
    while ($arr = $res -> fetch_assoc())
      print_r($arr);
    $res -> free();
  }
  else
    echo $SQL -> error; // (*)
}
while ($SQL -> next_result());

$SQL -> close();

So, a first time, I get a bunch of arrays from the first resultset :
Array
(
    [indx] => 1
)
followed by the same number of arrays from the second resultset :
Array
(
    [question] => This is a question
    [answer] => This is an answer
)
And that is fine.

Then, browser reload, and I get no arrays at all but a _single_ error
instead, which I show with line (*) :

"You have an error in your SQL syntax; check the manual that corresponds
to your MySQL server version for the right syntax to use near '; SELECT
question, answer FROM faq' at line 1 "

Browser reload, back to my nice arrays. Browser reload again, error
message. It is _very_ rare that a same situation should occur twice in a
row instead of the alternation.

I've tried concatenating the queries onto a single line, even with no
space at all behind the semicolon. All the same.

So, despite my running MySQL 4.1.9, is this mysqli_multi_query() related,
or is something up with the database server ?

Thanks.


-- 
Edit bug report at http://bugs.php.net/?id=31668&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=31668&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=31668&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=31668&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=31668&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=31668&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=31668&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=31668&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=31668&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=31668&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=31668&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=31668&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=31668&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=31668&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=31668&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=31668&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=31668&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=31668&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=31668&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=31668&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=31668&r=mysqlcfg

Reply via email to