I am facing one more problem with MySQLi. I have a table stock under 'test' database. It has fields id (not null auto incremetal), name (varchar 30) and expirydate. Select query shows following result..
mysql> select * from stock;
+----+---------------------+----------+------------+
| id | name | stockqty | expirydate |
+----+---------------------+----------+------------+
| 1 | Ampoxin 2500 mg Tab | 100 | 2007-07-31 |
| 2 | Ampoxin 500 mg Tab | 250 | 2008-09-30 |
| 3 | Frez DS | 2500 | 2009-09-30 |
| 4 | Vizlac DP | 3500 | 2005-08-31 |
| 5 | Cough'Z Killer | 50 | 2008-01-31 |
+----+---------------------+----------+------------+
5 rows in set (0.06 sec)
Now When I run following script, I get proper results ..
<?php
$mysqli=new mysqli('localhost','root','MyPassWord','test');
if (mysqli_connect_errno()){
printf("Connection Failed: %s \n </br>",mysqli_connect_error());
exit();
}
$SqlStr="select * from stock where stockqty<=300 order by name";
$result=$mysqli -> query($SqlStr);
if ($result){
print("Meidicines having stock <=300 are : \n</br></br>");
while($row=$result->fetch_assoc()){
echo "Product Desc : <b>" . $row['name'] . "</b> Stock in Hand :<b> " . $row['stockqty'] . " </b>\n </br>";
}
$result->close();
}
?>
But When I am using following script, system is getting hanged and mysqld-nt.exe is taking 99% of CPU process. What could be the problem?
<?php
$mysqli=new mysqli('localhost','root','mypassword','test');
if (mysqli_connect_errno()){
printf("Connection Failed: %s \n </br>",mysqli_connect_error());
exit();
}
if ($stmt=$mysqli -> prepare("insert into stock values ( ?, ?, ?)")){
$stmt->bind_param('sis',$p_name, $p_qty, $p_edate);
$p_name='Valcox 20 Mg Tab';
$p_qty=350;
$p_edate='2007/11/30';
$stmt->execute();
echo "Rows affected : " . $stmt -> affected_rows . "\n </br>";
$stmt->close();
}
$mysqli -> close();
?>
Please Help !!!!!!!!