简体   繁体   中英

PHP getting HTTP error 500

I want to retrieve data from the hosting but it returns me a HTTP error 500 when I tried to test my php.

This is my php code:

 /**
 * Getting all stock
 */
public function getstockdesc() {
    $con = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD,DB_DATABASE);
    $result = mysqli_query($con,"select * FROM stockdesc");
    return $result;
}

This is the for sync into android sqllite:

<?php

include_once 'db_functions.php';
$db = new DB_Functions();
$stockdesc = $db->getstockdesc();
$a = array();
$b = array();
if($stockdesc != false){
    while($row = mysql_fetch_array($stockdesc)){
        $b["stockdescId"] = $row["stockdescId"];
        $b["stockdesc"] = $row["stockdesc"];
        $b["itemCode"] = $row["itemCode"];
        array_push($a,$b);
    }
    echo json_encode($a);
         return $b;
}
    else{
         return false;
    }
  ?>

HOLY MOLY, I got the answers right now thx.

Recently using:

mysql_fetch_array()

Need to change to

mysqli_fetch_array()

My bad not paying attention!

Thanks Nipun Tyagi for finding my typo :D!

Use the following to see the actual error:

error_reporting(E_ALL);
ini_set('display_errors', 1);

Place it in the beginning of the code ;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM