Fatal error undefined mysql_connect - somebody please help!

hello everyone

here is my problem

>> fatal error undefined mysql_connect <<

i dont have it open at this minute, but logged into cpanel, i loaded my files into file manager, one of which asked me to fill in where it says something like mysql_connect (server, user, password, dbname), created a database, gave it a name, user and password, i then went into myphpadmin and put files into the databases i created…

i typed in the web address using my domain name, clicked the file, logged in and it open up… but most i couldnt access most of the stuff on there because of the error message telling me “fatal error undefined mysql_connect” which leads back to this file i uploaded and the line where it says i should enter my (server, user, password, dbname)

thanks for any help anyone can offer on this. its really driving me around the bend.

You’ll have to contact your host.
They need to edit the php.ini file, and my guess is you won’t have access to it.

hey thanks, Jaanboy

I read somewhere that all i need to do is delete a semicolon infront of the MySQL extension to enable it. Would i need to contact my host for that is can i do that myself?

Sounds like the MySQLi extension isn’t enabled on your server.

You can change all your functions from mysqli_ to mysql_ as theoaks said. If you really need these functions, you’ll have to contact your host.

hey thanks for the replies guys

there shouldn’t be a problem with the code… i’ve pasted it is below… i’ve edited it in file manager to show the relevant info, i.e. abc_user. and the error mesage points to line 6, but i’m confident i’ve put in the correct info in the correct manner.

im wondering… does it matter that the code says mysqli when cpanel is using mysql??


require_once ‘config.php’;

function db_open() {
$dbase = mysqli_connect (DB_SERVER, DB_USER, DB_PASSWORD, DB_NAME);

if (mysqli_connect_errno()) {
	printf ("&lt;font class='error'&gt;Connect failed&lt;/font&gt; : %s\

", mysqli_connect_error());
return null;

return $dbase;


function db_close($dbase) {


thanks again for any help given. much appreciated!


Let us see the code that is causing that error.

Check the server name (It should be “localhost”), also check your username amd database name. Most hosts require a prefix to the main database name. If your capnel login name is abc, your database name will be named abc_dbname and your database user name will also be abc_username. Your password can be anything.

Also check the priviledge granted to your user name. It must be at least a SELECT priviledge

Try using mysql for all your code markup instead of mysqli. They are different