0

I want to display all products from my table product in my database. I have around 450 products in it . But using a simple select statement is not working and not returning any data unless in the select query I set a limit of 22 .

I did a little research and here are some points I'd like to make clear:

1.Most online sites suggest that a memory limit is causing it and to change the same in php.ini

And I tried it and it still didnt help

2.The connection is not an error as it works when a limit is set.

3.The console and dev tools in the browser do not show any errors.

4.I did a fair amount of research and everywhere it said to increase memory like the first point but it didnt work .

5.I am using xampp to run.

6.The select statement works perfectly when i ran it on phpMyAdmin, it displayed all 450 products there.

7.I have set all php error showers to on in php.ini and it still no error

8.error.logs is also not showing any errors

this is my php code:

<?php
include "dbconfig1.php";
$data = array();

$q = mysqli_query($connection,"select * from product   limit 22");

while ($row = mysqli_fetch_assoc($q)){
    $data[] = $row;
}
echo json_encode($data);
echo mysqli_error($connection);
Harsh Sharma
  • 1
  • 1
  • 3
  • There is no error in your code. I don't know what kind of help you are expecting from us. – Dharman Jul 18 '22 at 19:06
  • Did you put a breakpoint in the code and tried to investigate in the debugger what's happening? – Dharman Jul 18 '22 at 19:07
  • It displays data only when i set a limit of 22 or less if a set it more or not at all, it retruns nothing i.e it displays no data . and i want t display all the data in the table but unable to – Harsh Sharma Jul 18 '22 at 19:09
  • Does it at least display empty brackets? Does any output show in the browser? How do you test the output? – Dharman Jul 18 '22 at 19:10
  • it doesnt display empty brackects . – Harsh Sharma Jul 18 '22 at 19:13
  • [{"product_id":"254","product_name":"PLOT 4 - PACK OF 6","product_brand":"RATNA","product_price":"714.00","product_image":"PLOT4.jpg","product_category":"Return Gift","product_sub_category":"UNISEX","product_quantity":"4" – Harsh Sharma Jul 18 '22 at 19:13
  • it displays this if a limit is set to 22 but if not then its just blank , nothing at all – Harsh Sharma Jul 18 '22 at 19:14
  • If you get a blank page then you should look for an error. There must be an error somewhere. Did you check PHP error_log? – Dharman Jul 18 '22 at 19:17
  • i checked error.log and there are no errors there – Harsh Sharma Jul 18 '22 at 19:22

1 Answers1

-1

Once you make changes in the php.ini file, you should restart apache service on XAMPP control panel.