I'm trying to customize a Word Press blog a bit...
I need to select row(s) from a table where the field news_id (integer) is equal to the ID of the blog post.
I start with the following to test if my variable works.
$n == the_ID();
echo ($n);
and it does. I get the correct result.
then I try to select from the table...
$query2 = "SELECT * FROM nd_links WHERE news_id = $n";
but I get the following error...
Error in query: select * FROM nd_links WHERE news_id = . You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
when I put single quotes around $n, I don't get the error, but I also don't select the row(s) that I need.
when I test it by replacing $n with a post number, it calls the correct data.
I feel like the select call should work fine. any ideas why it isn't?
thanks in advance.