警告:mysql_fetch_row()期望参数1为资源 [英] Warning: mysql_fetch_row() expects parameter 1 to be resource
问题描述
Possible Duplicate:
mysql_fetch_array() expects parameter 1 to be resource, boolean given in select
运行此脚本时,我收到以下消息:
I am receiving the below message when I run this script:
警告:mysql_fetch_row()期望参数1为资源,在第12行的/var/www/html/toolkit/routing.php中给出的字符串
Warning: mysql_fetch_row() expects parameter 1 to be resource, string given in /var/www/html/toolkit/routing.php on line 12
我已经在mysql控制台中运行了查询,并打印了正确的行.不知道为什么我无法在php中显示它?
I have ran the query in the mysql console and it prints the correct row. Not sure why I cant get it to show up in php?
routing.php页面:
routing.php page:
<?php
error_reporting(E_ALL);
////error_reporting(0);
ini_set('display_errors', 'On');
include("db/sbc_config.php");
include("db/mysql.class.php");
$db = new MySQL(true, DB_DATABASE_ROUTING, DB_SERVER, DB_USER , DB_PASS);
if ($db->Error()) $db->Kill();
$searchroute = "SELECT * FROM destination_route as d WHERE d.destPrefix='2146811'";
$result = mysql_fetch_row($searchroute);
echo $result;
?>
sbc_config.php:
sbc_config.php:
<?php
//database server
define('DB_SERVER', "10.10.1.146");
//database login name"
define('DB_USER', "user");
//database login password
define('DB_PASS', "pasword");
//database names
define('DB_DATABASE_ROUTING', "routing");
//smart to define your table names also
define('TABLE_DESTINATION_ROUTE', "destination_route");
?>
推荐答案
mysql_fetch_row
提取一个游标并返回该游标中的下一行.您正在尝试给它一个字符串.您错过了一步.
mysql_fetch_row
takes a cursor and returns the next row in that cursor. You're trying to give it a string. You're missing a step.
您必须先执行该查询:
$cursor = mysql_query($searchroute); // for example
$result = mysql_fetch_row($cursor);
这篇关于警告:mysql_fetch_row()期望参数1为资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!