mysql - PHP Breaks with second mysql_query -


running program includes 2 queries. when run either query alone works when both queries exist within code breaks.

$qry = "select * temp_user email='$email' , pin='$pin'"; $result = mysql_query($qry); $num_rows = mysql_num_rows($result);  $qry2 = "select * email email='$email'"; $result2 = mysql_query($qry2); $num_rows2 = mysql_num_rows($result2); 

how can fix this?

edit:

for asking mean breaks, here image.

enter image description here

error 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 * temp_user email='$email' , pin='$pin'"; $result = mysql_query($qry); $num_rows = mysql_num_rows($result); if ($num_rows!=0){     print "create user , delete temp";     $sql = "insert pin values (default, '$pin', '$email')";     $result = mysqli_query($con,$sql);     if ( false===$result ) {       printf("error: %s\n", mysqli_error($con));     } else {         // delete user temp table         $sql2 = "delete temp_user email='$email' , pin='$pin'";         $delete = mysqli_query($con,$sql2);         // make query see if user new or existing         $qry2 = "select * email email='$email'";         $result2 = mysql_query($qry2);         $num_rows2 = mysql_num_rows($result2);         // need add snippet add row email table, make sure check user doesn't have email in table         if($num_rows2==0){             print "email doesn't exist, create new user."             // $date = new datetime;             // $sql = "insert 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); ?> 

try calling $result->close() before call second query, in order release connection. php script hasn't finished executing yet, , previous result holding connection open. in general, practice explicitly clean these kinds of resources rather leaving runtime.

edit: believe @eis correct since older (and deprecated, incidentally) mysql_ api, proper call mysql_free_result($result).

another edit: put comment under @eis's answer, figure bears bolder type, because @eis's answer absolutely right , should not have been down-voted:

just elaborate redundantly on whole buffered vs. unbuffered thing; concept buffered query read of results database buffer, release connection automatically (this happen synchronously, connection free call after buffered call returns). unbuffered query open connection , hand reference database server cursor, need fetch records. long there left fetch, cursor still open, , won't using underlying connection anything else. or can call mysql_free_result() , free connection "early" (without reading of rows cursor first).


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -