Raven1992 Posted July 30, 2012 Posted July 30, 2012 hey i done all the stuff and when i try to install it all it says can't connect to mysql database any tips on how to fix this there is a database in there i did made one with the user and pass so any help would be nice thanks tom Quote
Octet Posted July 30, 2012 Posted July 30, 2012 Is this when connecting through a script? If so, check your 'mysql_connect' and 'mysql_select_db' parts. If you have the correct information then do a 'die(mysql_error());' and post what it says. Quote
Raven1992 Posted July 30, 2012 Author Posted July 30, 2012 (edited) i try that i take that in the connect.php file the mysql db Edited July 30, 2012 by Raven1992 Quote
Octet Posted July 30, 2012 Posted July 30, 2012 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? Quote
Raven1992 Posted July 30, 2012 Author Posted July 30, 2012 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());' ?> Quote
Octet Posted July 30, 2012 Posted July 30, 2012 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>"); } ?> Quote
Octet Posted July 30, 2012 Posted July 30, 2012 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? Quote
Raven1992 Posted July 30, 2012 Author Posted July 30, 2012 Tryed and still got the same message Quote
Octet Posted July 30, 2012 Posted July 30, 2012 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. Quote
Raven1992 Posted July 30, 2012 Author Posted July 30, 2012 So I take the username and pass out and try it that way Quote
Octet Posted July 30, 2012 Posted July 30, 2012 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')); Quote
Raven1992 Posted July 31, 2012 Author Posted July 31, 2012 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>"); } ?> Quote
skooda Posted July 31, 2012 Posted July 31, 2012 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 Quote
Djkanna Posted July 31, 2012 Posted July 31, 2012 <?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>"); ?> Quote
Raven1992 Posted July 31, 2012 Author Posted July 31, 2012 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 Quote
skooda Posted July 31, 2012 Posted July 31, 2012 <?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? Quote
rulerofzu Posted July 31, 2012 Posted July 31, 2012 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. Quote
Raven1992 Posted July 31, 2012 Author Posted July 31, 2012 Your username and password are incorrect. well I put the right pass in and the right username and the message is back from the 1st page Can't connect to the MySQL server. Please contact the webmaster. Quote
rulerofzu Posted July 31, 2012 Posted July 31, 2012 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. Quote
Raven1992 Posted July 31, 2012 Author Posted July 31, 2012 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 Quote
KyleMassacre Posted July 31, 2012 Posted July 31, 2012 Did you set up a user to access that database or did you just start a new database without giving a user access to it? Quote
rulerofzu Posted July 31, 2012 Posted July 31, 2012 get it right i work at pcworld Hahahaha too funny. Quote
Octet Posted July 31, 2012 Posted July 31, 2012 (edited) 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 July 31, 2012 by Octet Quote
rulerofzu Posted July 31, 2012 Posted July 31, 2012 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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.