LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 11-23-2003, 08:28 PM   #1
lowpro2k3
Member
 
Registered: Oct 2003
Location: Canada
Distribution: Slackware
Posts: 340

Rep: Reputation: 30
Accessing MySQL from a PHP script (locally)


I just installed MySQL, Apache and PHP the way they installed it from "PHP - Fast and Easy Web Development" (kind of, RPM's didnt seem to work, so installing from source is what worked), i.e., For them to all work with each other (mostly just PHP needed additional parameters for configuration). MySQL works on its own, and I can access and parse my normal PHP scripts through Apache, but I used this code to try and access my MySQL database and it gave the error below:

PHP Code:
<?
$connection 
mysql_connect("localhost""root""mypassword") or die(mysql_error());

if (
$connection) {
    
$msg "it worked";
}

?>

<html>
<head>
<title>MySQL Connection</title>
</head>
<body>

<? echo "$msg"?>

</body>
</html>
I get the following error message, and I'm not too sure what to make of it: Warning: mysql_connect(): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in /usr/local/apache_1.3.29/htdocs/phpsql.php on line 2
Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)


Hopefully some people have gone through this before and can help me out a little here, it would be much appreciated, I'm sitting here scratching my head...

Thanks alot!



Last edited by lowpro2k3; 11-23-2003 at 08:29 PM.
 
Old 11-23-2003, 08:47 PM   #2
ugenn
Member
 
Registered: Apr 2002
Posts: 549

Rep: Reputation: 30
either one or more of the following...

1. MySQL daemon isn't running.
2. it's working but configured to listen on a non-default port
3. Password is wrong (did u initialise the database using mysql_install_db)?
 
Old 11-23-2003, 09:50 PM   #3
Doomhammer
Member
 
Registered: Oct 2003
Location: Montreal Qc, Canada
Posts: 102

Rep: Reputation: 15
have you setup the php.confing.inc file accordingly??
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Shell Script (with MySql) Tony Empire Programming 1 09-20-2005 09:59 AM
issues with mirc script accessing our php script dtra Linux - Software 2 07-02-2005 04:30 PM
MySQL Returning very strange Values in PHP Script benrose111488 Programming 2 10-21-2004 11:26 AM
Running a php script locally on SuSE 9.1 Personal ClarkNG Linux - Newbie 5 08-20-2004 02:55 PM
accessing mysql from apache/php vher Linux - General 4 01-21-2003 08:06 AM


All times are GMT -5. The time now is 10:10 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration