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

Problems with the Windows version of XAMPP, questions, comments, and anything related.

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

Postby gleonard@bluewin.ch » 20. February 2019 11:03

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
gleonard@bluewin.ch
 
Posts: 2
Joined: 20. February 2019 10:06
XAMPP version: 7.3
Operating System: Windows 10

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

Postby Altrea » 20. February 2019 12:26

Hi,

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

best wishes,
Altrea
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

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

Postby gleonard@bluewin.ch » 20. February 2019 16:37

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
gleonard@bluewin.ch
 
Posts: 2
Joined: 20. February 2019 10:06
XAMPP version: 7.3
Operating System: Windows 10

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

Postby Altrea » 20. February 2019 17:19

You are welcome.
If you have any specific questions about how to change your code to mysqli, let us now :D
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 124 guests