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.