PHP : Undefined function mysql_connect() [duplicate] - php

This question already has answers here:
"Call to undefined function mysql_connect()" after upgrade to php-7 [duplicate]
(1 answer)
Undefined function mysql_connect() [duplicate]
(14 answers)
Closed 7 years ago.
I just downloaded the new xampp and try to run my old projects and I got this error
Fatal error: Uncaught Error: Call to undefined function mysql_connect() in F:\xampp\htdocs\try\index.php:17 Stack trace: #0 {main} thrown in F:\xampp\htdocs\try\index.php on line 17
Does it mean that the mysql_connect that I used is not already supported in new xampp ?

mysql_connect()
has been removed from PHP7, which is used by the newest xampp version.
Instead, use mysqli_connect() like in this example.
Another method, PDO is also possible (but is coded in a very different way as mysql_connect.)

The MySQL module is depreciated in PHP5 and removed in PHP7, you can use these:
MySQLi http://php.net/manual/en/book.mysqli.php
PHP::PDO http://php.net/manual/en/book.pdo.php
Check your version by using phpinfo().

Not particularly by xamppp but php itself deprecated mysql Here a quote from them:
The original MySQL extension is now deprecated, and will generate E_DEPRECATED errors when connecting to a database. Instead, use the MySQLi or PDO_MySQL extensions
if you can provide us php version i can help more

Related

Php 7.4 version and unable to access user authorization page

I am using php 7.4. I have a php page called auth1. It requires a username and Password, which in the
past took me into auth3. I started receiving a deprecated error when I was on php 5.4 so I upgraded to
7.4. Now I get the error messages below. Any ideas. Could it be my mysql not compatible
Warning: Use of undefined constant user - assumed 'user' (this will throw an Error in a future version of PHP) in /home/utm/public_html/auth3.php on line 5
Warning: Use of undefined constant password - assumed 'password' (this will throw an Error in a future version of PHP) in /home/utm/public_html/auth3.php on line 5
Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /home/utm/public_html/auth3.php:19 Stack trace: #0 {main} thrown in /home/utm/public_html/auth3.php on line 19
welcome to stackoverflow
your first and second lines are not Uncaught error and don't break your php processes
but about your last line it tell you that mysql_connect doesn't exists
because mysql extension and all of mysql_* functions are deprecated as of PHP 5.5 and has been removed as of PHP 7 to up
as the itachi said, and you said an example (mysqli) you should use a new extension between 3 following ways:
MySQLI reference functions Check they here
MySQLI OOP extension Check they here
PDO Extension Check they here
Also you can see this references for install your needs:
PDO Installation
MySQLI Installation
and about your 1st and 2nd lines you could put your codes to let us check, know and solve your problem

Error with mysql_real_escape_string() [duplicate]

This question already has answers here:
Why shouldn't I use mysql_* functions in PHP?
(14 answers)
Closed 5 years ago.
So I'm running the code from this link for testing, trying to learn how sessions work.
https://www.formget.com/login-form-in-php/
and I'm getting an error message
Fatal error: Uncaught Error: Call to undefined function
mysql_real_escape_string() in :20 Stack trace: #0
: include() #1 {main} thrown in on line 20
its to do with the mysql_real_escape_string() in the login.php file but I'm unsure what's wrong with it. As it protects against MySQL injections, has this function been renamed since the tutorial was posted or something?
Edit: This is not a duplicate as I'm not asking how to protect against MySQL injections I was asking whether the function had been removed
mysql_ has been deprecated since 5.5:
The mysql extension has been deprecated since PHP 5.5. The mysqli or PDO extension should be used instead. The deprecation has been decided in mysql_deprecation, where a discussion of the reasons behind this decision can be found.
and removed in PHP 7.
mysql_real_escape_string() is standard part of MySQL function "batch" and should always work if the extension is loaded correctly.
Does any another mysql_ function work? (It should not)
Make sure, that you have this line uncommented in your php.ini:
extension=mysql.so
Also it'd be wise to use mysqli or PDO instead (mysql_ is deprecated), they both can take care of escaping for you.

msql_connect warning fix [duplicate]

This question already has answers here:
Deprecated: mysql_connect() [duplicate]
(12 answers)
Closed 6 years ago.
I've got some older software that was written a few years ago but is now unsupported so I can't simply upgrade to resolve this issue.
Meaning; that I cannot go to the vendor and get a software update to resolve it.
I'm getting an error on all my pages because of this 1 line of code. I know what needs to happen to it but because I don't do much SQL programming I'm unsure how to implement it.
The code:
$dblink = mysql_connect(SB_HOST_NAME,SB_DB_USER_NAME,SB_DB_PASSWORD) OR DIE("Unable to connect to database");
The error:
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/kribs/public_html/stconfig.php on line 117
Warning: Cannot modify header information - headers already sent by (output started at /home/kribs/public_html/stconfig.php:117) in /home/kribs/public_html/key/openinfo.php on line 248
I've come across the article saying it needs to use the newer format but not sure how it applies to this situation.
Any help is much appreciated, I will continue reading to see if I can resolve it in the mean time.
The original MySQL extension is now deprecated, and will generate E_DEPRECATED errors when connecting to a database. Instead, use the MySQLi or PDO_MySQL extensions.
http://php.net/manual/en/migration55.deprecated.php
You can turn off those warnings with error_reporting
Here You go:
// Report all errors except E_DEPRECATED
error_reporting(E_ALL & ~E_DEPRECATED);

XAMPP Fatal error: Call to undefined function mysql_connect() [duplicate]

This question already has answers here:
Undefined function mysql_connect() [duplicate]
(14 answers)
Closed 6 years ago.
I hit this error when running a PHP script on XAMPP, in Windows. Does anyone know how solved it?
Fatal error: Call to undefined function mysql_connect() in
C:\xampp\htdocs\netbanking\dbconnection.php on line 2.
Try:
<?php
phpinfo();
?>
Create and call the page with above code and search for mysql. If not found, Do the following things.
Open your php.ini and
Changed from
;extension=php_mysql.so
into
extension=php_mysql.so
NOTE: mysql extension was deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0. Instead, the MySQLi or PDO_MySQL extension should be used.

How to solve this error [Fatal error: Uncaught Error: Call to undefined function mysql_connect()] in php? [duplicate]

This question already has answers here:
Why shouldn't I use mysql_* functions in PHP?
(14 answers)
Closed 6 years ago.
Can anyone suggest how to solve this error in php "Fatal error: Uncaught Error: Call to undefined function mysql_connect()" ? I am using php 7.0.4 and php extension is mysqli.
you are trying to connect by using mysql_connect() instade of mysqli_connect().
you are saying you had extension for mysqli then you should go for mysqli_connect().
You are using a PHP function that was removed on PHP 7
http://php.net/manual/en/function.mysql-connect.php
use mysqli_connect() instead.
http://php.net/manual/en/function.mysqli-connect.php

Categories