[求助]新手问php问题!急需!
<?php$connid=@mysql_connect("localhost","","");
$sql="select * from user_info";
$result=mysql_db_query("user",$sql);
$name=mysql_result($result,0,"username");
$sex=mysql_result($result,0,"sex");
$email=mysql_result($result,0,"Email");
?>
<html>
<head>
<title>信息</title>
</head>
<body>
<table>
<tr>
<td>用户名:</td>
<td>
<?php
echo $name;
?></td>
<tr>
<td>性&nbsp;别</td>
<td>
<?php
echo $sex;
?></td>
<tr>
<td>Email</td>
<td>
<?php
echo $email;
?></td>
</tr>
</table>
浏览效果,出现错误信息:
Warning: mysql_db_query() : Access denied for user 'www-data'@'localhost' (using password: NO) in /var/www/show.php on line 4
Warning: mysql_db_query() : A link to the server could not be established in /var/www/show.php on line 4
Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /var/www/show.php on line 5
Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /var/www/show.php on line 6
Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /var/www/show.php on line 7
用户名:
性 别
请大家帮帮忙!哪里出错了!!
_adslin_db();
$sql = "SELECT *
FROM user_info";
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
$name = $row["name"];
$sex = $row["sex"];
$email = $row["email"];
function _adslin_db ($dbhost = "localhost", $dbuser= "root", $dbpw = "123456", $dbname= "adslin_database")
{
$adslin_dbc = mysql_connect($dbhost, $dbuser, $dbpw);
mysql_select_db($dbname, $adslin_dbc);
return $adslin_dbc;
}
谢谢版主!我试试看.
还有我想问:mysql我没有设置用户密码,是不是一定要设的?? 没有设置的话,相关密码处就留空好了,但数据库用户名是默认就有root的哦
http://dev.mysql.com/doc/refman/5.0/en/database-administration.html
随意看看就OK了
页:
[1]