Warning: mysql_fetch_array() expects sqlparameter用法 1 to be resource, boolean given in这是什么错误?

This question already has an answer here:
28 answers
I have a line of PHP code for which I am getting an error.
while($row = mysql_fetch_array($result))
The line of code is the 60th line in my program,
Here's a link to the complete PHP code:
I am getting the following error message:
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/ranco690/public_html/highscores/index.php
86.7k19146158
marked as duplicate by , , , ,
This question has been asked before and already has an answer. If those answers do not fully address your question, please .
For a start you should be wrapping it in an 'if' make sure that results is a resource.
$result = mysql_query("SELECT * FROM Ratio ORDER BY Kills DESC LIMIT 20");
if ( $result ) {
while($row = mysql_fetch_array($result))
echo $row['playerName'];
echo "&br /&";
// there is a problem ...
echo mysql_error(); // display error so you can fix it
Your query $result = mysql_query("SELECT * FROM Ratio ORDER BY Kills DESC LIMIT 20"); must be incorrect. Check if you have tables Ration, column Kills.
You need to test $result before proceeding.
For example:
if ( $result )
while($row = mysql_fetch_array($result))
echo $row['playerName'];
echo "&br /&";
mysql_free_result($result);
die( mysql_error()) ;
As you could notice, I added mysql_free_result($result); which you do not have.
Also ranco690_kill database may be improperly spelled.
mysql_select_db("ranco690_kill", $con) || die( "ranco690_kill does not exist." ) ;
Blessings,
Not the answer you're looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabledmysql_connect() []: Access denied for user 'bayramoftp_db'@'localhost' (using password: YES) in /home/bayramoftp/public_html/admin/functions.php on line 4
mysql_select_db() expects parameter 2 to be resource, boolean given in /home/bayramoftp/public_html/admin/functions.php on line 5
mysql_query() []: Access denied for user 'bayramoftp'@'localhost' (using password: NO) in /home/bayramoftp/public_html/query.php on line 3
mysql_query() []: A link to the server could not be established in /home/bayramoftp/public_html/query.php on line 3
mysql_query() []: Access denied for user 'bayramoftp'@'localhost' (using password: NO) in /home/bayramoftp/public_html/query.php on line 5
mysql_query() []: A link to the server could not be established in /home/bayramoftp/public_html/query.php on line 5
mysql_query() []: Access denied for user 'bayramoftp'@'localhost' (using password: NO) in /home/bayramoftp/public_html/admin/functions.php on line 19
mysql_query() []: A link to the server could not be established in /home/bayramoftp/public_html/admin/functions.php on line 19
mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/bayramoftp/public_html/admin/functions.php on line 20
mysql_connect() []: Access denied for user 'bayramoftp_db'@'localhost' (using password: YES) in /home/bayramoftp/public_html/admin/functions.php on line 4
mysql_select_db() expects parameter 2 to be resource, boolean given in /home/bayramoftp/public_html/admin/functions.php on line 5
mysql_query() []: Access denied for user 'bayramoftp'@'localhost' (using password: NO) in /home/bayramoftp/public_html/title.php on line 35
mysql_query() []: A link to the server could not be established in /home/bayramoftp/public_html/title.php on line 35
mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/bayramoftp/public_html/title.php on line 36
mysql_query() []: Access denied for user 'bayramoftp'@'localhost' (using password: NO) in /home/bayramoftp/public_html/slider.html on line 6
mysql_query() []: A link to the server could not be established in /home/bayramoftp/public_html/slider.html on line 6
mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/bayramoftp/public_html/slider.html on line 7
mysql_query() []: Access denied for user 'bayramoftp'@'localhost' (using password: NO) in /home/bayramoftp/public_html/templates/tema2/main.html on line 75
mysql_query() []: A link to the server could not be established in /home/bayramoftp/public_html/templates/tema2/main.html on line 75
mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/bayramoftp/public_html/templates/tema2/main.html on line 76
?rünlerimiz
mysql_query() []: Access denied for user 'bayramoftp'@'localhost' (using password: NO) in /home/bayramoftp/public_html/templates/tema2/tabs/mainurun.html on line 31
mysql_query() []: A link to the server could not be established in /home/bayramoftp/public_html/templates/tema2/tabs/mainurun.html on line 31
mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/bayramoftp/public_html/templates/tema2/tabs/mainurun.html on line 32
Foto Galeri
mysql_query() []: Access denied for user 'bayramoftp'@'localhost' (using password: NO) in /home/bayramoftp/public_html/templates/tema2/slider_hor/index.html on line 29
mysql_query() []: A link to the server could not be established in /home/bayramoftp/public_html/templates/tema2/slider_hor/index.html on line 29
mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/bayramoftp/public_html/templates/tema2/slider_hor/index.html on line 30PHP代码中关于mysql_fetch_array()报错。_百度知道
PHP代码中关于mysql_fetch_array()报错。
错误如下:Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\shop\left.php on line 158源代码:&?php$sql=mysql_query(&select * from tb_links order by id desc limit 0,5&,$conn);$info=mysql_fetch_array($sql);
//第158行if($info==false){?&请提供解决方法。
这个问题不用理会了。你帮我看看这个问题:如果我注册模块里有几行这样的代码session_register(&username&);$username=$
session_register(&producelist&);$producelist=&&;session_register(&quatity&);$quatity=&&;错误:Fatal error: Call to undefined function session_register() in C:\wamp\www\shop\savereg.php on line 40网上说,比较新的PHP版本不使用session_register()函数了,然后我改用$_SESSION['username']=$$_SESSION['producelist']=&&;$_SESSION['quatity']=&&;(上面加了session_start();了),没有任何报错,但是数据就是传不进数据库。
我有更好的答案
没有数据或数据库错误?$info=@mysql_fetch_array($sql);
有,检查了用户名密码都没错.
你是要实现登录模块还是显示?多贴点代码
这是个session,跟数据库有什么关系,你可以看看打印下这个session试试
其他类似问题
为您推荐:
mysql的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁Possible Duplicate:
My PHP functions script was working fine last night, and now when I logged on to work on it some more today, I am getting
"Warning: mysql_result() expects parameter 1 to be resource, boolean given".
I have -no- idea why this isn't working. I've read the PHP manual online, and I've even seen examples where what I did is used and works. Can anyone please help me out with this? I've been fixing bug after bug (so many things stopped working when I logged on today) and I'm at my wits end here. If it helps, I'm using XAMPP on Windows 7 for my server.
function dbConnect() {
$dbserver="127.0.0.1";
$dbuser="Mike";
$dbpassword="mike";
$dbname="devsite";
$con = mysql_connect($dbserver, $dbuser, $dbpassword);
mysql_select_db($dbname, $con);
function getSiteTitle() {
$siteTitle = mysql_result(mysql_query("SELECT \`siteTitle\` FROM siteSettings"), 0);
return $siteT
function getSiteHeader(){
$siteHeader = mysql_result(mysql_query("SELECT \`siteHeader\` FROM siteSettings"), 0);
return $siteH
function getBodyContent() {
$bodyContent = mysql_result(mysql_query("SELECT \`bodyContent\` FROM siteSettings"), 0);
return $bodyC
9,53322854
marked as duplicate by ♦
This question has been asked before and already has an answer. If those answers do not fully address your question, please .
The problem is that mysql_query() is returning a boolean instead of a result resource. There are two reasons this can happen:
You performed query that returns success/fail instead of a result set (e.g. UPDATE)
Your query failed
In your case the query failed. The reason it failed is because you have escaped the back ticks in the PHP string where you did not need to.
Your lines look like this:
$siteTitle = mysql_result(mysql_query("SELECT \`siteTitle\` FROM siteSettings"), 0);
When they should simply be this:
$siteTitle = mysql_result(mysql_query("SELECT `siteTitle` FROM siteSettings"), 0);
Now, some side notes:
Don't write new code that uses the mysql_* functions. They are deprecated and will eventually be removed from PHP. Use
instead (I personally recommend PDO, YMMV)
Nesting database functions in this way is not a particularly good way to write your code. It is much better to check the errors explicitly after every function call.
For example:
$result = mysql_query("SELECT somecol FROM sometable");
if (!$result) {
// Handle error here
// Now process the result
You should quote either all identifiers, or none, in your queries (preferably all). Quoting only some makes it harder to read.
SELECT `siteTitle` FROM `siteSettings`
50.8k972115
Not the answer you're looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabled}

我要回帖

更多关于 expects parameter 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信