Can't connect to MySQL server on 'localhost'

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
cat3rn
-


Joined: 19 May 2008
Posts: 20
Location: Gardnerville

PostPosted: Sat Apr 04, 2009 10:17 pm    Post subject: Can't connect to MySQL server on 'localhost' Reply with quote

Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on 'localhost' (10061) in C:\Program Files\Abyss Web Server\htdocs\util.php on line 16
Could not connect to database


This is the error I get when I try to use the website. The program I am using is Trax_RT System. It is a patient tracking php based system.

Any help appreciated.
Back to top View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
pkSML
-


Joined: 29 May 2006
Posts: 955
Location: Michigan, USA

PostPosted: Sun Apr 05, 2009 2:08 am    Post subject: Reply with quote

From what it looks like, the MySQL server is not running.

Try Ctrl+Alt+Del and see if mysqld.exe is listed in the processes tab. If not, check if it's a service by going to Start -> Run -> services.msc -- look for MySQL server to see if it's started.
_________________
Stephen
Need a LitlURL?


http://CodeBin.yi.org
Back to top View user's profile Send private message Visit poster's website
cat3rn
-


Joined: 19 May 2008
Posts: 20
Location: Gardnerville

PostPosted: Sun Apr 05, 2009 6:33 am    Post subject: Reply with quote

You know I probably have to install it first lol
Back to top View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
cat3rn
-


Joined: 19 May 2008
Posts: 20
Location: Gardnerville

PostPosted: Wed Apr 08, 2009 9:22 am    Post subject: Reply with quote

Ok it is installed and running same error.
Back to top View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
pkSML
-


Joined: 29 May 2006
Posts: 955
Location: Michigan, USA

PostPosted: Wed Apr 08, 2009 1:15 pm    Post subject: Reply with quote

It must be a simple mistake somewhere.

How do you know MySQL's running - is it in service mode or did you just run the executable? Is the error exactly the same? What is your code to make a database connection?
_________________
Stephen
Need a LitlURL?


http://CodeBin.yi.org
Back to top View user's profile Send private message Visit poster's website
cat3rn
-


Joined: 19 May 2008
Posts: 20
Location: Gardnerville

PostPosted: Wed Apr 08, 2009 5:58 pm    Post subject: Reply with quote

I checked in the services.msc and it is running.
What do you mean what code?
Back to top View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
pkSML
-


Joined: 29 May 2006
Posts: 955
Location: Michigan, USA

PostPosted: Wed Apr 08, 2009 6:01 pm    Post subject: Reply with quote

The PHP code used to connect to the DB.

Also, please paste again your error message given by the script.

If you're still having trouble, try stopping the service. Goto the installation folder and run mysqld.exe in the bin folder.
_________________
Stephen
Need a LitlURL?


http://CodeBin.yi.org
Back to top View user's profile Send private message Visit poster's website
cat3rn
-


Joined: 19 May 2008
Posts: 20
Location: Gardnerville

PostPosted: Thu Apr 09, 2009 9:02 pm    Post subject: Reply with quote

I am very new to this. I have read a few tutorials. The main website is in PHP downloaded from sourceforge for a free patient tracking system that we are going to use in the Emergency Room at the hospital.

Code:
http://ostatic.com/trax-rt


This is the error

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\Program Files\Abyss Web Server\htdocs\show_ER_patients.php on line 9
Can't connect to database server.

This is my PHP file

<?
/*--------- DATABASE CONNECTION INFO---------*/
$hostname="localhost";
$mysql_login="root";
$mysql_password="********";
$database="C:\Program Files\Abyss Web Server\htdocs\show_available_rooms.php";

// connect to the database server
if (!($db = mysql_connect($localhost, $mysql_root , $mysql_********))){
die("Can't connect to database server.");
}else{
// select a database
if (!(mysql_select_db("$database",$db))){
die("Can't connect to database.");
}
}
?>
<?
include 'util.php';
include "config.php";

echo "<html>";
echo "<head>";
echo "<META HTTP-EQUIV='PRAGMA' CONTENT='NO-CACHE'>";
echo "<META HTTP-EQUIV='CACHE-CONTROL' CONTENT='NO-CACHE'>";
echo "<META HTTP-EQUIV='Refresh' CONTENT='60'>";
echo "</head>";

