Re: php cli and mysql
| From: | cajbecu | Date: | Tue, 14 Nov 2006 18:17:16 +0000 |
| Subject: | Re: php cli and mysql | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-244605@lists.php.net to get a copy of this message | ||
touch /var/mysql/mysql.sock
chmod 777 /var/mysql/mysql.sock
On 11/14/06, James Tu <jtu@esidesign.com> wrote:
I'm running a php script from the command line (I'm on OS X) and I'm getting ... Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2) Here's the script (this just tests a connection and a query...the actual script imports data from text files): #!/usr/bin/php <?php echo "HELLO WORLD\n"; $connection = mysql_connect(HOST, ID, PW); mysql_select_db(DB, $connection); $result = mysql_query("SELECT COUNT(*) as num_of_countries from geo_entities"); $row = mysql_fetch_array($result); print_r($row); ?> I tested the script from a browser and the connection and query worked. Do I have to do something special in order for PHP CLI to connect to MySQL? -James -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php