Home » Php » PHP not returning values from SQL query

PHP not returning values from SQL query

Posted by: admin February 25, 2020 Leave a comment


In my database I have several columns and I want to get the price of an item using an id. The database is configured properly and I am having issues getting PHP to echo the value.

$temp = mysqli_query($conn, "SELECT * FROM 'MECH_MERCH' WHERE 'ID'='1';");
$final = mysqli_fetch_assoc($temp);

I am able to connect to the database just fine but PHP just shows nothing when I use:

<?php echo $final['PRICE'] ?>

I am referencing the variable later in the PHP file if that makes any difference. I am also being given the error:

mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in (file on drive) on line 25
How to&Answers: