fsockopen

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

BachgenCymreig
Forum Newbie
Posts: 12
Joined: Fri Sep 22, 2006 3:57 pm

Post by BachgenCymreig »

UGH I haven't had a chance to reply with work :@

Ok so I tried removing the '@' operator before fsockopen and now I get an error message:
Warning: fsockopen() [function.fsockopen]: unable to connect to irc.com:6667 in /home/cymru/public_html/alpha/registernick.php on line 30

Code: Select all

set_time_limit(0);

$server_host = "irc.com";
$server_port = "6667";

$nickname = $nick;


$server = array(); //we will use an array to store all the server data.

$server['SOCKET'] = fsockopen($server_host, $server_port, $errno, $errstr, 2);
if($server['SOCKET'])
{
  SendCommand("NICK $nickname\n\r"); 
  SendCommand("USER $nickname test test :IRC.com NickRegBot\n\r");
}
btw irc.com isn't the real server but the actual server I am trying to get it connecting to is up and running and the above script works to connect on my website, just not my friends. Really annoying me now lol

Any further help greatly appreciated - Thanks!
BachgenCymreig
Forum Newbie
Posts: 12
Joined: Fri Sep 22, 2006 3:57 pm

Post by BachgenCymreig »

Am I allowed to ask again now? :oops: Helppppppp someone! lol
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Post by daedalus__ »

Dood.

Fix this:

Warning: fsockopen() [function.fsockopen]: unable to connect to irc.com:6667 in /home/cymru/public_html/alpha/registernick.php on line 30

Try again.

Where is the definition for SendCommand?

Did you write this script?

Try this:

Code: Select all

$server_host = "irc.com";
$server_port = "6667";

$nickname = $nick; <-- where the heck did $nick come from?

// we could have used an array to store all the server data but since only the socket is in there, an array is a waste of memory.

$sr = fsockopen($server_host, $server_port, $errno, $errstr, 2) or print('Could not open socket:<br />');

if($sr != false)
{
   SendCommand("NICK $nickname\n\r");
   SendCommand("USER $nickname test test :IRC.com NickRegBot\n\r");
}
else
{
   // the MANUAL states that if the error number is 0 or if fsockopen() returns false then there was probably a problem initializing the socket
   echo $errno.'<br />'.$errstr.'<br />';
}
Tell your friend to turn off Register Globals to see if it helps, if he refuses, refuse to help him. :P

EDIT: Please, learn how to do basic error checking.
Post Reply