Running a program which includes two queries. When I run either query alone it works but when both queries exist within the code it breaks.
$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);
How can I fix this?
EDIT:
For those asking what do I mean by it breaks, here is an image.
Error from log.
PHP Parse error: syntax error, unexpected '}' in /Users/philipkirkbride/Documents/apps/Today_test/confirm.php on line 30
Full code of page is
<?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);
?>