Inori Yuzuriha
Inori Yuzuriha

Reputation: 53

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;
    }
  ?>

Upvotes: 0

Views: 116

Answers (2)

Inori Yuzuriha
Inori Yuzuriha

Reputation: 53

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!

Upvotes: 1

EvgenyKolyakov
EvgenyKolyakov

Reputation: 3634

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 ;)

Upvotes: 0

Related Questions