OOP + Functions Help
Posted: Thu Mar 15, 2007 3:05 pm
Hello,
I've created a few functions that use some class functions as well. But I cant get the two to work together. I don't understand whats going on here. I've included as much information as I thought necessary.
I've created a few functions that use some class functions as well. But I cant get the two to work together. I don't understand whats going on here. I've included as much information as I thought necessary.
Fatal error: Call to a member function on a non-object in login.function.php on line 4
Code: Select all
<?php
require("include/config.php");
require("include/mysql.class.php");
require("include/login.function.php");
$db = new mysql($db['host'], $db['username'], $db['password'], $db['database']);
checkUsername("tehbrosta");
$db->close();
?>Code: Select all
//login.function.php
function checkUsername($username)
{
$data = $db->query("SELECT username FROM `" . $tb['login'] . "` WHERE username = '" . $db->prepare($username) . "' LIMIT 1") or $db->raise_error(); //LINE 4
if( $db->num_rows($data) == 1 )
{
return true;
}
else
{
return false;
}
}