SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 20/09/2010, 04:17 PM   #1
DeathOnaStick
High-roller
 
DeathOnaStick's Avatar
 
Join Date: May 2009
Location: 127.0.0.1
Posts: 1,028
Reputation: 27
Default <Php> 'Cannot use object of type stdClass as array'

Hey everybody.
I don't know if this is the correct section here, (i even guess it's the wrong forum, but i don't want to be registered on every shitty forum on the world) but i have a question according php-coding.

When I try to check the values i get from my mysql_database, it gives me a weird error. I tried to ****** it but i did not find anything that helped me somehow. Here my code:
PHP Code:
    ...
    
$result mysql_query("SELECT var1,var2 FROM table WHERE ip = '".$rip."'"); //$rip is declared before
    
$row=mysql_fetch_field($result);
    if(
mysql_num_rows($result)>0)
    {
        if(
$row[0]==1) echo "SINVALID";
        else {
            if(
$row[1]==strval(date("H"))) echo "LREACHED";
            else {
                
mysql_query("INSERT INTO(...)");
                if(
mysql_errno()==0) echo "1";
            }
        }
    }
    ... 
It gives me following error:
Code:
Fatal error: Cannot use object of type stdClass as array in youdontneedmyurl/bleh.php on line 40
In line:
PHP Code:
...
if(
$row[0]==1) echo "SINVALID";
... 
The saving in arrays actually works, i tried this in my code before, so this does not cause the problem (i guess).
I hope anybody has enough knowledge in php to help me with my problem, because i am actually totally bad in coding php =P.

Thanks.
__________________
If this helps you, please thank me by giving me reputation points
DeathOnaStick is offline  
Old 20/09/2010, 04:35 PM   #2
Conroy
Huge Clucker
 
Join Date: Sep 2009
Location: Scotland
Posts: 440
Reputation: 19
Default Re: <Php> 'Cannot use object of type stdClass as array'

http://www.wallpaperama.com/forums/h...php-t1735.html
Conroy is offline  
Old 20/09/2010, 04:48 PM   #3
DeathOnaStick
High-roller
 
DeathOnaStick's Avatar
 
Join Date: May 2009
Location: 127.0.0.1
Posts: 1,028
Reputation: 27
Default Re: <Php> 'Cannot use object of type stdClass as array'

Quote:
Originally Posted by Conroy View Post
Seen this berfore. This did actually not help me. Maybe i used it wrong, would you be able to 'translate' my code to this way? Like i said, i tried it before, but i don't know if i used it correctly, because it did not solve my problem.
__________________
If this helps you, please thank me by giving me reputation points
DeathOnaStick is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED]error 047: array sizes do not match, or destination array is too small help! Help Archive 7 18/06/2011 08:09 PM
error 047: array sizes do not match, or destination array is too small [NYRP]Mike. Help Archive 5 16/12/2010 06:24 PM
error 047: array sizes do not match, or destination array is too small matrixismyname Help Archive 6 25/07/2010 12:58 PM
error 047: array sizes do not match, or destination array is too small NEED HELP MaykoX Help Archive 0 14/03/2010 03:44 PM
[SOLVED] Enable Textdraw when type a command and disable when type the ...... RyDeR` Help Archive 2 11/08/2009 09:02 PM


All times are GMT. The time now is 06:26 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.