Codeigniter Deprecated: mysql_real_escape_string(): - php

Got below error while using codigniter 3.0
FYI using PHP Version 5.5.12,Apache Version Apache/2.4.9 (Win64) PHP/5.5.12
A PHP Error was encountered
Severity: 8192
Message: mysql_real_escape_string(): The mysql extension is deprecated
and will be removed in the future: use mysqli or PDO instead
Filename: models/common_model.php
Line Number: 21
Backtrace:
File: C:\wamp\www\Codeigniter\application\models\common_model.php
Line: 21 Function: mysql_real_escape_string

Go to application => config => database.php and change from
$db['default']['dbdriver'] = 'mysql';
to
$db['default']['dbdriver'] = 'mysqli';
Note It is recommended to use query builder class for queries.

use mysqli_real_escape_string();
and replace mysql to mysqli in every functions.

You should use PDO in codeigniter to solve all problem related to mysql and mysqli..
see how to use PDO in CI
if you are using CI 3 then http://www.codeigniter.com/user_guide/database/configuration.html
and if you are using CI 2.x
How to use pdo in codeigniter?

Related

Error with SQL_ODBC_CURSORS during initialization PDO

When I try to initialize a new instance of the PDO class using the odbc driver, I get the following error.
Error: PDO Error: SQLSTATE[HY024] SQLSetConnectAttr SQL_ODBC_CURSORS: 0 [unixODBC][Driver Manager]Invalid attribute value
Why can I get this error?
I tried to find similar problems, but I did not find anything similar. Partially similar problems were solved by the advice to install Microsoft ODBC Driver 17 for SQL Server, I have it
[ODBC Driver 17 for SQL Server]
Description=Microsoft ODBC Driver 17 for SQL Server
Driver=/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.10.so.1.1
UsageCount=1
but the problem is still there

How to connect to MS SQL Server 2016 from PHP 7

I'm attempting to insert rows in table in a database hosted in MS SQL Server 2016 installed in my local computer.
Here is my snippet $dbc = mssql_connect('MwangiCJ-PC/mwangi','sqluser','xxxx','mydb');
I have tried out the answer from
mssql_connect() with PHP5 and MSSQL2012 Express but I still get the error Fatal error: Uncaught Error: Call to undefined function mssql_connect()
When i run a simple phpinfo() I can see that I already have both sqlsrv and pdo_sqlsrv available.
Am I missing anything else? Please help. Thank you.
From the PHP docs:
Warning
This function was REMOVED in PHP 7.0.0.
Alternatives to this function include:
PDO::__construct()
sqlsrv_connect()
odbc_connect()

CodeIgniter and PHP 5.5.14 - mysql_escape_string() issue

I've this issue after setting up CodeIgniter with PHP 5.5.14
A PHP Error was encountered
Severity: 8192
Message: mysql_escape_string(): This function is deprecated; use mysql_real_escape_string() instead.
Filename: mysqli/mysqli_driver.php
Line Number: 320
It seems that mysql_real_escape_string() functions has been deprecated on 5.5.14, right?
CodeIgniter have no compatibility with this PHP version??
Any ideas??
Thanks in advance!
Giovanni
There was an error with the MySQL configuration (I'm on a MacBook Pro).
In practice, mysql's tmp path must be setup on mac.
After this step, my issue has disappeared!

mysql_connect() shows error in php5

I have using php5-mysql system-Ubantu 13.10, I setup my project but when i login for my first page it give me [:error] [pid 16033] [client 127.0.0.1:53154] PHP Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /var/www/Scada/Fleet/phpcmd/login.php on line 29, can you please tell me how I can make my environment compatible to work with the code.
change Line 29 /var/www/Scada/Fleet/phpcmd/login.php on line 29
from mysql_connect() to mysqli_connect()
you have to change all mysql statements to mysqli statements to get it work.
Or you use PDO.
Do
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
in your index.php or the first line of /var/www/Scada/Fleet/phpcmd/login.php
or use mysqli or PDO instead of the old mysql extensions.

Connecting to Oracle in Codeigniter (undefined constant OCI_COMMIT_ON_SUCCESS)

im kind of a n00b to Oracle db's, but when i set my dbdriver in codeigniter to oci8, i get the following error, which is weird, providing the extension is enabled in the php.ini file.
I get the following error.
A PHP Error was encountered
Severity: Notice
Message: Use of undefined constant OCI_COMMIT_ON_SUCCESS - assumed 'OCI_COMMIT_ON_SUCCESS'
Filename: database/DB.php
Line Number: 82
You should install/enable the oci8 extension.
http://www.php.net/manual/en/book.oci8.php

Categories