MySQL Warning: Invalid Argument for mysql_fetch_assoc
Issue:
When attempting to retrieve data from a MySQL database, the following error message is encountered:
mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource
Explanation:
The mysql_fetch_assoc() function is designed to extract a row from a MySQL result set. As its name suggests, it expects a valid result resource as an argument, which represents the link to the database search results. However, in this case, the argument passed to the function is not a valid result resource, triggering the error.
Solution:
To resolve this issue, ensure that the variable assigned to the result of your MySQL query is a valid result resource. Here's a breakdown of the code you provided:
$musicfiles = getmusicfiles($records['m_id']);
This line executes the getmusicfiles() function and assigns the result to the $musicfiles variable. Now, let's examine the getmusicfiles() function:
function getmusicfiles($m_id) {
$music = "select * from music WHERE itemid=".$s_id;
$result = getQuery($music, $l);
return $result;
}
This function executes a MySQL query, assigns the result to the $result variable, and then returns it. It's important to note that getQuery() is not shown in the provided code, so it's not possible to analyze if it's properly retrieving the result resource.
Once you have confirmed that getQuery() is returning a valid result resource, you should be able to successfully call mysql_fetch_assoc($musicfiles). Remember, the function expects a valid result resource as its argument, so ensure that it's available before calling mysql_fetch_assoc().
Отказ от ответственности: Все предоставленные ресурсы частично взяты из Интернета. В случае нарушения ваших авторских прав или других прав и интересов, пожалуйста, объясните подробные причины и предоставьте доказательства авторских прав или прав и интересов, а затем отправьте их по электронной почте: [email protected]. Мы сделаем это за вас как можно скорее.
Copyright© 2022 湘ICP备2022001581号-3