2011-06-16 34 views
-1

到现在为止,我在我的专用服务器上制作了所有的项目,这真的很痛苦 - 现在我决定用xampp移动本地,但似乎像mysql_fetch_array()在我的专用服务器上工作方式不同,当我尝试看到我德迪完美的作品内容,它抛出这些错误:移动到xampp后mysql_fetch_array()错误?

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\includes\variables.php on line 7 
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\template\win_clients.php on line 3 

这里是其抛出的PHP代码是:

variables.php:

<?php 

include ('config.php'); 

$sql_u = "SELECT * FROM users WHERE username='".$_COOKIE['u_name']."'"; 
$result_u = mysql_query($sql_u); 
$row_u = mysql_fetch_array($result_u); 

$sql_c = "SELECT name, user, pass, email, payment_type, last_payment FROM clients WHERE idnum='".$_COOKIE['id']."'"; 
$result_c = mysql_query($sql_c); 

?> 

win_clients.php:

<?php 
include('../includes/variables.php'); 
while ($row_c = mysql_fetch_array($result_c)) 
{ .......... 

的config.php:

//Connect to database from here 
$link = mysql_connect('localhost', 'root', 'xxxxx'); 
if (!$link) { 
    die('Could not connect: ' . mysql_error()); 
} 
//select the database | Change the name of database from here 
mysql_select_db('xxxxxx'); 

,你可以看到每一个我试图运行mysql_fetch_array()它不工作的时间。另一件事:config.php文件正在工作,因为我可以登录到系统中,并根据需要设置cookie。

任何帮助,将不胜感激。

编辑:我通过用“include __ DIR __。'/config.php';”替换正常包含来修复它。

+0

@Rico似乎出错了数据库,因为'$ result_u == FALSE' – Karolis 2011-06-16 14:21:33

+0

这是一个长镜头,但有可能这是一起,但你都发生在专用服务器上设置了不同的错误报告级别? – 2011-06-16 14:24:15

+0

刚刚使用config.php编辑帖子, @Brendan Bullen:没有它的不可能的原因在我的dedi它显示每个客户端喜欢它需要,所以我猜查询工作在那里:) – Ricardo 2011-06-16 14:27:46

回答

1

我觉得你忘了连接到您的数据库

+0

可能是这个。我的猜测是,config.php将服务器地址定义为localhost,或者您的专用服务器的防火墙不允许您连接到数据库。 – ben 2011-06-16 14:24:28

+0

刚刚使用config.php文件编辑了我的帖子。 编辑:这篇文章与我的专用服务器无关,整个文件和数据库不在我的本地服务器上。正如我所说的连接完全正常工作,因为我可以登录和饼干从数据库中采取像他们应该。 – Ricardo 2011-06-16 14:24:38