Jump to content

Need HELP "Cannot use object of type stdClass as array" :(


superbogel

Recommended Posts

Hi Guys,

 

I need help I have setup a code recently :

 

this is the code :

$za['MIN(spec_positionid)']

 

and it gave me an error saying : Cannot use object of type stdClass as array

 

but if I change to this :

 

$za->spec_positionid

 

it works, but I need to get the MIN value from the database.

 

can someone please help. :(

 

this is very urgent for me.....

 

 

here is the definition :

 

$ra = db_query("SELECT MAX(spec_id), MAX(spec_positionid), MIN(spec_id), MIN(spec_positionid) FROM spec");

$za = db_fetch_object($ra);

 

if ($a->spec_positionid!=$za['MIN(spec_positionid)']) { $page_content .= '<a href="spec.php?idcat=$a->spec_id&movecatpos=$a->spec_positionid&movecat=up"><img src="images/uparrow.png" border="0" align="absmiddle">up</a>'; } else { $page_content .='     '; }

 

 

this code : $za['MIN(spec_positionid)'] shows error, but I don't understand how to change it into $za->(get the min value from the DB).

 

please help..  :'(

Use aliases in your query.

 

$ra = db_query("SELECT MAX(spec_id) AS max_spec_id, MAX(spec_positionid) AS max_spec_positionid, MIN(spec_id) AS min_spec_id, MIN(spec_positionid) AS min_spec_positionid FROM spec");

 

Then use....

 

$za->min_spec_positionid

Use aliases in your query.

 

$ra = db_query("SELECT MAX(spec_id) AS max_spec_id, MAX(spec_positionid) AS max_spec_positionid, MIN(spec_id) AS min_spec_id, MIN(spec_positionid) AS min_spec_positionid FROM spec");

 

Then use....

 

$za->min_spec_positionid

 

THIS SOLVE THE PROBLEM!!! YOU ARE THE MAN!! THANK YOU VERY MUCH  :D

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.