0

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;
    }
  ?>
7
  • What does 500 mean? Commented Sep 11, 2017 at 8:19
  • @greenapps 500 is a internal server error.... OP needs to view their logs. Commented Sep 11, 2017 at 8:20
  • I know what it means! Commented Sep 11, 2017 at 8:21
  • hmm i dunno how to fix right now @.@ Commented Sep 11, 2017 at 8:22
  • 1
    You made connection in db with mysqli and used mysql_fetch_array in your loop, may be this is the issue, sometime when disble error logs in server then php error getting 500 Commented Sep 11, 2017 at 8:22

2 Answers 2

1

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!

Sign up to request clarification or add additional context in comments.

Comments

0

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

2 Comments

This is not a solution for the problem. So no answer. You should have placed this as a comment.
No darling !! this is the solution!! Asking how to solve a 500 error is something like: "What is the meaning of life?"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.