I have an SQL query as follows:
$tagID = mysql_query("SELECT tagID FROM tags WHERE tagName = '$tag'");
echo $tagID;
I want $tagID to contain something like 3, or 5, or any integer. But when I echo it, the output is:
resource id #4
How can I make it a simple integer?
mysql_query()returns result resource, not the value in the query. You have to use fetch functions to get the actual data.If you want this code to be cleaner, check that
$resultis notfalse(query error) and$rowis notfalse(nothing found).