An SQL query always returns the result of an SQL resource, possibly an unreadable object containing the results of the query. Because of how databases are stored, the way users can manipulate data, as well as the amount of data, is easier to store as an identifier than as an object.
To get the data you need, you must first convert them to an array:
$result = mysql_query("SELECT tagID FROM tags WHERE tagName = '$tag'");
$row = mysql_fetch_assoc($result);
echo $row["tagID"];
(where $ row [column] is the column from which you want to extract data (
Or object:
$result = mysql_query("SELECT tagID FROM tags WHERE tagName = '$tag'");
$object = mysql_fetch_object($result);
echo $object->tagID;
(where the column $ object-> is the column from which you want to extract data)
Hope this helps.
source
share