Multiple queries using mysqli

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

 



Hello,

I'm having a little bit trouble with mysqli (PHP 5.0.0 attached to MySQL 4.1.3-beta):

I have a table "test" and two tables "testdetails1" and "testdetails2". Now let's see (I left out error checking to simplify my problem):

01| $db = new mysqli($host,$user,$passwd,$dbname);
02|
03| $qry = $db->query ("select * from test where field1 = '$a' and field2 = '$b'");
04| while ($row = $qry->fetch_array()) {
05| echo $row["field3"] . ": ";
06|
07| $qry2 = $db->prepare("select info8 from testdetails1 where linkfield = ? and otherfield = 'c'");
08| $qry2->bind_params("s", $row["field3"]);
09| $qry2->execute();
10| $qry2->bind_result($info8);
11| while ($qry2->fetch()) echo $info8 . "-";
12| $qry2->close();
13| }
14| $qry->close();
15| $db->close();


That above example does work - but only because I used a "normal" query() in line 3 and a "prepared query" in line 7. If I had used both times the same time I would have got "2014: Commands out of sync; You can't run this command now".

The problem is that in my application I have the case that I have to do such a loop as given above with the addition that I have a third query which would be in the loop on line 11 ... I already tried, I can't get it to work properly - no matter what I try I keep getting error #2014.

Who knows how to solve this problem?

Thanks in advance for every hint,
  Helge.

--
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