<Php> 'Cannot use object of type stdClass as array'
#1

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


Messages In This Thread
<Php> 'Cannot use object of type stdClass as array' - by DeathOnaStick - 20.09.2010, 16:17
Re: <Php> 'Cannot use object of type stdClass as array' - by Conroy - 20.09.2010, 16:35
Re: <Php> 'Cannot use object of type stdClass as array' - by DeathOnaStick - 20.09.2010, 16:48

Forum Jump:


Users browsing this thread: 1 Guest(s)