Re: [PHP] I'm prepared to feel like an idiot... But I just simply need the answer :)

2007-08-07 Thread Richard Lynch
On Wed, August 1, 2007 7:49 am, Jason Pruim wrote:
 I have a php script that I am attempting to run from the CLI to
 connect to a MySQL database and update a field. but when I run it
 with this command: php cronjob.php it prints out the script on screen
 but doesn't process it...

 Running: php-rphpinfo(); prints out the standard phpinfo screen..
 and I don't think I should have to write it differently to make it
 run from the command line right?

 HELP! I'm desperate... I would offer to name my first born after
 you... But he's already been born :)

#1
Can you copy/paste the exact command from crontab -l without the
first 5 when fields into a shell and have it work?

#2
cron doesn't run in your normal shell with all the $PATH stuff.
Use a full and complete path from / for every program and every file
in cron jobs.
/usr/local/bin/php /home/pruim/cronjob.php
Also change any code inside of cronjob.php to use a FULL PATH to
anything.
You can never go wrong specifying the full path, unless the path
itself is wrong.
You start making assumptions in your code about cwd and all hell
breaks loose, sooner or later.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] I'm prepared to feel like an idiot... But I just simply need the answer :)

2007-08-01 Thread Brad Bonkoski
I would start with suppling the entire path of for php in the cron.  The 
path in the cron environment may be vastly different then the path in 
your shell environment...

so: /path/to/php file.php
See how that works for you, of course I am assuming it runs fine from 
your command line...

-B

Jason Pruim wrote:

Hi All :)

I have a php script that I am attempting to run from the CLI to 
connect to a MySQL database and update a field. but when I run it with 
this command: php cronjob.php it prints out the script on screen but 
doesn't process it...


Running: php-rphpinfo(); prints out the standard phpinfo screen.. 
and I don't think I should have to write it differently to make it run 
from the command line right?


HELP! I'm desperate... I would offer to name my first born after 
you... But he's already been born :)



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] I'm prepared to feel like an idiot... But I just simply need the answer :)

2007-08-01 Thread Bastien Koert

I have had success in running CLI php pages from a bat file fired via a 
scheduled task. Since the output can be limited I would suggest adding some 
logging functionality to the page to trap errors and write them to a file that 
you can use to analyze any issues.
 
bastien To: php-general@lists.php.net From: [EMAIL PROTECTED] Date: Wed, 1 
Aug 2007 08:49:34 -0400 Subject: [PHP] I'm prepared to feel like an idiot... 
But I just simply need the answer :)  Hi All :)  I have a php script that I 
am attempting to run from the CLI to  connect to a MySQL database and update a 
field. but when I run it  with this command: php cronjob.php it prints out the 
script on screen  but doesn't process it...  Running: php-rphpinfo(); 
prints out the standard phpinfo screen..  and I don't think I should have to 
write it differently to make it  run from the command line right?  HELP! I'm 
desperate... I would offer to name my first born after  you... But he's 
already been born :)   --  Jason Pruim Raoset Inc. Technology Manager 
MQC Specialist 3251 132nd ave Holland, MI, 49424 www.raoset.com [EMAIL 
PROTECTED]  
_
Discover the new Windows Vista
http://search.msn.com/results.aspx?q=windows+vistamkt=en-USform=QBRE

Re: [PHP] I'm prepared to feel like an idiot... But I just simply need the answer :)

2007-08-01 Thread Daniel Brown
On 8/1/07, Jason Pruim [EMAIL PROTECTED] wrote:
 cannot connect to DB!Can't connect to local MySQL server through
 socket '/var/mysql/mysql.sock' (2)qs:/volumes/raider/webserver/
 documents/tests/ticklers japruim$


 This is only from the commandline... running the script straight in a
 browser doesn't show any errors... and it works just fine.

When running via the web, is it being included in another file?
Make sure that from the command line, it's either self-sufficient
(with the username/password combination hard-coded) or has any
necessary information parsed through included files.

-- 
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] I'm prepared to feel like an idiot... But I just simply need the answer :)

2007-08-01 Thread Michael Preslar
 @mysql_connect('localhost', 'user', 'password') or die(Cannot
 connect to DB! . mysql_error());
..
 cannot connect to DB!Can't connect to local MySQL server through
 socket '/var/mysql/mysql.sock' (2)qs:/volumes/raider/webserver/
 documents/tests/ticklers japruim$

MySQL is running right? (I know, silly question, but have to make sure)

If it is.. grep sock /etc/my.ini .. Bet the socket file its creating
is in /tmp or /var/lib/mysql

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] I'm prepared to feel like an idiot... But I just simply need the answer :)

2007-08-01 Thread Thijs Lensselink
On Wed, 1 Aug 2007 08:49:34 -0400, Jason Pruim [EMAIL PROTECTED] wrote:
 Hi All :)
 
 I have a php script that I am attempting to run from the CLI to
 connect to a MySQL database and update a field. but when I run it
 with this command: php cronjob.php it prints out the script on screen
 but doesn't process it...
 
 Running: php-rphpinfo(); prints out the standard phpinfo screen..
 and I don't think I should have to write it differently to make it
 run from the command line right?
 
 HELP! I'm desperate... I would offer to name my first born after
 you... But he's already been born :)
 
 
 --
 
 Jason Pruim
 Raoset Inc.
 Technology Manager
 MQC Specialist
 3251 132nd ave
 Holland, MI, 49424
 www.raoset.com
 [EMAIL PROTECTED]
 
 
 
 

Maybe you can show use some code?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] I'm prepared to feel like an idiot... But I just simply need the answer :)

2007-08-01 Thread Jason Pruim


On Aug 1, 2007, at 8:55 AM, Brad Bonkoski wrote:

I would start with suppling the entire path of for php in the  
cron.  The path in the cron environment may be vastly different  
then the path in your shell environment...

so: /path/to/php file.php
See how that works for you, of course I am assuming it runs fine  
from your command line...

-B


Actually I haven't gotten to the point of setting it up on the cron,  
I can't get it to run the php script from the cli.. thought I should  
test that first :)


Once that works I'll add it to the cron :)





Jason Pruim wrote:

Hi All :)

I have a php script that I am attempting to run from the CLI to  
connect to a MySQL database and update a field. but when I run it  
with this command: php cronjob.php it prints out the script on  
screen but doesn't process it...


Running: php-rphpinfo(); prints out the standard phpinfo  
screen.. and I don't think I should have to write it differently  
to make it run from the command line right?


HELP! I'm desperate... I would offer to name my first born after  
you... But he's already been born :)



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] I'm prepared to feel like an idiot... But I just simply need the answer :)

2007-08-01 Thread Jason Pruim


On Aug 1, 2007, at 9:37 AM, Thijs Lensselink wrote:

On Wed, 1 Aug 2007 08:49:34 -0400, Jason Pruim [EMAIL PROTECTED]  
wrote:

Hi All :)

I have a php script that I am attempting to run from the CLI to
connect to a MySQL database and update a field. but when I run it
with this command: php cronjob.php it prints out the script on screen
but doesn't process it...

Running: php-rphpinfo(); prints out the standard phpinfo screen..
and I don't think I should have to write it differently to make it
run from the command line right?

HELP! I'm desperate... I would offer to name my first born after
you... But he's already been born :)


--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]






Maybe you can show use some code?


@mysql_connect('localhost', 'user', 'password') or die(Cannot  
connect to DB! . mysql_error());
@mysql_select_db('ticklers') or die(Cannot select DB! . mysql_error 
());



$sql=UPDATE tasks SET completed='0';
mysql_query($sql);

also when looking at the code, I noticed that I didn't have the  
opening and closing php tags ... Now I do and I'm getting an error :)


cannot connect to DB!Can't connect to local MySQL server through  
socket '/var/mysql/mysql.sock' (2)qs:/volumes/raider/webserver/ 
documents/tests/ticklers japruim$



This is only from the commandline... running the script straight in a  
browser doesn't show any errors... and it works just fine.



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] I'm prepared to feel like an idiot... But I just simply need the answer :)

2007-08-01 Thread Daniel Brown
On 8/1/07, Thijs Lensselink [EMAIL PROTECTED] wrote:
 On Wed, 1 Aug 2007 08:49:34 -0400, Jason Pruim [EMAIL PROTECTED] wrote:
  Hi All :)
 
  I have a php script that I am attempting to run from the CLI to
  connect to a MySQL database and update a field. but when I run it
  with this command: php cronjob.php it prints out the script on screen
  but doesn't process it...
 
  Running: php-rphpinfo(); prints out the standard phpinfo screen..
  and I don't think I should have to write it differently to make it
  run from the command line right?
 
  HELP! I'm desperate... I would offer to name my first born after
  you... But he's already been born :)
 
 
  --
 
  Jason Pruim
  Raoset Inc.
  Technology Manager
  MQC Specialist
  3251 132nd ave
  Holland, MI, 49424
  www.raoset.com
  [EMAIL PROTECTED]
 
 
 
 

 Maybe you can show use some code?

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



Since it's being run as a cron, that indicates that it's a
*nix-like machine, so .bat files are out of the question, but you're
on the right track, Bastien.

