0
我想更新舊腳本,如下所示。從MySQL到mysqli更新代碼
mysql sql statement that works is:
$result = mysql_query("SELECT products.products_id AS id,
products_description.products_name AS name,
products.products_quantity AS quantity, products.products_weight AS weight,
products.products_price AS price
FROM products, products_description WHERE
products.products_id=products_description.products_id;") or
die(mysql_error());
while($row = mysql_fetch_array($result)) {
的mysqli的聲明,我不能去工作是:
$sql = "SELECT products_id, products_description.products_name,
products_quantity, products_weight, products_price FROM products INNER JOIN
products_description on products.products_id =
products_description.products_id";
$result = mysqli_query($con, $sql);
if(mysqli_num_rows($result)>0){
while(null !== ($row = mysqli_fetch_assoc($result))) {
我收到的錯誤是:
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean
given in index.php on line 19
和mysqli聲明工作,但不是當我添加products_description.products_name
來查詢。
工作就像一個夢想satish!學習如何在PDO中做到這一點 – craig
很高興知道。也許這也將是有益的:https://code.tutsplus.com/tutorials/pdo-vs-mysqli-which-should-you-use--net-24059 –