www.webdeveloper.com
Results 1 to 2 of 2

Thread: 1st Prepared Statement is not returning results

  1. #1
    Join Date
    Jul 2006
    Posts
    146

    1st Prepared Statement is not returning results

    I have followed instructions from a tutorial, but the following will not return results. I know that the query it is performing does have corresonding values. But, the while $stmt->fetch() loop never gets entered.

    Code:
    		$host = "#####";
    		$user="####";
    		$password="####";
    		$database="####";
    		
    		$mysqli = new mysqli($host, $user, $password, $database);
    
    		if (mysqli_connect_errno()) {
    			printf("Connect failed: %s\n", mysqli_connect_error());
    			exit();
    		}
    
    		/* prepare statement */
    		if ($stmt = $mysqli->prepare("SELECT UserID, UserFirstName FROM User where UserEmail = ?"))
    		{
    			$stmt->bind_param("s",$EmailAddress);
    
    			$stmt->execute();
    
    			/* bind variables to prepared statement */
    			$stmt->bind_result($col1,$col2);
    			
    			
    			  /* fetch values */
    			while ($stmt->fetch()) 
    			{
    				printf("results:%s %s\n", $col1, $col2);
    			} 
    			
    			/* close statement */
    			$stmt->close();
    		}
    		/* close connection */
    		$mysqli->close();
    Thank you for any insight

  2. #2
    Join Date
    Jul 2006
    Posts
    146
    The issue with my code was that i was using double quotation marks in the $stmt->bind_param() call to indicate parameter type ("ss"). Once i switched to single quotes, it is magic

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles