I am getting exception while calling a stored procedure in a for loop.here is my code
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname);
$total = 0;
$error = 0;
$trimmed = explode("\n",file_get_contents($fileName));
for ($i = 0; $i < 2; $i++) {
$qry_ins = "call sampleProcedureTest();";
try {
mysql_query($qry_ins) or throw_ex(mysql_error());
$total++;
} catch(Exception $e) {
echo $e;
echo $qry_ins;
echo "</br></br>";
$error++;
}
}
I have searched but didn't find any good reason and solution
NOTE: When I remove the loop then it works fine.But My need is to call in a loop
Guide me please regarding this
EDIT # 1: Here is the procedure
BEGIN
DECLARE uid VARCHAR(10) DEFAULT "0000";
SELECT SUBSTRING(MD5(RAND()) FROM 1 FOR 4) AS passwordStrin into uid FROM NO WHERE uid not in (Select ID from UIDLIST WHERE ID=uid);
INSERT IGNORE INTO UIDLIST values(uid);
select REPLACE(MSG,'URL',CONCAT('http://abc.org/?uid=',uid)) as message,SOURCE as sender,MODE as mode,uid as uniqueid from testDB _MESSAGE;
select REPLACE(MSG,'URL',CONCAT('http://abc.org/?uid=',uid)) as message,SOURCE as sender,MODE as mode,uid as uniqueid from testDB_MESSAGE;
END