duanmu2013 2009-09-29 13:38
浏览 20

如何使用mysql和php从数据库中显示成员信息的问题?

Okay I have a piece of code that for some reason gives me the following errors.

Warning: mysqli_query() expects at least 2 parameters, 1 given in
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in

here is the code below.

$dbc = mysqli_query("SELECT * FROM sitename WHERE id='$user_id'"); 
while($row = mysqli_fetch_array($dbc)){ 
$state = $row["state"];
$city = $row["city"];
$zip = $row["zip"]; 
$bio_body = $row["bio_body"]; 

If you can please help me by giving me the correct code.

  • 写回答

3条回答 默认 最新

  • dosin84644 2009-09-29 13:41
    关注

    You need to include the database link parameter as well as the query you want to run. Like this:

    $mysqli = new mysqli("localhost", "my_user", "my_password", "world");
    $dbc = mysqli_query($mysqli,"SELECT * FROM sitename WHERE id='$user_id'"); 
    

    I don't see why it wouldn't work after that's fixed.

    评论

报告相同问题?