I am using a if statement in my PHP code to determine which query should be run. Today I expanded this if/elseif statement to include a third possibility. However, when I load the page I get the following error:
MySQL error occurred.
Query:
Error: (1065) Query was empty
I am able to echo the exact query to the page, as a debugging effort, and this exact same query can be copied and pasted in to mySQL Workbench and run perfectly. I searched on google for this error and some people said it may be due to an extra semicolon in my query, but I checked and that is no my issue.
Here is a snip of the actual code:
elseif ($_SESSION[complianceRole] == "Judge") {
$getTestimonial = "
SELECT
t.tID,
date_format(dateAdded, '%m-%d-%Y') as dateAdded,
t.views,
t.title,
t.keywords,
t.testimony,
length(testimony) - length(replace(testimony, ' ', ''))+1 as length,
u.uID,
u.firstName,
u.lastName,
u.email,
u.bouncing,
u.subscription,
datediff(now(), u.lastLogin) AS sinceLogin
FROM testimonies t, users u
WHERE
t.uID = u.uID
and classifyStatus is not null
and reviewStatus is not null
and classifyStatus <> reviewStatus
and busy is null
and bouncing = 'No'
and datediff(now(), u.lastLogin) < 1460
and u.uID not in (333, 717)
ORDER BY datediff(now(), u.lastLogin)
LIMIT 1
";
}
echo $_SESSION[complianceRole];
echo $getTestimonial;
$result = mysql_query($getTestimonial) or die("<p>Please email us the following information:</p> <p>Query: $getTestimonial </p> <p>Error: mysql_errno() " . mysql_error() );
Can someone help me understand why the error says my query is empty?
Thanks!