Skip to content

Instantly share code, notes, and snippets.

@sivaprabug
Created August 15, 2013 00:56
Show Gist options
  • Save sivaprabug/6237328 to your computer and use it in GitHub Desktop.
Save sivaprabug/6237328 to your computer and use it in GitHub Desktop.
mysqli returns empty result - how to display ?
<?php
$q2 = "SELECT FIELD FROM TABLENAME WHERE ID = 1;";
$con = new mysqli($server, $user, $pass);
if (mysqli_connect_errno())
{
$error = mysqli_connect_error();
exit();
}
else
{
$res = mysqli_query($con, $q2);
$row_cnt = mysqli_num_rows($res);
if ($row_cnt == 0)
{
PRINT "THERE WAS NO RESULT: ";
}
else
{
if ($res)
{
while($row = mysqli_fetch_assoc($res))
{
PRINT "THERE WAS A RESULT HERE: ";
}
}
else
{
$error = mysqli_error();
exit();
}
mysqli_free_result($res);
}
};
mysqli_close($con);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment