Php runs differnt from a command line, b

software development

#1

I just found this, http://www.phpfreaks.com/phpmanual/page/features.commandline.html
which I think is relevant to the problem I was having in the thread below, where I can’t seem to get a script to find mysqli_connect when running the script from a command line. Apparently there is another SAPI type for PHP that is designed for running php from the command line. The CLI SAPI is available depending on the options used during the make of php. On dreamhost when I run php -v I only see cgi SAPI.

This signature line intentionally blank.


#2

Hey, I just noticed something else. phpinfo.php tells me that PHP 5.2.1 is what’s available to the webserver, while php -v tells me that PHP 4.4.4 (cgi) is what’s available at the command line. mysqli methods are only available with php 5, so that’s probably why my routines stopped when they hit any of the mysqli calls.

This signature line intentionally blank.


#3

$ whereis php
php: /etc/php /usr/local/bin/php /usr/local/lib/php
$ whereis php5
php5: /etc/php5 /usr/local/php5
$ whereis php4
php4:

$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games

Games?! :smiley:

----------
[color=#00CC00]ANONYMOUS0 => Max Discount[/color], [color=#6600CC]ANONYMOUS2 => Max Discount less $1[/color] or Cut the code, [color=#CC0000]it’s their birthday:[/color] [color=#00CC00]9999 => $99.99 Off[/color]


#4

Interesting, but I don’t seem to be able to run the script with the command line like: /etc/php5 ~/path/scriptname.php

Put /etc/php5 at the top of the script?

This signature line intentionally blank.


#5

Why are you trying to run php5 from the /etc (config file) directory? That’s not even a binary!

The actual location of the PHP5 binary should be here:
/usr/local/php5/bin/php


#6

You can also do /dh/cgi-system/php5.cgi
I don’t know why that works, but I remember that someone found it for me when I was having trouble running the maintenance scripts for my MediaWiki installation (which uses PHP5).

emufarmers.com
Very little to do with either emus or farmers!