DB Connection script failing, php

I have index.php that requires config.php, and sql.php.

Config.php has the database credentials and sql.php has the following code
function dbconnect()
 global $db_connect_info;
	$errormessage = "<center><h2>Sorry.</h2><br />Service unavailable, please contact to the administrator.</center>";
	$db = @mysql_connect($db_connect_info["dbhost"], $db_connect_info["dbuser"], $db_connect_info["dbpassword"]) or die ($errormessage);
	@mysql_select_db($db_connect_info["dbname"],$db) or die ($errormessage);

Open in new window

This is an older script that im trying to use. Not sure if it's outdated or not. I did test my credentials to the database were correct by using a simple script.

mysql_connect('db_host', 'myuser', 'password') or die('Could not connect the database : Username or password incorrect');
mysql_select_db('esudmanager') or die ('No database found');
echo 'Database Connected successfully';

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Nathan RileyFounderCommented:
Your using old mysql commands, I would update to mysqli, check the below example of how to connect and query.

$db = new mysqli("localhost", "user", "pass", "database");
$sql="select * from table";

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dave BaldwinFixer of ProblemsCommented:
Using '@' in front of functions only suppresses the reporting of errors, it does not make the errors go away.  I never do that.  In addition, nothing is returned from your function which means in effect it does nothing.  And Nathan is correct about using the old mysql functions, they are going away.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.