Pr0t0n Posted January 27, 2014 Share Posted January 27, 2014 Hey guys, I am having problems when I started a class for mysql queries, and I am trying to connect in the __construct() but it doesnt matter how many diffrent servers I try it won't freaking connect PLEASE HELP lol. Code is below: function __construct() { $db = new mysqli($db_login_cred); // $db_conn = mysqli_connect() or die(mysqli_error($db)); if (mysqli_connect_error()) { die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); } echo 'Success... ' . $db->host_info . "\n"; /* if(isset($db_conn)) { echo "Verbinding met de MySQL backend tot stand gebracht."; } else { echo "Kan de MySQL-backend niet bereiken.<br /><br /> Foutmelding:<br />" .$error = $db_conn->mysqli_connect_error() .$error; } */ There's some of my own code which is commented out in a try to use standard code from php.net to see if I made a typo or whatever. I will keep this page open so if u need additional info I can supply it fast hopefully. if u also want to see the output: http://odins.co.nf/ Quote Link to comment https://forums.phpfreaks.com/topic/285723-cant-connect-to-mysql-server/ Share on other sites More sharing options...
Barand Posted January 27, 2014 Share Posted January 27, 2014 your credentials need to to be four separate string values $db = new mysqli(HOST,USERNAME,PASSWORD,DATABASE); Quote Link to comment https://forums.phpfreaks.com/topic/285723-cant-connect-to-mysql-server/#findComment-1466777 Share on other sites More sharing options...
Pr0t0n Posted January 27, 2014 Author Share Posted January 27, 2014 I know why you're saying that but I came from four credentials and kept adding to be sure hes not using a wrong setting. See this: http://nl3.php.net/manual/en/mysqli.construct.php and scroll to "Parameters" u will see all the parameters u can add to it. Quote Link to comment https://forums.phpfreaks.com/topic/285723-cant-connect-to-mysql-server/#findComment-1466785 Share on other sites More sharing options...
Solution Pr0t0n Posted January 27, 2014 Author Solution Share Posted January 27, 2014 Solved it, it seems the variable for the credentials wasnt passed to the __construct() Quote Link to comment https://forums.phpfreaks.com/topic/285723-cant-connect-to-mysql-server/#findComment-1466792 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.