How to fix Warning: mysql_fetch_assoc()?

$query_res = "select `license_key` from `oc_key` where `key`='local_key'";

$query_row = mysql_fetch_assoc($query_res);

$lkey = $query_row['license_key'];


Warning: mysql_fetch_assoc() expects parameter 1 to be resource, string given in
Tell me what's wrong
July 8th 19 at 15:36
1 answer
July 8th 19 at 15:38
Afraid to be a strange man, but I see no query to the database!
Try this:
$query_res = "select `license_key` from `oc_key` where `key`='local_key'";
$query = mysql_query($query_res);
$query_row = mysql_fetch_assoc($query);
$lkey = $query_row['license_key'];
gives Warning: mysql_query() expects parameter 1 to be string, object given in - Uriel.Schneid commented on July 8th 19 at 15:41
And if you combine the first two lines in :
$query = mysql_query("select `license_key` from `oc_key` where `key`='local_key'") or die ("Error:" .mysql_error()); - Rosella.Heathco commented on July 8th 19 at 15:44

Find more questions by tags PHP