When working with a PHP PDO, calling execute on a prepared statement appears to completely hang the execution of the script. The PDO is initialized as follows:
$db = new PDO('mysql:host=localhost;dbname=test;charset=utf8', 'root', '');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$db->setAttribute(PDO::ATTR_PERSISTENT, false);
As far as I know, the connection works fine- there is no indication given that it fails. Then, later, I call prepare and then execute, and the execution appears to halt.
echo "Hi"; //executes
$username = mysql_real_escape_string($_POST['username']);
echo "Still Here"; //executes
$password = md5(mysql_real_escape_string($_POST['password']));
echo "So far so good"; //executes
$stmt = $db->prepare("SELECT * FROM users WHERE Username=:username");
echo "Still good"; //executes
$stmt.execute(array(':username' => $username));
echo "Nope..."; //doesn't execute
if($stmt->rowCount() >= 1)
{
echo "Sorry, that username is already taken.";
}
I am not sure what exactly is happening that causes this error, however any help in fixing it would be appreciated.