迁移到xampp后mysql_fetch_array()错误?

时间:2011-06-16 14:17:49

标签: php mysql

直到现在我在我的专用服务器上制作所有项目真的很痛苦 - 现在我决定用xampp移动本地但看起来像mysql_fetch_array()在我的专用服务器上的工作方式不同,当我尝试要查看在我的dedi上运行完美的内容,就会抛出这些错误:

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';”替换普通的include来修复它。

1 个答案:

答案 0 :(得分:1)

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