<?php     require_once('Connections/conn.php');
$conn=mysql_connect("localhost","root","root")or die("不能连接到数据库");
mysql_select_db("user",$conn)or die("can't connect to the servers"); 
    $reback=0;
    $sql="select * from user where name="'.$_GET['user'].'"";
    $rst=$conn->Execute($sql)or die('execute error');
    if($ret->RecordCount()==1)
  {
                $reback='2'; 
      }      else
      { 
                $reback='1';   
          }                echo $reback; 
?>页面是验证用户名是否存在。
提示是SQL语句出了问题。请高手指教!

解决方案 »

  1.   

    $sql="select * from `user` where `name`="'.$_GET['user'].'"";//user是关键词,用 ` 包着。字段名也一样。
      

  2.   

    <?php
    require_once('Connections/conn.php');
    $conn=mysql_connect("localhost","root","root")or die("不能连接到数据库");
    mysql_select_db("user",$conn)or die("can't connect to the servers");
    $reback=0;
    $sql="select * from user where name='".$_GET['user']."'"; //注意这句的引号
    $rst=$conn->Execute($sql)or die('execute error');
    if($ret->RecordCount()==1){
    $reback='2';
    }else{
    $reback='1';
    }echo $reback;
    ?>
      

  3.   

    多谢2位还有就是
    $rst=$conn->Execute($sql)or die('execute error');
    这行也有报错- -
      

  4.   

    $conn->Execute($sql)or die('execute error');麻烦帮忙看下···
      

  5.   

    $sql="select * from user where name='".$_GET['user']."'"; 
      

  6.   

    $sql="select * from user where name="'.$_GET['user'].'""; 这句要是不出错你砍死我
     $sql="select * from user where name='".intval($_GET['user'])."'";
      

  7.   

    错了,user是数字的话用intval,不是数组不能用intval
      

  8.   

    $_GET['user']
    不存在时sql语句不同样完蛋吗