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.....

 

 

Link to comment
Share on other sites

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..  :'(

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.