<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
#2

http://www.wallpaperama.com/forums/h...php-t1735.html
Reply
#3

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


Forum Jump:


Users browsing this thread: 1 Guest(s)