查询错误  麻烦帮忙改下 : <?php     //DataBase   Info   
  $dbhost   =   "localhost";   //   DB   Host   
  $dbuser   =   "admin";   //   DB   User   
  $dbpasswd   =   "admin";   //   DB   User   Password   
  $dbname   =   "mysql";   //   DB   Name   
    
  //DataBase   Connect   
  $mylink=mysql_connect($dbhost,$dbuser,$dbpasswd);   
  mysql_select_db($dbname,$mylink);   
    
  //Select   SQL   
  $sql="select help_topic_id,help_keyword_id from  $help_relation";   
  $result=mysql_query($sql);     
  while($myarray=mysql_fetch_array($result))   
  {   
  //Print   result   
    
  echo   $myarray["help_topic_id"];   
  echo   $myarray["help_keyword_id"];   
  echo   "<br>";   
  }     ?>错误提示:Notice: Undefined variable: user in D:\PC_webserver\phproot\1.php on line 13Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\PC_webserver\phproot\1.php on line 15看出来的帮忙改下 !

解决方案 »

  1.   

    $help_relation   是不是user啊
      

  2.   

    把sql语句echo 出来,在 phpmyadmin 里运行一下,看是不是sql问题
      

  3.   

    //DataBase Connect   
      mysql_connect($dbhost,$dbuser,$dbpasswd);   
      mysql_select_db($dbname);   
        
    //Select SQL   
    $sql="select help_topic_id,help_keyword_id from $help_relation";   
    1:  ","改为 ","
    2: $help_relation的值有么?这个表存在么
      

  4.   

    变量$user 未定义,不过你代码里没有user啊
      

  5.   

    也就是说
    没有连上数据库并且没找到$help_relation
      

  6.   

    呵呵  谢谢了 !$help_relation 改成help_relation就取出来了 !
    能给我说说 为什么嘛?
      

  7.   

    什么为什么?
    $help_relation 是变量,而你没有这个变量啊
    help_relation 是字符串,如果有这个表,那当然就可以了
      

  8.   

    $help_relation 为空了  
    而你的表的名字叫help_relation??
      

  9.   

    $dbhost = "localhost"; // DB Host   
    如果要变成  ip 地址 远程的  还应该加什么 例如:58.218.212.84 端口是 212
      

  10.   

    $dbhost = ip
    $port = 端口(端口不同于默认的情况下)
    其他的没有了 
      

  11.   

    $mylink=mysql_connect($dbhost,$dbuser,$dbpasswd);  这个里面还要填写$port这个嘛?
      

  12.   

    在mysql默认的端口被修改的情况下,才会host:port的