PHP 5 PDO: Weird Database Behavior
Posted: Thu Jun 29, 2006 6:20 pm
Okay, I've done a few tests:
I can't give you any Database Information, so I don't know how much help you can be, but if you have any tips for me to figure out to solve my problem then I'll be happy. I'm going to continue my tests to see where I screwed up on.
- I've tested that $GLOBALS['mysql'] is a PDO resource and the Information is accurate.
- I tested if I was getting any errors, and PDO wasn't receiving any from MYSQL.
- I'm not getting any exceptions.
- The foreach loop isn't returning anything. So I suppose that the table doesn't exist, but it does. I see it and the database has the table.
Code: Select all
if(!empty($_POST['username']) and preg_match('/^[a-zA-Z]{1}[ _a-zA-Z0-9-]{5,99}$/', $_POST['username']) and preg_match('/^[a-z-A-Z0-9]{5,100}$/', $_POST['password']))
{
try {
$statement = $GLOBALS['mysql']->prepare("SELECT COUNT(*) FROM gh_users WHERE username=:username AND pass=PASSWORD(:password)");
$statement->bindParam(':username', $username);
$statement->bindParam(':password', $password);
$username = $_POST['username'];
$password = $_POST['password'];
$statement->execute();
$row = $statement->fetch(PDO::FETCH_NUM);
$exists = (bool) $row[0];
foreach($GLOBALS['mysql']->query("SELECT * FROM gh_users") as $row)
{
print_r($row);
}
}
catch(PDOException $e) { var_dump($e); }
}