dudejma Posted July 26, 2011 Share Posted July 26, 2011 I'm sure this is an obvious answer but I just can't find it. Mind you, it's one o'clock and I'm used to doing coding during the day, but what in the world am I missing? I know it's an obvious answer. Error: Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'virtuala_test'@'localhost' (using password: YES) in /home/virtuala/public_html/test/sql.php on line 10 sql.php: <?php $server = "localhost"; $db_user = "user"; $db_pass = "password"; $db_name = "name"; $con = mysql_connect($server, $db_user, $db_pass); if (!$con) { die ("An error has occured. Please contact the webmaster with the following error: " . mysql_error()); } $con2 = mysql_select_db($db_name); if (!$con2) { die ("An error has occured. Please contact the webmaster with the following error: " . mysql_error()); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/242818-connection-error/ Share on other sites More sharing options...
LeadingWebDev Posted July 26, 2011 Share Posted July 26, 2011 wrong identification information supported or database server refusing connection for supported user. Quote Link to comment https://forums.phpfreaks.com/topic/242818-connection-error/#findComment-1247151 Share on other sites More sharing options...
IrOnMaSk Posted July 26, 2011 Share Posted July 26, 2011 you just giving yourself extra step in your connection. y not just $con = mysql_connect('localhost', 'virtuala_test', 'password', 'dbname'); if(!$con) { die ("An error has occured. Please contact the webmaster with the following error: " . mysql_error()); } that will connect and select the database. for the error, try to log into your database with the user n password you're gave in the connection. Most likely, u gave the wrong password, or the suer 'virtuala_test' is spelled wrong or it has not been granted access to the database you're trying to select to use... oh and try my method of connection, you might have some lucks talking about luck, good luck!!! Quote Link to comment https://forums.phpfreaks.com/topic/242818-connection-error/#findComment-1247375 Share on other sites More sharing options...
wildteen88 Posted July 26, 2011 Share Posted July 26, 2011 you just giving yourself extra step in your connection. y not just $con = mysql_connect('localhost', 'virtuala_test', 'password', 'dbname'); if(!$con) { die ("An error has occured. Please contact the webmaster with the following error: " . mysql_error()); } That wont work. mysql_connect doesn't have a fourth argument for selecting the database. You need to use mysql_select_db to connect to a database with the standard mysql function library. Quote Link to comment https://forums.phpfreaks.com/topic/242818-connection-error/#findComment-1247412 Share on other sites More sharing options...
IrOnMaSk Posted July 26, 2011 Share Posted July 26, 2011 oopsi, i meant: <?PHP $con = mysqli_connect('localhost', 'virtuala_test', 'password', 'dbname') ?> Quote Link to comment https://forums.phpfreaks.com/topic/242818-connection-error/#findComment-1247449 Share on other sites More sharing options...
wildteen88 Posted July 26, 2011 Share Posted July 26, 2011 oopsi, i meant: <?PHP $con = mysqli_connect('localhost', 'virtuala_test', 'password', 'dbname') ?> That will work so long as the OP is using the mysqli library functions within their code. The functions for mysql and mysqli are not interchangeable. So if you're using mysqli_connect toconnect to mysql but use mysql_query to run a query it wont work. Quote Link to comment https://forums.phpfreaks.com/topic/242818-connection-error/#findComment-1247451 Share on other sites More sharing options...
IrOnMaSk Posted July 26, 2011 Share Posted July 26, 2011 absolutely right... if you use the two function interchangable you won't even get to do the query at all because it will just throws out error Quote Link to comment https://forums.phpfreaks.com/topic/242818-connection-error/#findComment-1247473 Share on other sites More sharing options...
IrOnMaSk Posted July 26, 2011 Share Posted July 26, 2011 that's probly were more answers and bunny trail than what Jma was looking for Quote Link to comment https://forums.phpfreaks.com/topic/242818-connection-error/#findComment-1247476 Share on other sites More sharing options...
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.