echo "<body bgcolor='00CCFF' text='black' link='blue' vlink='blue'>";
echo "<b>Available Rooms</b>";

//foreach($_GET as $k => $v){echo "$k => $v <br> ";}
$er_select = $_GET[er_select];

$areas = array();
connect("trax_test");

if(!$er_select) {$er_select = "All";}

if($er_select != "All")
{
$area = $er_select;
make_available_room_list($area);
}

else
{
$result = mysql_query("SELECT * FROM AREAS");
while($row=mysql_fetch_array($result)) {array_push($areas, $row[NAME]);}

foreach($areas as $area)
{
make_available_room_list($area);
}
}

function make_available_room_list($area)
{
$fixed_area = str_replace("_", " ", $area);
$sql = "SELECT NAME FROM ROOMS
WHERE ER_TYPE='$area'
AND (STATUS IS NULL OR STATUS = '')
ORDER BY NAME";

$result = mysql_query($sql);

echo "<center><table border='1' width='70%'>
<CAPTION> $fixed_area </CAPTION>
<tr><td>"; // <ul compact>
//";

while ($row=mysql_fetch_array($result))
{
//echo " <li> $row[NAME] </li> ";
echo "$row[NAME] <br>";
}
echo "</ul> </td></tr></table></center><p>";
}


print "</TABLE>";

echo "</body>";
echo "<head>";
echo "<META HTTP-EQUIV='PRAGMA' CONTENT='NO-CACHE'>";
echo "<META HTTP-EQUIV='CACHE-CONTROL' CONTENT='NO-CACHE'>";
echo "<META HTTP-EQUIV='Refresh' CONTENT='60'>";
echo "</head>";
echo "</html>";

?>


Code:
Back to top View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
roganty
-


Joined: 08 Jun 2004
Posts: 357
Location: Bristol, UK

PostPosted: Fri Apr 10, 2009 9:42 pm    Post subject: Reply with quote

