How to make mysqli connect function?

As some users have suggested (and is the best way), return the mysqli instance function getConnected($host,$user,$pass,$db) { $mysqli = new mysqli($host, $user, $pass, $db); if($mysqli->connect_error) die(‘Connect Error (‘ . mysqli_connect_errno() . ‘) ‘. mysqli_connect_error()); return $mysqli; } Example: $mysqli = getConnected(‘localhost’,’user’,’password’,’database’);

Access mysql running on localhost from minikube

As the OS and minikube vm-driver wasn’t mentioned, I assume it is –vm-driver=virtualbox because it’s probably most common case. If you use something different you need to adjust this solution according to your configuration. Explanation: 127.0.0.1 is a localhost(lo0) interface IP address. Nodes, Hosts and Pods have their own localhost interfaces and they are not … Read more

php, mysql – Too many connections to database error

There are a bunch of different reasons for the “Too Many Connections” error. Check out this FAQ page on MySQL.com: http://dev.mysql.com/doc/refman/5.5/en/too-many-connections.html Check your my.cnf file for “max_connections”. If none exist try: [mysqld] set-variable=max_connections=250 However the default is 151, so you should be okay. If you are on a shared host, it might be that other … Read more

“Cannot drop database because it is currently in use”. How to fix?

The problem is that your application probably still holds some connection to the database (or another application holds connection as well). Database cannot be deleted where there is any other opened connection. The first problem can be probably solved by turning connection pooling off (add Pooling=false to your connection string) or clear the pool before … Read more

Testing an Entity Framework database connection

Are you just wanting to see if the DB connection is valid? If so take a look at the using (DatabaseContext dbContext = new DatabaseContext()) { dbContext.Database.Exists(); } http://msdn.microsoft.com/en-us/library/gg696617(v=vs.103).aspx and for checking if a server machine is up, DB server or web services server , try this: public PingReply Send( string hostNameOrAddress ) http://msdn.microsoft.com/en-us/library/7hzczzed.aspx