运行一个包含两个查询的程序。当我单独运行任一查询时,它可以工作,但是当两个查询都存在于代码中时,它会中断。
$qry = "SELECT * FROM temp_user WHERE email='$email' AND pin='$pin'";
$result = mysql_query($qry);
$num_rows = mysql_num_rows($result);
$qry2 = "SELECT * FROM email WHERE email='$email'";
$result2 = mysql_query($qry2);
$num_rows2 = mysql_num_rows($result2);
我怎样才能解决这个问题?
编辑:
对于那些询问我所说的中断是什么意思的人,这里有一张图片。
来自日志的错误。
PHP Parse 错误:语法错误,第 30 行 /Users/philipkirkbride/Documents/apps/Today_test/confirm.php 中的意外“}”
页面的完整代码是
<?php
include 'connect.php';
$pin = $_GET['pin'];
$email = $_GET['email'];
$qry = "SELECT * FROM temp_user WHERE email='$email' AND pin='$pin'";
$result = mysql_query($qry);
$num_rows = mysql_num_rows($result);
if ($num_rows!=0){
print "create user and delete temp";
$sql = "INSERT INTO pin VALUES (DEFAULT, '$pin', '$email')";
$result = mysqli_query($con,$sql);
if ( false===$result ) {
printf("error: %s\n", mysqli_error($con));
} else {
// Delete user from temp table
$sql2 = "DELETE FROM temp_user WHERE email='$email' AND pin='$pin'";
$delete = mysqli_query($con,$sql2);
// Make query to see if user is new or existing
$qry2 = "SELECT * FROM email WHERE email='$email'";
$result2 = mysql_query($qry2);
$num_rows2 = mysql_num_rows($result2);
// Need to add a snippet to add a row to the email table, make sure to check user doesn't have an email already in table
if($num_rows2==0){
print "email doesn't exist, create new user."
// $date = new DateTime;
// $sql = "INSERT INTO email VALUES ('$email', '$date')";
// $result = mysqli_query($con,$sql);
}else{
print "email exists already";
}
}
}else{
print "Account request not found";
}
// End connection
mysqli_close($con);
?>