<Php> 'Cannot use object of type stdClass as array' - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: <Php> 'Cannot use object of type stdClass as array' (
/showthread.php?tid=178114)
<Php> 'Cannot use object of type stdClass as array' -
DeathOnaStick - 20.09.2010
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.
Re: <Php> 'Cannot use object of type stdClass as array' -
Conroy - 20.09.2010
http://www.wallpaperama.com/forums/h...php-t1735.html
Re: <Php> 'Cannot use object of type stdClass as array' -
DeathOnaStick - 20.09.2010
Quote:
Originally Posted by Conroy
|
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.