Class definitions mysql_fetch_row() php 5
Posted: Mon Jan 11, 2010 1:09 am
Plz help me about Class definitions mysql_fetch_row() php 5
I am new in php 5
I am new in php 5
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
class database {
private $host;
private $user;
private $password;
private $database;
private $conn;
private $row;
function __construct() {
$this->host = "localhost";
$this->user = "root";
$this->password = "";
$this->conn = mysql_connect($this->host, $this->user, $this->password)
or die(mysql_error());
$this->changeDatabase("collage");
}
function changeDatabase($databaseName) {
mysql_select_db ($databaseName);
$this->database = $databaseName;
}
function query($sql) {
return mysql_query($sql,$this->conn) or die(mysql_error());
}
function num_rows($result) {
return mysql_num_rows($result);
}
function fetch_array($result) {
return mysql_fetch_array($result);
}
function fetch_row($result) {
return mysql_fetch_row($result);
}
}Code: Select all
<?php
include("lib/database.php");
$myCnn = new database();
error_reporting(E_ALL ^ E_NOTICE);
// Initialize session
session_id();
session_start();
header('Cache-control: private'); // IE 6 FIX
if($_POST['action'] == 'user_login')
{
$post_email = $_POST['email'];
$post_password = $_POST['password'];
// check username and password
$query="select * from admininfo where Ausername='$post_email' and Apass=md5('$post_password')";
$result=$myCnn->query($query) or die(mysql_error());
if($row=$myCnn->fetch_row($result))
{
$_SESSION['Ausername'] = $row[1];
$_SESSION['Apass'] = $row[2];
$_SESSION['name'] = $row[4];
//$url="admin/admin.php";
//header("Location: $url");
// report_log_in_out($row[0], "Loged in");
echo 'OK'; // this response is checked in 'process-login.js'
}
else
{
$auth_error = '<div id="notification_error">The login info is not correct.</div>';
echo $auth_error;
}
}
?>
Code: Select all
Warning: mysql_fetch_row() expects parameter 1 to be resource, boolean given in ...\admin\lib\database.php on line 34Or if($result).tasairis wrote:I don't see any call to $myCnn->num_rows().