Re: [PHP] php cli and mysql



ok. so the location of mysql.sock is a problem.
I found it at /tmp/mysql.sock

Why is the CLI looking for it at /var/myslq/mysql.sock?

Now the question is...
Do I change the mysql settings so that mysql.sock is at /tmp/ mysql.sock? (If I do, will the PHP module with Apache still be ok?)
or
Do I change where the CLI is looking for mysql.sock?

-James

On Nov 14, 2006, at 1:17 PM, cajbecu wrote:

touch /var/mysql/mysql.sock
chmod 777 /var/mysql/mysql.sock

On 11/14/06, James Tu <jtu@xxxxxxxxxxxxx> 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



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


.



Relevant Pages

  • Re: how to write a bash script to do the following task?
    ... I'm new to bash script. ... on machine B. To set up a connection between SVR and CLI, ... After the connection is set up between A and B, the Client program will ...
    (comp.os.linux.misc)
  • Re: netatalk, NFS, OS X and backup
    ... Personally I use a combination of applescript and cli. ... With applescript you create a script that mounts the remote afp volume. ... Personally I put the mount command inside the try block to prevent error ...
    (freebsd-questions)
  • Re: [PHP] problems with exec()
    ... script to move some files around and the script works from the command line. ... Subject: problems with exec() ... PHP General Mailing List ... To unsubscribe, visit: http://www.php.net/unsub.php ...
    (php.general)
  • Re: [PHP] PHP debugger
    ... Ok, so I am going to try this one, Jason Pruim, let's check how it works ... ... In my whois web-app, when a EU doamin is queried, whois.pl perl script is lunched and I got the right result to my PHP script I the result is shown at the web. ... If I do the query to a ES domain, other whois.pl script is lunched, but passthru doesn't execute it. ... PHP General Mailing List ...
    (php.general)
  • Re: [PHP] problems with exec()
    ... But then again you say the 'whoami' command runs perfect. ... script to move some files around and the script works from the command ... PHP General Mailing List ...
    (php.general)