I am trying to get a variable from a mySQL table into my PHP code. I am using a mysqli_query command. When I try to echo the result, it echos nothing, not even other echo statements.
I have ensured that the $conn is correct and working, and that the Sql query is correct by running it directly in PHPmyAdmin.
<?php
session_start();
include_once("includes/dbh.inc.php");
$UID = $_POST['userIdVariable'];
$UID = $_SESSION['u_uid'];
$balance = "SELECT account_balance FROM `users` WHERE user_uid = "$UID"";//this line probably works
$result = mysqli_query($conn, $balance);
echo "$result";
When I run this code it would output nothing. The right side of the $balance line is a good sql query according to PHPmyadmin. The $UID variable is read in correctly.
3
Answers
You need to use mysqli_fetch function to get result columns out of $result object.
Don’t use quotation in a field name or table name inside the query.
please check your database connectivity.there could be something missing like database name.
and print your $UID. may be there is no id getting.
to print data use print_r();
and try this: