Page 1 of 1
I cannot connect to server with fsockopen, please help!
Posted: Tue Oct 03, 2006 8:21 am
by kaisellgren
If someone can answer me why this doesn't work?
$fp = fsockopen("psychclassics.yorku.ca/Abbott",80,$errno,$errstr,0.5);
It does not create sock connection

Posted: Tue Oct 03, 2006 8:37 am
by miro_igov
where is your protocol string ? http:// ?
Posted: Tue Oct 03, 2006 8:40 am
by kaisellgren
I have also tried that but no lucky:
Warning: fsockopen() [function.fsockopen]: unable to connect to
http://psychclassics.yorku.ca/Abbott:80 (Unable to find the socket transport "http" - did you forget to enable it when you configured PHP?) in C:\Ohjelmat\WAMP\www\test.php on line 8
Unable to find the socket transport "http" - did you forget to enable it when you configured PHP? (40)
OH THAT'S BECAUSE THERE IS NOT
http://psychclassics.yorku.ca/Abbott:80 BUT HOW DO IT THE PORT? THIS IS ALSO WRONG:
http://psychclassics.yorku.ca/Abbott/:80 <--- HOW TO GET RID OF THE PORT?
Posted: Tue Oct 03, 2006 12:48 pm
by Mordred
fsockopen connects to a SERVER
the server is psychclassics.yorku.ca, not psychclassics.yorku.ca/Abbott
Posted: Tue Oct 03, 2006 1:59 pm
by kaisellgren
Okay I managet to connect to a html file with fopen(), but how do you connect to a .txt file? By connecting I mean that I'm able to read the lines of txt.
Posted: Tue Oct 03, 2006 2:18 pm
by volka
If enabled use php's url wrappers.
Code: Select all
<?php
$contents = file('http://psychclassics.yorku.ca/Abbott/');
foreach($contents as $line) {
echo '# ', htmlentities($line);
}
?>
see
http://de2.php.net/manual/en/ref.filesy ... -url-fopen
Posted: Wed Oct 04, 2006 7:41 am
by kaisellgren
That works well for html pages but does not work for a txt file ...