MYSQL_Select_DB Error

jchilton

New Member
Messages
8
Reaction score
0
Points
0
I have read all of the forum messages for this issue but I cannot figure it out. I get the following error:

The error is Access denied for user 'jchilton_jchilto'@'localhost' to database 'jchilton_diabetes'

Here is the code:

<?php

// Connect the to Database
$con = mysql_connect("localhost","jchilton_jchilto","*********");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

// Select the Database
$db_select = mysql_select_db('jchilton_diabetes');
if (!$db_select)
{
die('The programmer who wrote this is an idiot because I could not connect to Database. The error is ' . mysql_error());
mysql_close ($con);
}

// Set the query
$result = mysql_query("SELECT * FROM `Readings`");

// This will print the data out line by line
$row = mysql_fetch_row($result);

$Date = $row[1];
$Time = $row[2];
$Reading = $row[3];
echo "<tr>";
echo "<td>$Date</td>";
echo "<td>$Time</td>";
echo "<td>$Reading</td>";
echo "</tr>";


// Close the connection to the database
mysql_close ($con);
?>



Thank you for the help,

Jeff Chilton
 

leafypiggy

Manager of Pens and Office Supplies
Staff member
Messages
3,819
Reaction score
163
Points
63
your password has a space in it. PHP cant parse a space in a password. use "_" or "%20"

if not, I can give you mine to fill in.
 

jchilton

New Member
Messages
8
Reaction score
0
Points
0
The password is not the issue in this case. I am able to connect to the MYSQL server just fine. I just can not connect to the database. I may have put a space in there by accident when I took out the password.

Jeff
 

jchilton

New Member
Messages
8
Reaction score
0
Points
0
No, that is not the issue I am having. I am able to connect to the server and have verified that is working by changing the password in the PHP code and I would get a connection to server error. Put the correct password in and I get a connection to database error.
 

wtvelocity

New Member
Messages
9
Reaction score
0
Points
0
Read the whole thing, the first problem was it not conencting. Now I got some other error, look at the second last post there.
 

leafypiggy

Manager of Pens and Office Supplies
Staff member
Messages
3,819
Reaction score
163
Points
63
sure SQL wasnt down? and check your passwords.
 

jchilton

New Member
Messages
8
Reaction score
0
Points
0
I found the issue to the error. I never assigned myself rights to the database. Once I did that the errors cleared up and everything is working fine.

Jeff
 
Top