QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 2066|回复: 3

[求助]新手问php问题!急需!

[复制链接]
发表于 2006-4-4 16:29:57 | 显示全部楼层 |阅读模式
<?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>性 别</td>
   <td>
    <?php
     echo $sex;
    ?></td>
<tr>
  <td>Email</td>
  <td>
   <?php
    echo $email;
   ?></td>
</tr>
</table>
浏览效果,出现错误信息:
Warning: mysql_db_query() [function.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() [function.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
      
用户名:
  性 别
  Email
请大家帮帮忙!哪里出错了!!
发表于 2006-4-4 17:07:15 | 显示全部楼层
[code:1]

_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;
}

[/code:1]
回复

使用道具 举报

 楼主| 发表于 2006-4-4 17:49:25 | 显示全部楼层
谢谢版主!我试试看.
还有我想问:mysql我没有设置用户密码,是不是一定要设的??
回复

使用道具 举报

发表于 2006-4-4 17:55:38 | 显示全部楼层
没有设置的话,相关密码处就留空好了,但数据库用户名是默认就有root的哦

http://dev.mysql.com/doc/refman/5.0/en/database-administration.html

随意看看就OK了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-11-17 00:49 , Processed in 0.043676 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表