private function verify_db()
{
$dbhost = 'host';
$dbname = 'dbname';
$dbuser = 'user';
$dbpass = 'pass';
try
{
$db = new PDO("mysql:host=$dbhost;dbname=$dbname", $dbuser, $dbpass );
}
catch(PDOException $err)
{
$err->getMessage();
}
foreach($db->query('SELECT * FROM username') as $row)
{
if ($row == 'username')
{
$this->set_priv('errCode', $row, EXISTS_USER);
$db = NULL;
return false;
}
if ($row == 'email')
{
$this->set_priv('errCode', $row, EXISTS_EMAIL);
$db = NULL;
return false;
}
}
$db = NULL;
return true;
}
To my understanding, that looks correct. I'm trying to find a comparison between usernames and emails in the database, if there is one than the user exists and registration cannot continue. If not than registration can continue and the data will be stored on the database. Now while doing the comparison I am getting this error on the register.php page before even submitting the form:
Warning: Invalid argument supplied for foreach() in /hermes/waloraweb024/b1976/moo.mywebsite/development/authenticate.class.php on line 363 getVerification: 1
the getVerification is just a bool variable that is assigned if the user exists or not:
$getVerification = $this->verify_db(); return $getVerification;
That is the only time it is used, anywhere.
I can see that it has to do with the foreach statement but I really can't see what the problem is. It looks to me to be fine, I have a table called username in the db and according to the many tutorials (however generic they are) it looks perfectly fine to me.
Perhaps because I've been working on this for 15 hours straight my brain is melting away and I just can't see it, so any ideas? Suggestions or tips? I'm going to sleep on it and hopefully dream of a solution, but in the meantime I hope someone can offer a solution.
Oh and I know that I don't have the mysql_get_real_string() function, I took it out for debugging's sake. Thank you for your time
This post has been edited by kiasta: 20 October 2012 - 01:58 AM

New Topic/Question
Reply



MultiQuote






|