obigraphics Posted June 6, 2007 Share Posted June 6, 2007 Hi everyone, I have a slight problem that I can't seem to figure out on my Vista machine running Apache 2.2 and PHP 5.2.3. I have sockets enabled, and all runs fine when I test it in the browsers (any of them). Main focus would just be socket_create for now. Now when I test this by command prompt (and of course using correct heading info #!/usr/bin/php -q), it gives a "Call to undefined function socket_create". So I looked further into this, just to make sure sockets were enabled, I used phpinfo() and sure enough its there. But when I run the same script by command prompt, everything is there except sockets. It just does not show up. Here is the test script I am using. if (($master = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) < 0) { echo "socket_create() failed, reason: " . socket_strerror($master) . "\n"; }else{ echo " socket_create() worked!!"; } As I said above, it works fine with a browser, but does not work by command prompt. Hope I can get some help thanks a lot! Quote Link to comment https://forums.phpfreaks.com/topic/54382-solved-sockets-enabled-but-not-in-command-prompt/ Share on other sites More sharing options...
btherl Posted June 6, 2007 Share Posted June 6, 2007 Two issues could be relevant here.. Often the command line and web PHP use different executables. Also, they often use different copies of php.ini So either one of those could cause the problem. I can't give you any more detailed help as I'm not too familiar with php on windows. Quote Link to comment https://forums.phpfreaks.com/topic/54382-solved-sockets-enabled-but-not-in-command-prompt/#findComment-268914 Share on other sites More sharing options...
obigraphics Posted June 6, 2007 Author Share Posted June 6, 2007 Yes that's exactly it. To solve that problem, just copy your php.ini file into the PHP folder. Thank you. Hopes this helps others. Quote Link to comment https://forums.phpfreaks.com/topic/54382-solved-sockets-enabled-but-not-in-command-prompt/#findComment-268919 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.