my script is shown below
it returns the following output
==============================================
object(user)(11) { ["id"]=> NULL ["author"]=> NULL ["username"]=> NULL ["password"]=> NULL
["full_name"]=> NULL ["email"]=> NULL ["phone"]=> NULL ["avatar"]=> NULL ["signature"]=> NULL
["posts"]=> NULL ["details"]=> NULL }
==============================================
but it is supposed to show the real values in the db
all the db params are good
help me please
my script is as follows
==============================================
<?php
$host="localhost";
$username="root";
$password="";
$name="cmrit";
$connect_parameters = mysql_connect($host,$username,$password);
mysql_select_db($name);
class user {
var $id,$author,$username,$password;
var $full_name,$email,$phone,$avatar;
var $signature,$posts,$details;
function initialize_user($user_id) {
$connect_parameters = mysql_connect("localhost","root","");
mysql_select_db("cmrit");
$user_query = "SELECT * FROM members WHERE id = $user_id";
// $user_query = "SELECT * FROM members WHERE id = '$user_id'";
//
// tried both of these already - same result
//
$user_result = mysql_query($user_query,$connect_parameters);
$user_row = mysql_fetch_row($user_result);
$id = $user_row[0];
$author = $user_row[1];
$username = $user_row[2];
$password = $user_row[3];
$full_name = $user_row[4];
$email = $user_row[5];
$phone = $user_row[6];
$avatar = $user_row[7];
$signature = $user_row[8];
$posts = $user_row[9];
$details = $user_row[10];
}
function get_full_name() {
return $this->full_name;
}
};
$mahendra = new user();
$mahendra->initialize_user(1);
var_dump($mahendra);
?>
==============================================
the db schema is as follows
==============================================
CREATE TABLE members (
id tinyint(3) unsigned NOT NULL auto_increment,
author tinyint(3) unsigned DEFAULT '0' NOT NULL,
username varchar(255) NOT NULL,
password varchar(255) NOT NULL,
full_name varchar(255) NOT NULL,
email varchar(255) NOT NULL,
phone int(10) unsigned DEFAULT '0' NOT NULL,
avatar varchar(255) NOT NULL,
signature varchar(255) NOT NULL,
posts tinyint(3) unsigned DEFAULT '0' NOT NULL,
details text NOT NULL,
PRIMARY KEY (id),
UNIQUE id (id),
KEY id_2 (id)
);
INSERT INTO members VALUES (1,1,'mahendra','mahendra','Mahendra
Kalkura','m@m.com',6630155,'','',100,'');
==============================================
cya guys soon (with a solution ofcourse)