mysql_connect command line problem

I posted this on the Database forum but perhaps this is the better place to ask.

I have shell access to a system as a regular user not admin/root.

I can write a php script to interrogate a MySQL database that works when it is called via Apache - ie from a browser.

If I issue the same script on the command line it chokes when trying to connect I get:

Fatal error: Call to undefined function: mysql_connect() in …

I want to cron the script, hence my interest in running it in command line plus I don’t really want to make it available via the web.

mysql ver 11.18 Distrib 3.23.58
php 4.1.2
httpd 1.3.27
RH Linux kernel 2.4.7 (pretty ancient I know).

Clues?

I’ve deleted your other post, please try to keep to a single post in a single forum.

I know it sounds odd, but you’ll get less attention by double posting :)

How exactly are you executing the php script from the command line are you running “php -q myscript.php” or are you using a different method?

I am just typing

php myscript.php

not bothering about the -q option

It’s odd that the web server can run mysql functions but not the command line version. It’s possible that the CLI version doesn’t have mysql compiled into it. These questions should really be asked of your hosting provider, since they have control over what functions you can/can’t run. I don’t have alot expirience with the CLI php stuff but tI think they started including it by default and it might not reflect any custom compiled in options, like MySQL client functions that are used for the apache module.

Sponsor our Newsletter | Privacy Policy | Terms of Service