View Single Post

   
  #4 (permalink)  
Old 02-28-2008, 10:06 AM
Jerry Stuckle
 
Posts: n/a
Default Re: [newbie] not a very auspicious start

desmond wrote:
> Hi
> my initial forays into MySQL and PhP aren't going well, and I think
> well if I'm stumped _this_ early in the game...
>
> I use the following file on my webserver, which I've named 'test.php'..
>
> <?php
>
> $dbhost='localhost';
> $dbname='mydb';
> $dubuser='user';
> $dbpass='GTEGF65';
>
> $conn = mysql_connect($dbhost, $dubuser, $dbpass)
> or die ('Cannot connect to DB!!');
> ?>
>
> The result when I load that?
>
> Warning: mysql_connect() [function.mysql-connect]: Can't connect to local
> MySQL server through socket '/var/mysql/mysql.sock' (2) in
> /usr/local/www/data/.php/test.php on line 8
> Cannot connect to DB!!
>
> The paths etc. have been changed, of course.
>
> Now if I do ...
>
> % mysql -A -u user mydb -pGTEGF65
>
> ... I get...
>
> Welcome to the MySQL monitor. Commands end with ; or \g.
> Your MySQL connection id is 22
> Server version: 5.0.41 MySQL Community Server (GPL)
>
> Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
>
> mysql>
>
> In other words, it works. So why can't I connect from within a php file?
> The password is _identical_ (I even copied and pasted it to make sure).
> This is annoying .. is there a typo that I can't see, or is it something,
> like some sort of 'rite of passage' that all newbies have to go through??
>
> Help !!
>
> D.


Do you actually have your mysql socket at /var/mysql/mysql.sock? If
not, where is it?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Reply With Quote