0

I have this code:

<?php
mysql_connect(HIDDEN)
or die(mysql_error());
mysql_select_db("wow")
or die(mysql_error());
$data = ("SELECT Data FROM wa_guilds") or die(mysql_error());

print "<table border cellpadding=3>"; 
while($info = mysql_fetch_array( $data )) 
{ 
    Print "<tr>"; 
    Print "<th>Name:</th> <td>".$info['name'] . "</td> "; 
    Print "<th>Level:</th> <td>".$info['level'] . " </td></tr>"; 
} 
print "</table>";
?>

But I'm getting this error: Warning: mysql_fetch_array() expects parameter 1 to be resource, string given in blah blah

It's stored as a blob in a row called Data. I'm assuming I have to unserialize it, but I don't really know how.

I'm using this library if it helps any. https://sourceforge.net/p/wowarmoryapi/home/Home/ There's no documentation on how to get the data once it's been cached in the db.

4

1 回答 1

1

首先,标准回复:不要使用mysql_...函数。但请改用 mysql i _ ... 函数或 PDO。mysql_... 函数已弃用。

但接下来是你真正的答案:

改变

$data = ("SELECT Data FROM wa_guilds") or die(mysql_error());

进入

$data = mysql_query("SELECT Data FROM wa_guilds") or die(mysql_error());

因为在您当前的代码中,您将字符串放入 $data。但在代码中,我建议您使用 mysql_query() 运行该查询,这会将响应资源放入 $data。

于 2013-05-02T11:58:41.503 回答