MySQL Forums
Forum List  »  Newbie

Why am I getting and Empty Querry
Posted by: Irvin Amoraal
Date: April 27, 2015 08:20PM

I am having trouble with a simple mysql query. When I run the query from my website I get "mysqli_query(): Empty query...". , but when I run the exact same query (cut and paste) using phpAdmin i get "Showing rows 0 - 2 (3 total, Query took 0.0005 sec)" There is three rows of data in the table.

This is the php code from the website:
<b>Test</b><br/>

<?php
$servername = "localhost";
$username = "-------";
$password = "-------";
$dbname = "-------";

// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}else{
    echo "Connection established.";
}

$SQL = "SELECT `blogID`, `blogTitle`, `blogAuthor`, `blogImg`, `blogDate`, `blogText` FROM `blog`";
    //"SELECT blogID, blogDate, blogTitle, blogAuthor FROM blog ORDER BY blogID DESC";

if (mysqli_query($conn, $sql)) {
    echo "Table and records found.";
} else {
    echo "Error: " . $SQL . "<br>" . mysqli_error($conn);
}

mysqli_close($conn);
?>

This produced the following results:

Test
Connection established.
Warning: mysqli_query(): Empty query in /home/irvidjof/public_html/test.php on line 21
Error: SELECT blogID, blogTitle, blogAuthor, blogImg, blogDate, blogText FROM blog

I even tried "select * from blog" which also returns three rows in phpAdmin but zero rows from my webpage.

Any thoughts on what the issue is?
Thanks.
Irvin.

Options: ReplyQuote


Subject
Written By
Posted
Why am I getting and Empty Querry
April 27, 2015 08:20PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.