RE: [PHP] PHP from the command line
jasper, what i meant to say is show us the code, as well as the output of the err msgs generated by the connection code. in some cases, the app runs as a different user when the code is run as the apache user or the 'command line' user. if you're going to try to figure out the issue/problem, you need to look at what might be the problem, and prioritize. from my experience: -might be running as a different user -might be some weird setup having to do with the host/port addresses -might be weird php.ini config settings.. -etc.. so rather than guess, let's get the guy's data/information and go from there. but all things remaning equal, i'm inclined to agree that the same code 'should' work. so, give us the data/output, and we'll see what it looks like. i'm also willing to bet that the issue will be something fairly simple/trivial to fix. -bruce -Original Message- From: Jasper Bryant-Greene [mailto:[EMAIL PROTECTED] Sent: Thursday, November 03, 2005 11:30 PM To: [EMAIL PROTECTED] Cc: 'Robbert van Andel'; 'David Tulloh'; php-general@lists.php.net Subject: RE: [PHP] PHP from the command line On Thu, 2005-11-03 at 20:58 -0800, bruce wrote: > ok.. > > show us the connection code you're using to access the db.. I think you're on the wrong track. The connection code is known good because it works in CLI mode. What I would like to see is any notable differences between the output of phpinfo() in CLI mode and through your webserver. Jasper > -Original Message- > From: Robbert van Andel [mailto:[EMAIL PROTECTED] > Sent: Thursday, November 03, 2005 8:37 PM > To: [EMAIL PROTECTED]; 'David Tulloh' > Cc: php-general@lists.php.net > Subject: RE: [PHP] PHP from the command line > > > From the web, all I get is that the connection failed. Nothing more useful > than that. PHP_INFO tells me that it sees the MS SQL ini file and the MS > SQL configuration settings are displayed further down the list. > > The username and password work in the script because I am able to connect > using the exact same script from the command line. > > -Original Message- > From: bruce [mailto:[EMAIL PROTECTED] > Sent: Thursday, November 03, 2005 7:28 PM > To: 'David Tulloh'; 'Robbert van Andel' > Cc: php-general@lists.php.net > Subject: RE: [PHP] PHP from the command line > > what's the error that you're getting from the web php app... > > also, what do you get from the php_info() for the web app? this tells you a > great deal of information regarding your php/web setup (if you didn't > already know!) > > get us the information and we can help track down your issue... > > also, is there a user/passwd setup to access the mssql db? > > -bruce > > > -Original Message- > From: David Tulloh [mailto:[EMAIL PROTECTED] > Sent: Thursday, November 03, 2005 6:22 PM > To: Robbert van Andel > Cc: php-general@lists.php.net > Subject: Re: [PHP] PHP from the command line > > > Many linux distributions use a different php config file for the apache > and cli versions. > Using two different configurations might explain the problems you are > seeing. > > David > > Robbert van Andel wrote: > > >I run a linux webserver with Apache and PHP5. Does anyone out there know > >why a php script would work from the command line but fail when running it > >through a web browser? In particular, I'm trying to get a connection to an > >MSSQL server but PHP fails to connect when I run the script with a web > >browser. My regular scripts (i.e. ones without any mssql functions) work > >fine from the browser. When I run the script from the command line, the > >connection succeeds. Any idea if this is a PHP error or an apache error. > If > >this is an apache error, does anyone know what I need to search for to find > >an answer? > > > > > > > >Thanks, > > > >Robbert van Andel > > > > > > > > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- Jasper Bryant-Greene General Manager Album Limited e: [EMAIL PROTECTED] w: http://www.album.co.nz/ b: http://jbg.name/ p: 0800 4 ALBUM (0800 425 286) or +64 21 232 3303 a: PO Box 579, Christchurch 8015, New Zealand -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP from the command line
On Thu, 2005-11-03 at 20:58 -0800, bruce wrote: > ok.. > > show us the connection code you're using to access the db.. I think you're on the wrong track. The connection code is known good because it works in CLI mode. What I would like to see is any notable differences between the output of phpinfo() in CLI mode and through your webserver. Jasper > -Original Message- > From: Robbert van Andel [mailto:[EMAIL PROTECTED] > Sent: Thursday, November 03, 2005 8:37 PM > To: [EMAIL PROTECTED]; 'David Tulloh' > Cc: php-general@lists.php.net > Subject: RE: [PHP] PHP from the command line > > > From the web, all I get is that the connection failed. Nothing more useful > than that. PHP_INFO tells me that it sees the MS SQL ini file and the MS > SQL configuration settings are displayed further down the list. > > The username and password work in the script because I am able to connect > using the exact same script from the command line. > > -Original Message- > From: bruce [mailto:[EMAIL PROTECTED] > Sent: Thursday, November 03, 2005 7:28 PM > To: 'David Tulloh'; 'Robbert van Andel' > Cc: php-general@lists.php.net > Subject: RE: [PHP] PHP from the command line > > what's the error that you're getting from the web php app... > > also, what do you get from the php_info() for the web app? this tells you a > great deal of information regarding your php/web setup (if you didn't > already know!) > > get us the information and we can help track down your issue... > > also, is there a user/passwd setup to access the mssql db? > > -bruce > > > -Original Message----- > From: David Tulloh [mailto:[EMAIL PROTECTED] > Sent: Thursday, November 03, 2005 6:22 PM > To: Robbert van Andel > Cc: php-general@lists.php.net > Subject: Re: [PHP] PHP from the command line > > > Many linux distributions use a different php config file for the apache > and cli versions. > Using two different configurations might explain the problems you are > seeing. > > David > > Robbert van Andel wrote: > > >I run a linux webserver with Apache and PHP5. Does anyone out there know > >why a php script would work from the command line but fail when running it > >through a web browser? In particular, I'm trying to get a connection to an > >MSSQL server but PHP fails to connect when I run the script with a web > >browser. My regular scripts (i.e. ones without any mssql functions) work > >fine from the browser. When I run the script from the command line, the > >connection succeeds. Any idea if this is a PHP error or an apache error. > If > >this is an apache error, does anyone know what I need to search for to find > >an answer? > > > > > > > >Thanks, > > > >Robbert van Andel > > > > > > > > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- Jasper Bryant-Greene General Manager Album Limited e: [EMAIL PROTECTED] w: http://www.album.co.nz/ b: http://jbg.name/ p: 0800 4 ALBUM (0800 425 286) or +64 21 232 3303 a: PO Box 579, Christchurch 8015, New Zealand -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP from the command line
ok.. show us the connection code you're using to access the db.. -bruce -Original Message- From: Robbert van Andel [mailto:[EMAIL PROTECTED] Sent: Thursday, November 03, 2005 8:37 PM To: [EMAIL PROTECTED]; 'David Tulloh' Cc: php-general@lists.php.net Subject: RE: [PHP] PHP from the command line >From the web, all I get is that the connection failed. Nothing more useful than that. PHP_INFO tells me that it sees the MS SQL ini file and the MS SQL configuration settings are displayed further down the list. The username and password work in the script because I am able to connect using the exact same script from the command line. -Original Message- From: bruce [mailto:[EMAIL PROTECTED] Sent: Thursday, November 03, 2005 7:28 PM To: 'David Tulloh'; 'Robbert van Andel' Cc: php-general@lists.php.net Subject: RE: [PHP] PHP from the command line what's the error that you're getting from the web php app... also, what do you get from the php_info() for the web app? this tells you a great deal of information regarding your php/web setup (if you didn't already know!) get us the information and we can help track down your issue... also, is there a user/passwd setup to access the mssql db? -bruce -Original Message- From: David Tulloh [mailto:[EMAIL PROTECTED] Sent: Thursday, November 03, 2005 6:22 PM To: Robbert van Andel Cc: php-general@lists.php.net Subject: Re: [PHP] PHP from the command line Many linux distributions use a different php config file for the apache and cli versions. Using two different configurations might explain the problems you are seeing. David Robbert van Andel wrote: >I run a linux webserver with Apache and PHP5. Does anyone out there know >why a php script would work from the command line but fail when running it >through a web browser? In particular, I'm trying to get a connection to an >MSSQL server but PHP fails to connect when I run the script with a web >browser. My regular scripts (i.e. ones without any mssql functions) work >fine from the browser. When I run the script from the command line, the >connection succeeds. Any idea if this is a PHP error or an apache error. If >this is an apache error, does anyone know what I need to search for to find >an answer? > > > >Thanks, > >Robbert van Andel > > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP from the command line
>From the web, all I get is that the connection failed. Nothing more useful than that. PHP_INFO tells me that it sees the MS SQL ini file and the MS SQL configuration settings are displayed further down the list. The username and password work in the script because I am able to connect using the exact same script from the command line. -Original Message- From: bruce [mailto:[EMAIL PROTECTED] Sent: Thursday, November 03, 2005 7:28 PM To: 'David Tulloh'; 'Robbert van Andel' Cc: php-general@lists.php.net Subject: RE: [PHP] PHP from the command line what's the error that you're getting from the web php app... also, what do you get from the php_info() for the web app? this tells you a great deal of information regarding your php/web setup (if you didn't already know!) get us the information and we can help track down your issue... also, is there a user/passwd setup to access the mssql db? -bruce -Original Message- From: David Tulloh [mailto:[EMAIL PROTECTED] Sent: Thursday, November 03, 2005 6:22 PM To: Robbert van Andel Cc: php-general@lists.php.net Subject: Re: [PHP] PHP from the command line Many linux distributions use a different php config file for the apache and cli versions. Using two different configurations might explain the problems you are seeing. David Robbert van Andel wrote: >I run a linux webserver with Apache and PHP5. Does anyone out there know >why a php script would work from the command line but fail when running it >through a web browser? In particular, I'm trying to get a connection to an >MSSQL server but PHP fails to connect when I run the script with a web >browser. My regular scripts (i.e. ones without any mssql functions) work >fine from the browser. When I run the script from the command line, the >connection succeeds. Any idea if this is a PHP error or an apache error. If >this is an apache error, does anyone know what I need to search for to find >an answer? > > > >Thanks, > >Robbert van Andel > > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP from the command line
what's the error that you're getting from the web php app... also, what do you get from the php_info() for the web app? this tells you a great deal of information regarding your php/web setup (if you didn't already know!) get us the information and we can help track down your issue... also, is there a user/passwd setup to access the mssql db? -bruce -Original Message- From: David Tulloh [mailto:[EMAIL PROTECTED] Sent: Thursday, November 03, 2005 6:22 PM To: Robbert van Andel Cc: php-general@lists.php.net Subject: Re: [PHP] PHP from the command line Many linux distributions use a different php config file for the apache and cli versions. Using two different configurations might explain the problems you are seeing. David Robbert van Andel wrote: >I run a linux webserver with Apache and PHP5. Does anyone out there know >why a php script would work from the command line but fail when running it >through a web browser? In particular, I'm trying to get a connection to an >MSSQL server but PHP fails to connect when I run the script with a web >browser. My regular scripts (i.e. ones without any mssql functions) work >fine from the browser. When I run the script from the command line, the >connection succeeds. Any idea if this is a PHP error or an apache error. If >this is an apache error, does anyone know what I need to search for to find >an answer? > > > >Thanks, > >Robbert van Andel > > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP from the command line
Many linux distributions use a different php config file for the apache and cli versions. Using two different configurations might explain the problems you are seeing. David Robbert van Andel wrote: I run a linux webserver with Apache and PHP5. Does anyone out there know why a php script would work from the command line but fail when running it through a web browser? In particular, I'm trying to get a connection to an MSSQL server but PHP fails to connect when I run the script with a web browser. My regular scripts (i.e. ones without any mssql functions) work fine from the browser. When I run the script from the command line, the connection succeeds. Any idea if this is a PHP error or an apache error. If this is an apache error, does anyone know what I need to search for to find an answer? Thanks, Robbert van Andel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP] PHP from the command line
Sorry, I failed to mention that I ran the command line script as the apache user. Robbert [EMAIL PROTECTED] wrote on 11/03/2005, 04:25:40 PM: > the most obvious is db permissions -- but you should be able to get php > to report a decent error so you know more precisely what the issue is. > > for the db permissions issue -- when you run the php script from the > command line it's running as "you", so the (default) connect to the db > will come from . when the same script is > run through the apache server the (default) connect will be from > . if the "apache user" doesn't have > access to the db (but "you" do) it will fail. > > > > > > Original Message > > Date: Thursday, November 03, 2005 06:59:30 AM -0800 > > From: Robbert van Andel > > To: php-general@lists.php.net > > Subject: [PHP] PHP from the command line > > > > I run a linux webserver with Apache and PHP5. Does anyone out there > > know why a php script would work from the command line but fail when > > running it through a web browser? In particular, I'm trying to get a > > connection to an MSSQL server but PHP fails to connect when I run the > > script with a web browser. My regular scripts (i.e. ones without any > > mssql functions) work fine from the browser. When I run the script > > from the command line, the connection succeeds. Any idea if this is a > > PHP error or an apache error. If this is an apache error, does anyone > > know what I need to search for to find an answer? > > > > > > > > Thanks, > > > > Robbert van Andel > > > > > > > > -- End Original Message -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php from the command line
> Simply put > > /usr/local/bin/php -q to the top of your script ... > i've written one a while ago an email roboter ... it works on command line But you realize you have to have command line php compiled first, right? Nathan Cook [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] php from the command line
Hi Simply put /usr/local/bin/php -q to the top of your script ... i've written one a while ago an email roboter ... it works on command line maybe u wanna check it out : http://linuks.net/robot.phps best regards attila strauss > > > Hi! > I was wondering how you could run php from the command line, and how it works! > Just out of curiosity =) > > Thanks > /Broder > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] php from the command line
It might be a good idea to check the list archives. http://marc.theaimsgroup.com/?l=php-general But since I am feeling nice today (assuming you want to do it on *nix). Then download and un-pack the source and run: # ./configure [... additional options here like MySQL etc...(make sure you don't put in the webserver)] # make # make install Then it will create a php executable in the /usr/local/bin/ dir. Run that like this: # php -f filename.php There is also another way to do it with magic lines I think something like this at the top of your _executable_ file #!/usr/local/bin/php ... Then just run your executable file like you would any other. Nathan Cook [EMAIL PROTECTED] - Original Message - From: "Jimmy Bäckström" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, September 25, 2001 10:21 AM Subject: [PHP] php from the command line Hi! I was wondering how you could run php from the command line, and how it works! Just out of curiosity =) Thanks /Broder -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]