Re: mysql_fetch_array warning

From: Date: Sun, 04 Jun 2000 19:40:46 +0000
Subject: Re: mysql_fetch_array warning
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-993@lists.php.net to get a copy of this message
> I am getting this warning using php3/Mysql and Apache: > > Warning: $row is not an object in /cart.php3 on line 36 > > Block containing line 36: > > $query1 = "select session_id_num from user where userid ='$userid'"; > $result2 = MYSQL_QUERY($query1); > > while ( $row = mysql_fetch_array ($result2) ) { > $session_id = $row -> session_id_num; > } > mysql_free_result($result2); > > > Any Ideas why this error happens? When I look at errno and error it shows > "0" meaning no backend errors, but why this warning? mysql_fetch_array() returns an array. You are trying to access $row as an object since you are doing $row->session_id_num. You should be doing $row['session_id_num']. If you want to access it your way, call mysql_fetch_object() -Rasmus

« previous php.general (#993) next »