THEK Posted December 22, 2011 Share Posted December 22, 2011 Hi, I'm trying to connect to a database on a port other than 3306 to create a database. Here's my connect code: $connection = new MySQLi($host,$user,$pass) But according to the PHP website it says I can lay the code out like so: new MySQLi($host,$user,$pass,$database,$port) But how do I specify the port without the database? I've tried just "" as the database but the connection still fails. Any help would be much appreciated. Link to comment https://forums.phpfreaks.com/topic/253718-connecting-to-mysql-on-a-custom-port/ Share on other sites More sharing options...
requinix Posted December 22, 2011 Share Posted December 22, 2011 How about using null? Link to comment https://forums.phpfreaks.com/topic/253718-connecting-to-mysql-on-a-custom-port/#findComment-1300722 Share on other sites More sharing options...
AGuyWithAthing Posted December 22, 2011 Share Posted December 22, 2011 you could set the host to "127.0.0.1:3307" or w/e port you want to use? Dunno if that will work but it "should". Link to comment https://forums.phpfreaks.com/topic/253718-connecting-to-mysql-on-a-custom-port/#findComment-1300723 Share on other sites More sharing options...
THEK Posted December 23, 2011 Author Share Posted December 23, 2011 you could set the host to "127.0.0.1:3307" or w/e port you want to use? Dunno if that will work but it "should". That was what I had but it said unknown host. How about using null? This worked perfectly. I was putting it in quotes but it only works without them. Link to comment https://forums.phpfreaks.com/topic/253718-connecting-to-mysql-on-a-custom-port/#findComment-1300965 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.