can not connect to Db?

Problems with the Mac OS X version of XAMPP, questions, comments, and anything related.

can not connect to Db?

Postby louie » 01. July 2009 08:34

I use Mac OSX 10.4.11 and set up XAMPP vsersion 1.0.1., set up new data base, table and id, username, email, password.
Now try to connect to Db but got message:
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: YES) in /Applications/XAMPP/xamppfiles/htdocs/connectmsql.php on line 7
Not connected : Access denied for user 'root'@'localhost' (using password: YES)

I noticed XAMPP on default Username: root
Password: No password
Are those for Db username and password?
can we change them for security reasons?

many thanks
louie
louie
 
Posts: 5
Joined: 01. July 2009 05:02
Location: SYDNEY

Re: can not connect to Db?

Postby caltuna » 01. July 2009 15:26

How are you trying to connect to the database? Via PHP? If so, set password to "".

You can change all of the passwords and usernames with phpMyAdmin under Priviledges. But be careful in doing so, and write down the changes you make.
caltuna
 
Posts: 111
Joined: 05. May 2009 16:35

Re: can not connect to Db?

Postby Dr. Strange » 01. July 2009 23:19

hey,

i've hade something similar, and i found that if i gave the phpMyAdmin a password, e.g. "pass", most errors will be fixed.
User avatar
Dr. Strange
 
Posts: 3
Joined: 01. July 2009 02:27

Re: can not connect to Db?

Postby louie » 02. July 2009 03:04

caltuna wrote:How are you trying to connect to the database? Via PHP? If so, set password to "".

You can change all of the passwords and usernames with phpMyAdmin under Priviledges. But be careful in doing so, and write down the changes you make.


yes, I use PHP trying to conncect to Db. I tried to change the PW and Username, more problems, end up reinstall XAMPP.
Thanks for the tips, I Set PW to "", looks like pass it? but message says:
Parse error: syntax error, unexpected T_STRING in /Applications/XAMPP/xamppfiles/htdocs/connectmysql.php on line 17

line 17 is:
$query="UPDATE game SET email='hopethisworks' WHERE username="louielu";

any idea how to fix this please?
louie
 
Posts: 5
Joined: 01. July 2009 05:02
Location: SYDNEY

Re: can not connect to Db?

Postby caltuna » 02. July 2009 04:22

louie wrote:
caltuna wrote:How are you trying to connect to the database? Via PHP? If so, set password to "".

You can change all of the passwords and usernames with phpMyAdmin under Priviledges. But be careful in doing so, and write down the changes you make.


yes, I use PHP trying to conncect to Db. I tried to change the PW and Username, more problems, end up reinstall XAMPP.
Thanks for the tips, I Set PW to "", looks like pass it? but message says:
Parse error: syntax error, unexpected T_STRING in /Applications/XAMPP/xamppfiles/htdocs/connectmysql.php on line 17

line 17 is:
$query="UPDATE game SET email='hopethisworks' WHERE username="louielu";

any idea how to fix this please?


I have no idea where all of this comes from but the line should look like:
$query="UPDATE game SET email='hopethisworks' WHERE username='louielu'";
caltuna
 
Posts: 111
Joined: 05. May 2009 16:35

Re: can not connect to Db?

Postby louie » 02. July 2009 04:36

caltuna wrote:
louie wrote:
caltuna wrote:How are you trying to connect to the database? Via PHP? If so, set password to "".

You can change all of the passwords and usernames with phpMyAdmin under Priviledges. But be careful in doing so, and write down the changes you make.


yes, I use PHP trying to conncect to Db. I tried to change the PW and Username, more problems, end up reinstall XAMPP.
Thanks for the tips, I Set PW to "", looks like pass it? but message says:
Parse error: syntax error, unexpected T_STRING in /Applications/XAMPP/xamppfiles/htdocs/connectmysql.php on line 17

line 17 is:
$query="UPDATE game SET email='hopethisworks' WHERE username="louielu";

any idea how to fix this please?


I have no idea where all of this comes from but the line should look like:
$query="UPDATE game SET email='hopethisworks' WHERE username='louielu'";


I updated:
$query="UPDATE game SET email='hopethisworks' WHERE username='louielu'";
but still got same message:
Parse error: syntax error, unexpected T_STRING in /Applications/XAMPP/xamppfiles/htdocs/connectmysql.php on line 17
louie
 
Posts: 5
Joined: 01. July 2009 05:02
Location: SYDNEY

Re: can not connect to Db?

Postby Nobbie » 02. July 2009 08:29

You should show us the full source, usually you forgot a semicolon, a closing bracket, a closing quote or similar in the line above.
Nobbie
 
Posts: 8759
Joined: 09. March 2008 13:04

Re: can not connect to Db?

Postby louie » 03. July 2009 01:33

Nobbie wrote:You should show us the full source, usually you forgot a semicolon, a closing bracket, a closing quote or similar in the line above.

database:
game

table:
louie

username:
louielu

password:
passwrod

my connectmysql.php file:

<?php

//open connect to mysql server
$dbc = mysql_connect ('localhost','root','');
if (!$dbc) {
die("Not connected : " . mysql_error());
}

//seclt Database

$db_seclected = mysql_select_db ( "game", sdbc);
if ('$db_seclected)
{
die ("cant connect : " . mysql_error ());

//test databse
$query="UPDATE game SET email='hopethisworks' WHERE username='louielu'";
$result= mysql_query ($query);

?>


Now got error for line:
$query="UPDATE game SET email='hopethisworks' WHERE username='louielu'";

message:
Parse error: syntax error, unexpected T_STRING in /Applications/XAMPP/xamppfiles/htdocs/connectmysql.php on line 17
louie
 
Posts: 5
Joined: 01. July 2009 05:02
Location: SYDNEY

Re: can not connect to Db?

Postby louie » 03. July 2009 03:32

My friend find out one apostrophe:
if ('$db_seclected)

should be
if ($db_seclected)

I update php file,now message:
Parse error: syntax error, unexpected $end in /Applications/XAMPP/xamppfiles/htdocs/connectmysql.php on line 20

line 20 is:
?>

any idea?
nearly done!
louie
 
Posts: 5
Joined: 01. July 2009 05:02
Location: SYDNEY

Re: can not connect to Db?

Postby caltuna » 04. July 2009 05:10

Code: Select all
if ('$db_seclected)
{
die ("cant connect : " . mysql_error ());

//test databse


put in a closing brace before // test database...

Code: Select all
if ('$db_seclected)
{
die ("cant connect : " . mysql_error ());
}
//test databse
caltuna
 
Posts: 111
Joined: 05. May 2009 16:35


Return to XAMPP for Mac OS X

Who is online

Users browsing this forum: No registered users and 5 guests