0

When I am removing the remarks the PHP returns

500 - Internal server error. There is a problem with the resource you are looking for, and it cannot be displayed.

$sql = 'SELECT * FROM lastName ORDER BY dt_server DESC';

$query = mysqli_query($conn,$sql);
//$count= mysqli_num_rows($query);

I put the // marks then the rest of the PHP codes are working, obviously the JSON data returns NULL I visited at https://www.w3schools.com/php/func_mysqli_num_rows.asp , same function sample used.

mysqli_num_rows($query); crash all. What I am doing wrong?

Vitali
  • 95
  • 1
  • 2
  • 6
  • 2
    Question: `lastName` is a very odd name for a table. Is that really the table name – RiggsFolly Nov 24 '20 at 14:54
  • 1
    To get errors out of PHP even in a LIVE environment add these 4 lines to the top of any `MYSQLI_` based script you want to debug `ini_set('display_errors', 1); ini_set('log_errors',1); error_reporting(E_ALL); mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);`. This will force any `MYSQLI_` errors to generate an Exception that you can see on the browser as well as normal PHP errors. – RiggsFolly Nov 24 '20 at 14:54
  • 1
    A 500 error is a generic error message and covers pretty much every single thing that can go wrong with a PHP script. Check your server error logs to find out the exact error message. – aynber Nov 24 '20 at 14:59
  • RiggsFolly - yes lastName is the record name – Vitali Nov 24 '20 at 16:25
  • @Vitali do you mean the name of the type of value you're trying to retrieve or the name of the table (collection) the values are stored in? The way you're using `lastName` it looks like a column value but is being used as a table name, which can obviously cause you issues. – Martin Nov 24 '20 at 16:57

0 Answers0