Hi guys I think this is repetitive and most asked question … how Can I call a function in a class in another class ?
mysql class :
....
function RowCount( $string )
{
$result = $this->Query( $string );
return mysql_num_rows( $result );
mysql_free_result( $result );
}
.....
I wanna call RowCount in this class :
<?php
class Authentication
{
function Login( $table = NULL , $data = array() )
{
if ( ( $table !== NULL ) or ( !is_array( $data ) ) ) return FALSE;
foreach ( $data as $index => $ket )
{
$mysql[] = $index;
$value[] = $key;
}
global $db;
$row_count = $db->RowCount("Select * from ".$table." where ".$mysql[0]." = '".$value[0]."' and ".$mysql[1]." = '".md5( $value[1] )."'");
if ( $row_count > 0 ) return TRUE;
}
}
?>
index.php
<pre>
<?php
$config['hostname'] = 'localhost';
$config['username'] = 'root';
$config['password'] = '';
$config['database'] = 'auth';
require_once('mysql.class.php');
require_once('auth.class.php');
$data = array ( 'username' => 'admin' , 'password' => '21232f297a57a5a743894a0e4a801fc3' );
$db = new MySQL();
$db->SetUpParam( $config );
$connection = new Authentication();
if ( ( $connection->Login ( 'admin' , $data ) ) === TRUE ) echo 'Admin!';
But doesn’t work …