0

This is question, however:

In a PHP file, I am running an ezSql command (http://justinvincent.com/ezsql):

$_result = $db->get_var("CALL spcheck ('".$_var1."')");

then I have a if ($_result..

within that if, I have:

$_logInsert = $db->query("CALL splog1 ('".$_referrer."','".$_userAgent."','".$_ipAddress."','".$_countryCode."')");

However, I get the error:

"Warning: Commands out of sync; you can't run this command now" when I try the second db call (first one runs fine)

Is it not possible to have a globally defined $db and use it throughout the page multiple times? Do I need to somehow "cancel the get_var after its executed so I can reuse it?

Mercy
  • 1,862
  • 9
  • 39
  • 75
dpluscc
  • 590
  • 1
  • 8
  • 18
  • You can reuse the `$db` variable multiple times. – Luke Stevenson Jan 06 '12 at 08:43
  • Thats what I was hoping.. Any idea why I'd be getting the above error? – dpluscc Jan 06 '12 at 16:57
  • It seems to be using the "CALL " in the get_var, etc. When I change that to straight SQL statements, it runs fine. No way to have a middle tier with the ezSQL libraries? – dpluscc Jan 06 '12 at 17:46
  • I have not used `CALL ... (...)` myself, inside or outside of the ezSQL library, so I have no idea why it would be failing. Maybe this would be better directed to Justin Vincent, the creator of the library - http://justinvincent.com/ezsql. As it's his baby, he'll have a better idea of any limitations/bugs. – Luke Stevenson Jan 08 '12 at 22:01

1 Answers1

2

After a quick Google and a peak under the hood of ezSQL.

In ez_sql_mysql.php (or whatever name you may have given the file) Line 81 (as at v2.11)

Old code:

else if ( ! $this->dbh = @mysql_connect($dbhost,$dbuser,$dbpassword,true) )

New code:

else if ( ! $this->dbh = @mysql_connect($dbhost,$dbuser,$dbpassword,true,131074) )

Adapted from Drupal Bugs - "Patch needed to execute MySQL stored procedures"

Luke Stevenson
  • 10,357
  • 2
  • 26
  • 41