Jason, try creating a file like this, chmod'ing it to 0755, and
running it with the full path as follows:

[EMAIL PROTECTED] dir]$ pwd
/path/to/dir
[EMAIL PROTECTED] dir]$ /path/to/dir/file

Provided the file is named `file` and is in the same directory as
the PHP script you want to run as a cron, it should run just fine with
this code:

#!/bin/bash
phppath=`which php`

# pwd can be changed to a hard-coded directory if
# the PHP file isn't in the same directory as this script.
# However, make sure not to use the tickmarks (below
#the tilde (~), but instead use single quotes.
pwd=`pwd`

# Change phpfile.php to whatever the actual name of the PHP file is.
$phppath $pwd/phpfile.php  /dev/null 21


If that doesn't work, post the code from your PHP file and we can
all take a look.

-- 
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] I'm prepared to feel like an idiot... But I just simply need the answer :)

2007-08-01 Thread Stut

Jason Pruim wrote:
I have a php script that I am attempting to run from the CLI to connect 
to a MySQL database and update a field. but when I run it with this 
command: php cronjob.php it prints out the script on screen but doesn't 
process it...


Running: php-rphpinfo(); prints out the standard phpinfo screen.. and 
I don't think I should have to write it differently to make it run from 
the command line right?


Sounds like you're not using ?php and ? tags to surround your code. 
Without those PHP will simply output the content of the file rather than 
running it.


-Stut

--
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] I'm prepared to feel like an idiot... But I just simply need the answer :)

2007-08-01 Thread Jason Pruim


On Aug 1, 2007, at 9:55 AM, Michael Preslar wrote:


@mysql_connect('localhost', 'user', 'password') or die(Cannot
connect to DB! . mysql_error());

..

cannot connect to DB!Can't connect to local MySQL server through
socket '/var/mysql/mysql.sock' (2)qs:/volumes/raider/webserver/
documents/tests/ticklers japruim$


MySQL is running right? (I know, silly question, but have to make  
sure)


If it is.. grep sock /etc/my.ini .. Bet the socket file its creating
is in /tmp or /var/lib/mysql


Okay, so the command didn't work.. couldn't find my.ini... But I just  
cd'ed into /tmp and there is a file mysql.sock in there... Do I need  
to move that somewhere else? I realize that this is starting to get  
off topic for this list... So Maybe I should take this to a mysql  
list since it looks like php isn't at fault?




--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] I'm prepared to feel like an idiot... But I just simply need the answer :)

2007-08-01 Thread Jason Pruim


On Aug 1, 2007, at 9:53 AM, Daniel Brown wrote:


On 8/1/07, Jason Pruim [EMAIL PROTECTED] wrote:

cannot connect to DB!Can't connect to local MySQL server through
socket '/var/mysql/mysql.sock' (2)qs:/volumes/raider/webserver/
documents/tests/ticklers japruim$


This is only from the commandline... running the script straight in a
browser doesn't show any errors... and it works just fine.


When running via the web, is it being included in another file?
Make sure that from the command line, it's either self-sufficient
(with the username/password combination hard-coded) or has any
necessary information parsed through included files.



Hey Dan,

All the info is hardcoded into the php file, no includes on this one...

--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] I'm prepared to feel like an idiot... But I just simply need the answer :)

2007-08-01 Thread Jason Pruim


On Aug 1, 2007, at 9:55 AM, Stut wrote:


Jason Pruim wrote:
I have a php script that I am attempting to run from the CLI to  
connect to a MySQL database and update a field. but when I run it  
with this command: php cronjob.php it prints out the script on  
screen but doesn't process it...
Running: php-rphpinfo(); prints out the standard phpinfo  
screen.. and I don't think I should have to write it differently  
to make it run from the command line right?


Sounds like you're not using ?php and ? tags to surround your  
code. Without those PHP will simply output the content of the file  
rather than running it.


-Stut


Hey Stut,

Yeah that was the result of the first issue which led to the  
second... Newbie mistake I guess... :) Thanks for looking!


--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] I'm prepared to feel like an idiot... But I just simply need the answer :)

2007-08-01 Thread Brad Bonkoski

Brad Bonkoski wrote:

Jason Pruim wrote:


On Aug 1, 2007, at 9:55 AM, Michael Preslar wrote:


@mysql_connect('localhost', 'user', 'password') or die(Cannot
connect to DB! . mysql_error());

..

cannot connect to DB!Can't connect to local MySQL server through
socket '/var/mysql/mysql.sock' (2)qs:/volumes/raider/webserver/
documents/tests/ticklers japruim$


MySQL is running right? (I know, silly question, but have to make sure)

