The function below will be used to input a Facebook access token into a database. The user id will already have an associated record so the “acc_tok” field just needs to be updated.
For some reason even though the $_result value holds “1” and the function echoes out “Successful!”, a warning is appearing that says:
“Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given”. Does anyone know why it appears that the query was successful but is only returning a boolean and not something the mysql_fetch_array can work with? Thanks for reading
function setUserAccessToken($_uid, $_accTok){
$sql = "UPDATE `user_core` SET `acc_tok`=$_accTok WHERE `id` = $_uid";
$_result = mysql_query($sql) or die($sql."<br/><br/>".mysql_error());
echo $_result;
if ($_result) {
echo ("Successful!");
$_resultArray = mysql_fetch_array($_result);
print_r($_resultArray);
} else {
echo ("Failed!");
}
}
You’re doing an
UPDATEquery, there are no rows to fetch from the result, hence a boolean value frommysql_query()and not a resource.From the manual: