-1

I've been struggling to connect my website to my MariaDB server using PHP. I've been using this PHP script:

$dbname = 'testdb'; $dbuser = 'rfradkin'; $dbpass = '****'; $dbhost = 'romfradkin.com'; $connect = mysql_connect($dbhost, $dbuser, $dbpass) or die("Unable to connect to '$dbhost'"); mysql_select_db($dbname) or die("Could not open the database '$dbname'");

The password is correct, and the database exists. Also, I have PHP functioning and this website is running on an apache web server. Whenever I check the PHP page, I look at the console logs in chrome and see this error

GET https://romfradkin.com/test.php 500 (Internal Server Error)

Any suggestions on how to fix this problem? Thanks.

Shadow
  • 32,277
  • 10
  • 49
  • 61
  • 2
    The answers to the duplicate question tell you how to get a meaningful error message from php, rather than just a meaningless http 500 error code (it basically means that oops, something went wrong). My guess is that you php version no longer includes the mysql library. You really should be using mysqli or pdo instead. And please forget the php tutorial / book you are using because it is waaaay out of date! By about 15 years... – Shadow Jun 03 '22 at 21:20
  • I'm using mariadb, does that make a difference? – user23472342 Jun 03 '22 at 21:23
  • 1
    If I guessed the problem correctly, then no, mariadb does not make any difference as the issue is with php, not with your database. But the best course of action would be to follow the answers to the duplicate question to determine the exact root cause of the error. – Shadow Jun 03 '22 at 21:27
  • Your a wizard lmao. That worked (had to just use mysqli for both commands) Thanks so much!!! – user23472342 Jun 03 '22 at 21:36

0 Answers0