If it is.. grep sock /etc/my.ini .. Bet the socket file its creating
is in /tmp or /var/lib/mysql


Okay, so the command didn't work.. couldn't find my.ini... But I just 
cd'ed into /tmp and there is a file mysql.sock in there... Do I need 
to move that somewhere else? I realize that this is starting to get 
off topic for this list... So Maybe I should take this to a mysql 
list since it looks like php isn't at fault?



I *think* the mysql config file is named: my.cnf
so run a slocate or find on your system to see where it is and look at 
the line:
socket  = 
/var/run/mysqld/mysqld.sock


You can also go into your php.ini file and check out the line:
mysql.default_socket =
and perhaps setting that to where it is located in your /tmp directory 
will do the trick...


-B


As a quick follow up...
the command:
$ php -i | grep mysql

will spit out info on how php thinks mysql is set up currently...
one of the items is:
MYSQL_SOCKET = ...
So just make sure that is in tune with where the socket really is running
-B



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]

--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] I'm prepared to feel like an idiot... But I just simply need the answer :)

2007-08-01 Thread Brad Bonkoski

Jason Pruim wrote:


On Aug 1, 2007, at 9:55 AM, Michael Preslar wrote:


@mysql_connect('localhost', 'user', 'password') or die(Cannot
connect to DB! . mysql_error());

..

cannot connect to DB!Can't connect to local MySQL server through
socket '/var/mysql/mysql.sock' (2)qs:/volumes/raider/webserver/
documents/tests/ticklers japruim$


MySQL is running right? (I know, silly question, but have to make sure)

If it is.. grep sock /etc/my.ini .. Bet the socket file its creating
is in /tmp or /var/lib/mysql


Okay, so the command didn't work.. couldn't find my.ini... But I just 
cd'ed into /tmp and there is a file mysql.sock in there... Do I need 
to move that somewhere else? I realize that this is starting to get 
off topic for this list... So Maybe I should take this to a mysql list 
since it looks like php isn't at fault?



I *think* the mysql config file is named: my.cnf
so run a slocate or find on your system to see where it is and look at 
the line:
socket  = 
/var/run/mysqld/mysqld.sock


You can also go into your php.ini file and check out the line:
mysql.default_socket =
and perhaps setting that to where it is located in your /tmp directory 
will do the trick...


-B




--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]

--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] I'm prepared to feel like an idiot... But I just simply need the answer :)

2007-08-01 Thread Daniel Brown
On 8/1/07, Jason Pruim [EMAIL PROTECTED] wrote:

 On Aug 1, 2007, at 9:55 AM, Michael Preslar wrote:

  @mysql_connect('localhost', 'user', 'password') or die(Cannot
  connect to DB! . mysql_error());
  ..
  cannot connect to DB!Can't connect to local MySQL server through
  socket '/var/mysql/mysql.sock' (2)qs:/volumes/raider/webserver/
  documents/tests/ticklers japruim$
 
  MySQL is running right? (I know, silly question, but have to make
  sure)
 
  If it is.. grep sock /etc/my.ini .. Bet the socket file its creating
  is in /tmp or /var/lib/mysql

 Okay, so the command didn't work.. couldn't find my.ini... But I just
 cd'ed into /tmp and there is a file mysql.sock in there... Do I need
 to move that somewhere else? I realize that this is starting to get
 off topic for this list... So Maybe I should take this to a mysql
 list since it looks like php isn't at fault?



 --

 Jason Pruim
 Raoset Inc.
 Technology Manager
 MQC Specialist
 3251 132nd ave
 Holland, MI, 49424
 www.raoset.com
 [EMAIL PROTECTED]

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



The cheapest fix, if you have root access, is just to symlink it like so:

ln -s /tmp/mysql.sock /var/mysql/mysql.sock

It'll at least get it running, but PHP should be set to look for
the MySQL socket in the right place via both the CLI and the Apache
module.

-- 
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] I'm prepared to feel like an idiot... But I just simply need the answer :)

2007-08-01 Thread Jason Pruim
Okay, Now I got it figured out, it was a problem with php cli not  
being able to find the mysql.sock file. I didn't realize that there  
are 2 php.ini files, one for the web and the other for the CLI...  
I'll look into what needs to be changed in the php.ini file... For  
right now I took Dan's advice and symlinked it to get it up and running.


Thanks for the help!


--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] I'm prepared to feel like an idiot... But I just simply need the answer :)

2007-08-01 Thread Sancar Saran
On Wednesday 01 August 2007 17:46:44 Brad Bonkoski wrote:
Hi,
Please Check php.ini of cli. They are different. Maybe there where problem in 
php.ini 

Regards

Sancar

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php