msql_connect warning fix [duplicate] - php

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);

Related

Error when updating from PHP 5.4 to 7.4: "Your PHP installation appears to be missing the MySQL extension which is required by WordPress." [duplicate]

This question already has answers here:
Error : Your PHP installation appears to be missing the MySQL extension which is required by WordPress
(7 answers)
Why shouldn't I use mysql_* functions in PHP?
(14 answers)
Closed 2 years ago.
I recently updated my site hosted on HostGator from PHP 5.4 to 7.4. I got this error:
Warning: Use of undefined constant WP_CONTENT_DIR - assumed 'WP_CONTENT_DIR' (this will throw an Error in a future version of PHP) in /home1/keziavida/public_html/wp-includes/load.php on line 115
Your PHP installation appears to be missing the MySQL extension which is required by WordPress.
Deprecated: Directive 'allow_url_include' is deprecated in Unknown on line 0
Does anyone know how to fix this?

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.

PHP : Undefined function mysql_connect() [duplicate]

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

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in [duplicate]

This question already has answers here:
Mysql_real_escape_string() A link to the server could not be established
(3 answers)
Closed 9 years ago.
I got this warning message when executing my PHP script in Internet webserver, but in local wamp it is working without warnings. what is the reason ?
Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/deport/public_html/abc/index.php on line 209
mysql_real_escape_string() needs an active connection to the MySQL server and will initiate one with the default data from the php.ini configuration if there is none.
Do not use this function without first connecting to the database.
Also, do not use the mysql_* functions. They are deprecated and will be removed from PHP.
You need to have a valid connection to your MySQL Server first.
Do mysql_connect() before using this function.
Example:
$connection = mysql_connect("host","user","pass");
mysql_select_db("dbname",$connection);
echo mysql_real_escape_string("string to be escaped",$connection);
You should really use the MySQLi Extension instead of the standard MySQL Extension from PHP.

PHP escapeshellarg() Issue, with CodeIgniter [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
escapeshellarg() has been disabled for security reasons
I've created an image upload system with PHP and it all works but I still get a warning:
A PHP Error was encountered
Severity: Warning
Message: escapeshellarg() has been disabled for security reasons
Filename: libraries/Upload.php
Line Number: 1066
Does anyone know how to get rid of this without contacting Hosting provider?
You can't. You will have to contact your sys admin to enable that function for you, or use something else (that does not involve executing shell commands) for what you are trying to accomplish.
Try replacing escapeshellarg with #escapeshellarg.
Because, then you'd be suppressing any warning that function call gives.
Since
it all works
Doing that shouldn't be a problem to your working code.
Note: using # to suppress warnings or errors is not recommended.

Categories