可能重复:
PHP Error: mysql_fetch_array() expects parameter 1 to be resource, boolean givenmysql_fetch_assoc()预计参数1是资源,布尔给定的错误
我编码的PHP和MySQL程序中添加和检索的Facebook应用程序ID和秘密在database.But我得到以下错误。我的链接是http://freegiveaway.info/new/manageApp.php .btw我的数据库连接成功。
Warning: mysql_fetch_assoc() expects parameter 1 to be resource,
boolean given in /home/free/public_html/new/manageApp.php
我的PHP包含follwing代码
$flag = $_POST['flag'];
$key = $_POST['key'];
$secret = $_POST['secret'];
$deleteApp=$_POST['deleteApp'];
$appN=$_POST['appN'];
$db = mysql_connect("localhost", "free_1", "password");
mysql_select_db("facefunv_chuck", $db);
$app = mysql_query("SELECT * FROM tsp ORDER BY n",$db);
while ($apps = mysql_fetch_assoc($app)){
我上线得到错误而($应用= mysql_fetch_assoc($ APP)){
而且我的SQL文件如下
/*!40101 SET @[email protected]@CHARACTER_SET_CLIENT */;
/*!40101 SET @[email protected]@CHARACTER_SET_RESULTS */;
/*!40101 SET @[email protected]@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `facefunv_chuck`
--
-- --------------------------------------------------------
--
-- Table structure for table `tsp`
--
CREATE TABLE IF NOT EXISTS `tsp` (
`n` int(11) NOT NULL AUTO_INCREMENT,
`id` text NOT NULL,
`secret` text NOT NULL,
`restricted` int(11) NOT NULL,
`banned` int(11) NOT NULL,
PRIMARY KEY (`n`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=40 ;
/*!40101 SET [email protected]_CHARACTER_SET_CLIENT */;
/*!40101 SET [email protected]_CHARACTER_SET_RESULTS */;
/*!40101 SET [email protected]_COLLATION_CONNECTION */;
如果'mysql_query'失败,它将返回布尔值'false'而不是资源。调用mysql_error()来了解哪里出了问题。 – Basti 2012-02-21 18:32:23
在这段时间之前添加一个'echo mysql_error()'并且发布它。它看起来像mysql_query函数没有返回正确的结果,可能是一些与查询/ db – 2012-02-21 18:33:55
我得到这个错误查询失败:没有选择数据库 – vishnu 2012-02-21 18:40:46