I am facing something strange. I will discuss it by very clear and simple example below.
1)I have function called Test() in page1.php (gives correct output) as follows:
$sql = "SELECT * FROM accounts WHERE account_id = 4";
$rs = mysql_query($sql);
while ($row = mysql_fetch_array($rs))
$mobile_number = $row;
2)I have stored procedure called GetAccounts() in page2.php that gets all accounts without IN and OUT parameters, I call it as follows:
$sql = "CALL GetAccounts()"; //LINE 1
///Here calling the function Test()works fine!!!
$result = mysql_query($sql); //LINE 2
////Here if I call the function Test(), it gives mysql error as below.
while($row = mysql_fetch_array($result)) //LINE 3
Now the problem, when I call the function Test() between LINE 1 and LINE 2, it works fine, please see the comment I indicated above. Also it works fine before LINE 1.
But, when calling the function Test() between LINE 2 and LINE 3, it gives the mysql error: Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in.... Also the error appear when I call it after LINE 3.
I am really wondering!! It happens only when using stored procedure, but when using normal query(without stored procedure) no such problem happens!!
Is it bug in PHP? How can I solve it?
Please advise and many thanks.