这是PHP代码
。。省略一部分
***下面是出错的几句
$query="select * from als_signup where UserName='{$_SESSION['UserName']}' and Password='{$_SESSION['Password']}'";
$result=mysql_query($query);
$row=mysql_fetch_array($result);
if ($row)
{
//如果session会话变量用户名与密码匹配,则自动登录,直接跳转到管理页面
header("refresh:1;url=http://localhost/members/manage.php");
exit;
}
这是运行的警告!!
Warning: mysql_query() [function.mysql-query]: Access denied for user
'ODBC'@'localhost' (using password: NO) in D:\wamp\www\phptest\config.php
on line 9
Warning: mysql_query() [function.mysql-query]: A link to the server
could not be established in D:\wamp\www\phptest\config.php on line
9
Warning: mysql_query() [function.mysql-query]: Access denied for user
'ODBC'@'localhost' (using password: NO) in D:\wamp\www\phptest\config.php
on line 12
Warning: mysql_query() [function.mysql-query]: A link to the server
could not be established in D:\wamp\www\phptest\config.php on line
12
Error while creating database (Error1045:"Access denied for user
'ODBC'@'localhost' (using password: NO)")
Warning: session_start()
[function.session-start]: Cannot send
session cache limiter - headers already sent (output started at
D:\wamp\www\phptest\config.php:9) in D:\wamp\www\phptest\login.php on
line 4
Warning: mysql_query() [function.mysql-query]: Access denied for user
'ODBC'@'localhost' (using D:\wamp\www\phptest\login.php on line
6
Warning: mysql_fetch_array(): supplied argument is not a
valid MySQL result resource in D:\wamp\www\phptest\login.php on line
7
php语法错误
你既然把$_SESSION['UserName']直接写在sql语句中,那就不要加那个单引号了,
正确语法是:
$query="select * from als_signup where UserName='{$_SESSION[UserName]}' and Password='{$_SESSION[Password]}'";第二处应该修改的是:
$row=mysql_fetch_array($result);改成:
$row=mysql_num_rows($result);mysql_num_rows()函数是返回mysql_query()返回的数据源的行数,也就是返回符合sql语句的数据表内的记录行数,如果有这用户,那么至少存在1行,如果没有这个用户,那就是没有一行,就会返回0
追问$query="select * from als_signup where UserName='{$_SESSION[UserName]}' and Password='{$_SESSION[Password]}'";
$result=mysql_query($query);
$row=mysql_num_rows($result);
按照你的修改后错误提示不变哦~请指教
你确定你连接数据库都正常?
要操作数据库,首先要连接数据库不是?
你得先排除数据库连接方面的问题啊
Warning: mysql_query() [function.mysql-query]: A link to the server
could not be established in D:\wamp\www\phptest\config.php on line
12
Error while creating database (Error1045:"Access denied for user
'ODBC'@'localhost' (using password: NO)")
这条警告,感觉像是数据库连接有问题
我自己打开数据库能连上,能加我聊下吗?我把所有的源码发你看一下,谢谢啦。
我的寇953 984048,到时再给你加分
看了你对其他人的追问
<?php<?php
$server="localhost";
$username="root";
$password="";
$database="";
这是config.php里面的代码 和我的电脑设置的是一样的,为什么还是打不开呢?
看你的错误信息是用的ODBC这个帐号
追问ODBC是PHP通过这个数据库的名字吧,能加我聊下吗?我把所有的源码发你看一下,谢谢啦。
我的寇953 984048,到时再给你加分
<?php
$server="localhost";
$username="root";
$password="";
$database="";
这是config.php里面的代码 和我的电脑设置的是一样的,为什么还是打不开呢?