cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Go to solution
Highlighted

Having PHP/MySQL connection problems

Hi, 
Im coping my php code over from another host and im running into some issues.
I hope someone here can help me with.
I tried calling Godaddy phone support but he didnt understand what I was talking about.

So im trying to make a simple connection to mysql database which I have created on godaddy and uploaded the data. But the page displays this error when loaded.

Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /home/{USERNAME}/public_html/index4.php:8 Stack trace: #0 {main} thrown in /home/{USERNAME}/public_html/index4.php on line 8

I replaced GD username with{ USERNAME} for security reasons.

I wrote this code myself and its working on 4 other hosting companies servers without any problems at all.

This is my code. I replaced my details with {REMOVED} but they are correct.

$DBhost = "localhost"; // Host name
$DBuser = "{REMOVED}"; // Database user name
$DBpass = "{REMOVED}"; // Database password
$DBname = "{REMOVED}"; // Database name

mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database"); // this is LINE 8
mysql_select_db ($DBname);

Any suggestions?
Is mysql off? how can i find out.
Thanks

-D

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User III
Super User III
Solution

Re: Having PHP/MySQL connection problems

@BigDotMedia 

 

The issue is you are now running PHP 7.x which mysql_connect has been removed - You need to use mysqli_connect - https://www.php.net/manual/en/function.mysqli-connect.php

 

Very similar syntax

I am a GoDaddy End User - Just Like You
Check out my site! | I currently manage over 300 WordPress Websites
* Please note that I offer free advice on this forum. Thank You Info If you would like personalized help, please contact me. Otherwise, please ask your question in the proper forum so the answer can assist EVERYONE in the community and not just you. Thanks! *

Once your issue is resolved,
please be sure to come back and click accept for the solution

Get Better Support on the Community Boards!
Etiquette When Asking for Help from the Community

View solution in original post

2 REPLIES 2
Highlighted
Super User III
Super User III
Solution

Re: Having PHP/MySQL connection problems

@BigDotMedia 

 

The issue is you are now running PHP 7.x which mysql_connect has been removed - You need to use mysqli_connect - https://www.php.net/manual/en/function.mysqli-connect.php

 

Very similar syntax

I am a GoDaddy End User - Just Like You
Check out my site! | I currently manage over 300 WordPress Websites
* Please note that I offer free advice on this forum. Thank You Info If you would like personalized help, please contact me. Otherwise, please ask your question in the proper forum so the answer can assist EVERYONE in the community and not just you. Thanks! *

Once your issue is resolved,
please be sure to come back and click accept for the solution

Get Better Support on the Community Boards!
Etiquette When Asking for Help from the Community

View solution in original post

Highlighted

Re: Having PHP/MySQL connection problems

OMG, thanks. But now it seems I have to go though over 50,000 lines of code.
Oh dear.