-6

我在这段代码中得到了错误。这段代码有什么问题?由于解析错误,它也给出了这个错误( SCREAM:错误抑制被忽略)。

1.     <?php   
2.    session_start(); 
3.      $name=$_POST['email']; //email, pass is the id='' field from table
4.      $passs=$_POST['pass'];
5.        mysql_connect("localhost","root",""); //db connection file
6.      mysql_select_db("secg");
7.       $_SESSION['email']='$name'; //for security purpose
8.   $result=mysql_query("select * from student where Email='$name and password='$passs'");
9.          $row=mysql_fetch_array($result);
10.        if($row>0)
11.           {
12.              header("location:index.htm");  }
13.           else  {
14.           die('could not be opened because of' mysql_error() ); }               
15.    ?>               
4

3 回答 3

5

该 die() 中缺少一个点

die('could not be opened because of'.mysql_error())
于 2013-06-25T13:10:47.430 回答
1

尝试更换

$_SESSION['email'] = $name;

在 tha sql 查询之后给出这个

die('could not be opened because of'.mysql_error())

因为它会给你 mysql 错误并且也不要使用mysql_*语句,因为它们已被弃用。Insted 使用mysqli_*语句或PDO statements

于 2013-06-25T13:10:21.367 回答
1

少了一个点:

die('could not be opened because of' . mysql_error() );
于 2013-06-25T13:11:07.657 回答