Page 1 of 1

php mysql_connect doesn't work for me. Can someone help?

PostPosted: 20. February 2019 11:03
by gleonard@bluewin.ch
I just installed xampp with php 7.3 / 7.2 and am test running it on my localhost. I can no longer connect to my database with the php 7.3. My code looks like this:
1 <?php
2 // ===============================================================
3 // customDBConnection.php
4 // ===============================================================
5 $db_server = 'localhost';
6 $db_name = 'crss';
7 $db_user = 'root';
8 $db_passwd = '';
9 // ------------------------------------------------
10 // Connect to DATABASE
11 // ------------------------------------------------
12 $db = mysql_connect($db_server, $db_user, $db_passwd);
13 mysql_select_db($db_name,$db);

The error that php throws is this:
Fatal error: Uncaught Error: Call to undefined function mysql_connect() in C:\xampp\htdocs\crss\customDBConnection.php:19 Stack trace: #0 C:\xampp\htdocs\crss\index.php(5): include() #1 {main} thrown in C:\xampp\htdocs\crss\customDBConnection.php on line 12

The above code has been running on my servers for years now without any problems.

Can someone of you help me?

Thank you.
George

Re: php mysql_connect doesn't work for me. Can someone help

PostPosted: 20. February 2019 12:26
by Altrea
Hi,

The official php Documentation tells you everything you need to know:
http://php.net/manual/en/function.mysql-connect.php

best wishes,
Altrea

Re: php mysql_connect doesn't work for me. Can someone help

PostPosted: 20. February 2019 16:37
by gleonard@bluewin.ch
Thanks Altrea. I see now that I have to abandon mysql. I've decided to go with mysqli which means that I have a lot of work to do. Nonetheless, thank you again for your response.
George

Re: php mysql_connect doesn't work for me. Can someone help

PostPosted: 20. February 2019 17:19
by Altrea
You are welcome.
If you have any specific questions about how to change your code to mysqli, let us now :D