I have a problem with mysql and php

Posted by neo skosana on Stack Overflow See other posts from Stack Overflow or by neo skosana
Published on 2010-05-06T17:48:26Z Indexed on 2010/05/06 17:58 UTC
Read the original article Hit count: 248

Filed under:
|
|

Hi

I have a problem, this is my code:

$db = new mysqli("localhost", "root", "", "blah");

$result1 = $db->query("select * from c_register where email = '$eml' and password = '$pass'");

if($result1->fetch_array())

{

    $auth->createSession();

    $_SESSION['user'] = 'client';

    promptUser("You have successfully logged in!!!","index.php");

}

$db = new mysqli("localhost", "root", "", "blah");

$result2 = $db->query("select * from b_register where email = '$eml' and password = '$pass'"); if($result2->fetch_array())

{

     $auth->createSession();

     $_SESSION['user'] = 'business';

     promptUser("You have successfully logged in!!!","index.php");

} $db = new mysqli("localhost", "root", "", "blah");

$result3 = $db->query("select * from g_register where email = '$eml' and password = '$pass'"); if($result3->fetch_array())

{

    $auth->createSession();

    $_SESSION['user'] = 'employee';

    promptUser("You have successfully logged in!!!","index.php");

}

$db = new mysqli("localhost", "root", "", "blah");

$result4 = $db->query("select * from k_register where email = '$eml' and password = '$pass'"); if($result4->fetch_array())

{

    $auth->createSession();

    $_SESSION['user'] = 'super';

    promptUser("You have successfully logged in!!!","index.php");

} else

{

    promptUser("Username/Password do not match.  Please try again!!!","");

}

Funny enough this code works, but I no that I went about it the wrong way. I am new with php and mysql, so please help. I also tried e.gresult4->free(); for all the variable that save the data, and I got this error: Fatal error: Call to a member function free() on a non-object in...

© Stack Overflow or respective owner

Related posts about php

Related posts about mysqli