Thanks ...no more error notice
Could I ask why mysql_fetch_array works instead of mysql_fetch_object? I thought they worked the same way except one creates an object, while the other creates an array?
Cheers,
Mark
Main Topics
Browse All TopicsHi all
I've turned on error notices and I'm getting one consistent problem throughout all my classes ...it doesn't like lines 17 and 18 where i use "$this" ...can anyone suggest what the problem is with my code? ...must work in both php4 and php5
The error is: "Trying to get property of non-object in line 17" ...
1 class Header_Image
2 {
3 //private variables
4 var $image_id = '';
5 var $filename = '';
6
7 function select_Record($object) {
8 $image_id = $object->image_id;
9
10 $query = mysql_query(" SELECT *
11 FROM $DB.header_image
12 WHERE image_id = '$image_id'");
13 errorcheck();
14
15 $result = mysql_fetch_object($query)
16
17 $this->image_id = $result->image_id;
18 $this->filename = stripslashes($result->file
19 } //end function
20 //**************
...
Thanks
Mark
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
probably you have more than 1 records selected out from DB
so, if insisting using the mysql_fetch_object($query)
while ($row = mysql_fetch_object($query)
echo $row->user_id;
echo $row->fullname;
}
mysql_fetch_array() returns an array that corresponds to the fetched row and moves the internal data pointer ahead. ( From: php.net: http://my.php.net/manual/e
*notes - for the mysql_fetch_array() each time only one record will be fetched.
so,
$result = mysql_fetch_array($query);
you might do some little bit testing on this.
regards.
Business Accounts
Answer for Membership
by: blue_hunterPosted on 2005-12-23 at 00:56:31ID: 15540592
15 $result = mysql_fetch_object($query) ;
16
17 $this->image_id = $result->image_id;
suggest to change to following
$result = mysql_fetch_array($query);
$this->image_id = $result["image_id"];
cheers