Note that there are some explanatory texts on larger screens.

plurals
  1. POError When Calling Function
    primarykey
    data
    text
    <p>I searched forever trying to find an answer, but was ultimately stumped. I've been writing code to allow multiple bots to connect to a chat box. I wrote all the main code and checked it over to make sure it was all okay. Then when I got to calling the function needed to make it work, it gave me an error saying:</p> <blockquote> <p>Notice: Undefined variable: ip in C:\wamp\www\BotRaid.php on line 40</p> </blockquote> <p>And also an error saying:</p> <blockquote> <p>Fatal Error: Cannot access empty property in C:\wamp\www\BotRaid.php on line 40</p> </blockquote> <p>( Also a screenshot here: <a href="http://prntscr.com/ckz55" rel="nofollow">http://prntscr.com/ckz55</a> )</p> <pre><code>&lt;?php date_default_timezone_set("UCT"); declare(ticks=1); set_time_limit(0); class BotRaid { public $ip="174.36.242.26"; public $port=10038; public $soc = null; public $packet = array(); ############################## # You can edit below this # ############################## public $roomid="155470742"; public $userid = "606657406"; public $k = "2485599605"; public $name=""; public $avatar=; public $homepage=""; ############################## # Stop editing # ############################## public function retry() { $this-&gt;connect($this-&gt;$ip,$this-&gt;$port); //Line 40, where I'm getting the error now. $this-&gt;join($this-&gt;$roomid); while($this-&gt;read()!="DIED"); } public function connect($ip, $port) { if($this-&gt;$soc!=null) socket_close($this-&gt;$soc); $soc = socket_create(AF_INET,SOCK_STREAM,SOL_TCP); if(!$this-&gt;$soc)$this-&gt;port(); if(!socket_connect($this-&gt;$soc,$this-&gt;$ip,$this-&gt;$port))$this-&gt;port(); } public function port() { $this-&gt;$port++; if($this-&gt;$port&gt;10038) $this-&gt;$port=10038; $this-&gt;retry(); } public function join($roomid) { $this-&gt;send('&lt;y m="1" /&gt;'); $this-&gt;read(); $this-&gt;send('&lt;j2 q="1" y="'.$this-&gt;$packet['y']['i'].'" k="'.$this-&gt;$k.'" k3="0" z="12" p="0" c"'.$roomid.'" f="0" u="'.$this-&gt;$userid.'" d0="0" n="'.$this-&gt;$name.'" a="'.$this-&gt;$avatar.'" h="'.$this-&gt;$homepage.'" v="0" /&gt;'); $this-&gt;port(); $this-&gt;$roomid; } public function send($msg) { echo "\n Successfully connected."; socket_write($this-&gt;$soc, $this-&gt;$msg."\0", strlen($this-&gt;$msg)+1); } public function read($parse=true) { $res = rtrim(socket_read($this-&gt;$soc, 4096)); echo "\nSuccessfully connected."; if(strpos(strtolower($res), "Failed"))$this-&gt;port(); if(!$res) return "DIED"; $this-&gt;lastPacket = $res; if($res{strlen($res)-1}!='&gt;') {$res.=$this-&gt;read(false);} if($parse)$this-&gt;parse($res); return $res; } public function parse($packer) { $packet=str_replace('+','@più@',str_replace(' ="',' @=@"',$packet)); if(substr_count($packet,'&gt;')&gt;1) $packet = explode('/&gt;',$packet); foreach((Array)$packet as $p) { $p = trim($p); if(strlen($p)&lt;5) return; $type = trim(strtolower(substr($p,1,strpos($p.' ',' ')))); $p = trim(str_replace("&lt;$type",'',str_replace('/&gt;','',$p))); parse_str(str_replace('"','',str_replace('" ','&amp;',str_replace('="','=',str_replace('&amp;','__38',$p)))),$this-&gt;packet[$type]); foreach($this-&gt;packet[$type] as $k=&gt;$v) { $this-&gt;packet[$type][$k] = str_replace('@più@','+',str_replace('@=@','=',str_replace('__38','&amp;',$v))); } } } } $bot = new BotRaid; //This is where I had the error originally $bot-&gt;retry(); ?&gt; </code></pre> <p>Line 40 is below the "Stop Editing" line. Anyone have any suggestions? Or perhaps need me to clear some things up?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload