Jump to content
MakeWebGames

problems connecting to mysql


Raven1992

Recommended Posts

i try that i take that in the connect.php file the mysql db

Ok, you're using an engine which I don't have the files to but I presume that opens the connection. Did you get any errors whilst doing that, are you actually able to connect to the database?

Link to comment
Share on other sites

nope try what you did still got the same error i show u the connect.php script i got

without the die in

<?php

session_start();

$connect = mysql_connect("localhost", "gothcent_admin3", "shadow0ffear");
if($connect == TRUE) {
if(mysql_select_db("db") != TRUE) {
 exit("<span style='color: red'>Can't connect to the MySQL database. Please contact the webmaster.</body></html>");
}
}else{
exit("<span style='color: red'>Can't connect to the MySQL server. Please contact the webmaster.</body></html>");
}

?>

 

with the die in

<?php

session_start();

$connect = mysql_connect("localhost", "gothcent_admin3", "shadow0ffear");
if($connect == TRUE) {
if(mysql_select_db("db") != TRUE) {
 exit("<span style='color: red'>Can't connect to the MySQL database. Please contact the webmaster.</body></html>");
}
}else{
exit("<span style='color: red'>Can't connect to the MySQL server. Please contact the webmaster.</body></html>");
}
'die(mysql_error());'
?>
Link to comment
Share on other sites

You really are new to PHP aren't you?

Die() is a function, you can't enclose it in ' ' otherwise it is classed as a string.

It should be

die (mysql_error());

 

Try this, and a tip... don't include your password when posting on a public forum:

 

<?php

session_start();

$connect = mysql_connect("localhost", "gothcent_admin3", "shadow0ffear") or die (mysql_error());
if($connect == TRUE) {
if(mysql_select_db("db") != TRUE) {
 exit("<span style='color: red'>Can't connect to the MySQL database. Please contact the webmaster.</body></html>");
}
}else{
exit("<span style='color: red'>Can't connect to the MySQL server. Please contact the webmaster.</body></html>");
}
?>
Link to comment
Share on other sites

yeah i am basiclly

Have you tried the piece I sent, what did the errors say?

Not sure if it is the password, but is it supposed to be with a zero for 0F in shadow0ffear? It is suggesting a problem in connecting, so it could be that if it is a typo?

Link to comment
Share on other sites

You're not selecting your database by the looks of it?

I would just completely get rid of all your if statements, it shall connect or it won't so there isn't really a need to check it again. In your current code you're just checking whether it is true and not actually connecting to the database.

Link to comment
Share on other sites

So I take the username and pass out and try it that way

No, to connect just use this:

 

 mysql_connect ("localhost", "gothcent_admin3", "shadow0ffear") or die (mysql_error());
mysql_select_db ("db") or die (mysql_error()); 

 

And then don't bother with your if true and all that.

If you want personalised messages and what not, do this (changing the href to your page locations):

 

 mysql_connect ("localhost", "gothcent_admin3", "shadow0ffear") or die (Header ('Location: Errors/Connect.php'));
mysql_select_db ("db") or die  (Header ('Location: Errors/DB.php')); 
Link to comment
Share on other sites

ok now i got this type of problem

Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'gothcent_ganstercentral' (0) in /home/gothcent/public_html/ganstercentral/safe/connect.php on line 5

Unknown MySQL server host 'gothcent_ganstercentral' (0)

here the php script

 

<?php

session_start();

$connect = mysql_connect("gothcent_ganstercentral", "gothcent_admin3", "password") or die (mysql_error());
{
 exit("<span style='color: red'>Can't connect to the MySQL database. Please contact the webmaster.</body></html>");
}
{
exit("<span style='color: red'>Can't connect to the MySQL server. Please contact the webmaster.</body></html>");
}
?>
Link to comment
Share on other sites

ok now i got this type of problem

Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'gothcent_ganstercentral' (0) in /home/gothcent/public_html/ganstercentral/safe/connect.php on line 5

Unknown MySQL server host 'gothcent_ganstercentral' (0)

here the php script

 

<?php

session_start();

$connect = mysql_connect("gothcent_ganstercentral", "gothcent_admin3", "password") or die (mysql_error());
{
 exit("<span style='color: red'>Can't connect to the MySQL database. Please contact the webmaster.</body></html>");
}
{
exit("<span style='color: red'>Can't connect to the MySQL server. Please contact the webmaster.</body></html>");
}
?>

Try removing the pasword

Link to comment
Share on other sites

<?php

session_start();
$connect = mysql_connect('localhost', 'username', 'password');
if (!$connect) 
   exit ("<span style='color: red'>Can't connect to the MySQL database. Please contact the webmaster.</body></html>");

$dbselect = mysql_select_db('database_name', $connect);
if (!$dbselect)
   exit("<span style='color: red'>Can't connect to the MySQL server. Please contact the webmaster.</body></html>");
?>
Link to comment
Share on other sites

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'username'@'localhost' (using password: YES) in /home/gothcent/public_html/ganstercentral/safe/connect.php on line 4

Can't connect to the MySQL database. Please contact the webmaster.

is the message

Link to comment
Share on other sites

<?php

session_start();

$connect = mysql_connect("gothcent_ganstercentral", "gothcent_admin3", "password") or die (mysql_error());
{
 exit("<span style='color: red'>Can't connect to the MySQL database. Please contact the webmaster.</body></html>");
}
{
exit("<span style='color: red'>Can't connect to the MySQL server. Please contact the webmaster.</body></html>");
}
?>

What are you using this piece for?

Link to comment
Share on other sites

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'username'@'localhost' (using password: YES) in /home/gothcent/public_html/ganstercentral/safe/connect.php on line 4

Can't connect to the MySQL database. Please contact the webmaster.

is the message

Your username and password are incorrect.

Link to comment
Share on other sites

Cannot connect to mysql.

Would imply the following

Your username and/or password is incorrect

Your user is not allowed to access the database insufficient permissions

If you cannot do the real basics of php mysql dont worry im sure mcdonalds are probably hiring in your area.

Link to comment
Share on other sites

Cannot connect to mysql.

Would imply the following

Your username and/or password is incorrect

Your user is not allowed to access the database insufficient permissions

If you cannot do the real basics of php mysql dont worry im sure mcdonalds are probably hiring in your area.

get it right i work at pcworld

Link to comment
Share on other sites

get it right i work at pcworld

You really are an obnoxious, annoying person?

All we have done is try and help you, and you can't even be bothered to either show some gratitude or attempt to learn the language yourself.

Also, to work at PCWorld isn't exactly an achievement.

The chances are you are a sales assistant? Trained to sell the products, you don't need to know too much at computers to do it. You don't need to know anything about programming, and so your comment 'get it right' is either meaningless or a poor use of English because at the moment you're implying that RulerofZu is both wrong about your work placement and about the MySQL issue you're having.

Edited by Octet
Link to comment
Share on other sites

Just to make sure I downloaded the GL script installed on my server and it worked after setting up the database and using the correct details to connect to it.

So this is plain and simple user error due to lack of understanding of php and mysql and a failure to be able to follow advice.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...