Jump to content

php script from command line - mysql_connect


glenelkins

Recommended Posts

Hi

 

I have XAMPP installed on my MAC. Which works perfectly fine. Though I need to run a script from the terminal.

 

So I perform the following command:

 

php -f /Volumes/Work\ HD/Projects/testProject/test.php

 

In test.php it has code to connect to a mysql database. Which works fine when I run the script through the browser. But in the shell I get an error along these lines:

 

Warning: mysql_connect(): [2002] No such file or directory (trying to connect via unix:///tmp/mysql.sock) in bla bla bla line 9

ok i got this worked out. i was loading up the mac version of php rather than the xampp one

 

do i need to keep the terminal window open for the script to execute or can I close it and leave it to do what is needed?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.