Correct me if I am wrong, but isn't the line
Code:
if (!($db = mysql_connect($localhost, $mysql_root , $mysql_********))){

supposed to read:
Code:
if (!($db = mysql_connect($localhost, $mysql_login , $mysql_password))){


The only part of the file you are supposed to edit is:
Code:
/*--------- DATABASE CONNECTION INFO---------*/
$hostname="localhost";
$mysql_login="root";
$mysql_password="********";
$database="C:\Program Files\Abyss Web Server\htdocs\show_available_rooms.php";


Also the value for $database should be the name of the database in mysql
_________________
Anthony R

Roganty
| Links-Links.co.uk
Back to top View user's profile Send private message Visit poster's website
cat3rn
-


Joined: 19 May 2008
Posts: 20
Location: Gardnerville

PostPosted: Sat Apr 11, 2009 7:19 am    Post subject: I dont know if I even have a database Reply with quote

I dont know if I even have a database as I have not put any patients in an ER list.

The program is TRAX_RT found here

Code:
http://ostatic.com/trax-rt


Can someone download the program and develop a database

Here is a screenshot of the program.

I am also using my own computer as the server using Abyss Web Server X2

[img]http://farm4.static.flickr.com/3363/3430271457_4a4e608193.jpg?v=0[/img]
Back to top View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
pkSML
-


Joined: 29 May 2006
Posts: 955
Location: Michigan, USA

PostPosted: Sat Apr 11, 2009 2:12 pm    Post subject: Reply with quote

Roganty is right. The reason you're getting the "using password: no" error is because the mysql_connect command isn't receiving any text for the password.

You can also try just changing this line:

Code:
if (!($db = mysql_connect($localhost, $mysql_root , $mysql_********))){

to this:

Quote:
if (!($db = mysql_connect($localhost, $mysql_root , mysql_password_here))){


Then you won't get that error. If you get a different error, post it on the forum.
_________________
Stephen
Need a LitlURL?


http://CodeBin.yi.org
Back to top View user's profile Send private message Visit poster's website
cat3rn
-


Joined: 19 May 2008
Posts: 20
Location: Gardnerville

PostPosted: Sat Apr 11, 2009 7:50 pm    Post subject: Reply with quote

I just used the ****** because I didn't want to show my password.
Back to top View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
pkSML
-


Joined: 29 May 2006
Posts: 955
Location: Michigan, USA

PostPosted: Sat Apr 11, 2009 8:22 pm    Post subject: Reply with quote

What we're saying is that your password shouldn't even be on this line:
Code:
if (!($db = mysql_connect($localhost, $mysql_root , $mysql_********))){

Change this line back to this:
Code:
if (!($db = mysql_connect($localhost, $mysql_root , $mysql_password))){

Only put your password in on this line:
Code:
$mysql_password="********";


Try that and tell us what errors you get, if any.
_________________
Stephen
Need a LitlURL?


http://CodeBin.yi.org
Back to top View user's profile Send private message Visit poster's website
roganty
-


Joined: 08 Jun 2004
Posts: 357
Location: Bristol, UK

PostPosted: Sat Apr 11, 2009 8:26 pm    Post subject: Reply with quote

Edit: Damn! pkSML got there 1st! Lol!

cat3rn wrote:
I just used the ****** because I didn't want to show my password.


Your not meant to edit that line anyway! Its supposed to read:

Code:
if (!($db = mysql_connect($localhost, $mysql_login , $mysql_password))){

_________________
Anthony R

Roganty
| Links-Links.co.uk
Back to top View user's profile Send private message Visit poster's website
cat3rn
-


Joined: 19 May 2008
Posts: 20
Location: Gardnerville

PostPosted: Sun Apr 12, 2009 12:05 am    Post subject: Reply with quote

Code:
http://farm4.static.flickr.com/3331/3432187781_845885037b.jpg?v=0


Code:
http://farm4.static.flickr.com/3378/3432187715_6a9c8c9c4c.jpg?v=0


Code:
http://farm4.static.flickr.com/3544/3432187645_579c2d9e5d.jpg?v=0


Now at least I got past the "start service" part on mysql. I also tried it with zone alarm off and got the same errors

Pictures of errors above
Back to top View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
roganty
-


Joined: 08 Jun 2004
Posts: 357
Location: Bristol, UK

PostPosted: Sun Apr 12, 2009 8:29 pm    Post subject: Reply with quote

I have managed to get Trax RT installed and running!
The version I have running is 042405, what version do you have?

Of course, until you have the database running, then you are not able to run the program!
_________________
Anthony R

Roganty
| Links-Links.co.uk
Back to top View user's profile Send private message Visit poster's website
cat3rn
-


Joined: 19 May 2008
Posts: 20
Location: Gardnerville

PostPosted: Sun Apr 12, 2009 11:47 pm    Post subject: Reply with quote

I downloaded it from the above link posted earlier. Not sure which version it is because I cant get it running. The site has not been updated in a while so we should have the same version.

How did you get it running?
Back to top View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
roganty
-


Joined: 08 Jun 2004
Posts: 357
Location: Bristol, UK

PostPosted: Mon Apr 13, 2009 11:03 am    Post subject: Reply with quote

cat3rn wrote:
I downloaded it from the above link posted earlier. Not sure which version it is because I cant get it running. The site has not been updated in a while so we should have the same version.

How did you get it running?


I extracted the zip file into htdocs/trax_rt

I then edited the file config.php and changed the following line:
Code:
$doc_root = "trax";
to
Code:
$doc_root = "trax_rt";

This is the folder that I extracted the zip file to. If you didn't put it in a subfolder then the value of $doc_root would be blank eg
Code:
$doc_root = "";


Then in MySQL I created a new database called trax you can call it what you like but you will need to change the value of $database in config.php to match.

Now you will have to use the file trax_database_04_25_05.sql to create the necessary table in the database you have just created.

In the file util.php you will have to change the user name and password to match the user name and password you use to connect to MySQL.
Code:
$sucess=mysql_connect("localhost","jake","mysql")


That should be everything!
_________________
Anthony R

Roganty
| Links-Links.co.uk
Back to top View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group