Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future:

QuestionsDeprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future:
Tom Tong asked 9 years ago

I ran the index.php. Index.php show a error.
The error is"eprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in X:xampp-win32-5.6.8-0-VC11xampphtdocsphpgriddemoseditingindex.php on line 14"

I tried to change from mysql_connect() to mysqli_connect(PHPGRID_DBHOST, PHPGRID_DBUSER, PHPGRID_DBPASS, PHPGRID_DBNAME);

And i delete the "mysql_select_db(PHPGRID_DBNAME);".

It show "Couldn't execute query. No database selected – SELECT * FROM clients WHERE 1=1 LIMIT 1 OFFSET 0"

How to solve the problem.

Thank you very much.

10 Answers
Abu Ghufran answered 9 years ago

Hi,

Use this code sample for mysqli connection:
http://phpgrid.org/demo/demos/loading/db-layer-mysqli.phps

Tom Tong answered 9 years ago

Hi Abu Ghufran,

I tried to copy db-layer-mysqli.php to X:xampp-win32-5.6.8-0-VC11xampphtdocsphpgriddemosloading. it still show ": mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO ".

Thank you very much.

Abu Ghufran answered 9 years ago

mysql_connect is not used anywhere else inside library. May be it's being called by some other code.
If you use db-layer-mysqli.php … it should not show mysql_connect.

Please check file and line number that comes with error.

Tom Tong answered 9 years ago

i change the phpgrid/demos/editing/index.php.

Change mysql_connect(PHPGRID_DBHOST, PHPGRID_DBUSER, PHPGRID_DBPASS); to mysqli_connect(PHPGRID_DBHOST, PHPGRID_DBUSER, PHPGRID_DBPASS, PHPGRID_DBNAME);

The page still show "Couldn't execute query. No database selected – SELECT * FROM clients WHERE 1=1 LIMIT 1 OFFSET 0".

How to solve the problem.

Abu Ghufran answered 9 years ago

To use mysqli driver,

You need to replace:

mysql_connect(PHPGRID_DBHOST, PHPGRID_DBUSER, PHPGRID_DBPASS);
mysql_select_db(PHPGRID_DBNAME);

include(PHPGRID_LIBPATH."inc/jqgrid_dist.php");
$g = new jqgrid();

with:

$db_conf = array();
$db_conf["type"] = "mysqli";
$db_conf["server"] = PHPGRID_DBHOST; // or you mysql ip
$db_conf["user"] = PHPGRID_DBUSER; // username
$db_conf["password"] = PHPGRID_DBPASS; // password
$db_conf["database"] = PHPGRID_DBNAME; // database

// include and create object
include(PHPGRID_LIBPATH."inc/jqgrid_dist.php");
$g = new jqgrid($db_conf);

Tom Tong answered 9 years ago

Hi Abu Ghufran,

The error is no show.

Thank you very much.

Abu Ghufran answered 9 years ago

We're working on updating all demos and will be done in coming version.
Quick solution is to pass db config array to constructor and remove mysql_ functions:

$db_conf = array();
$db_conf["type"] = "mysqli";
$db_conf["server"] = PHPGRID_DBHOST; // or you mysql ip
$db_conf["user"] = PHPGRID_DBUSER; // username
$db_conf["password"] = PHPGRID_DBPASS; // password
$db_conf["database"] = PHPGRID_DBNAME; // database

$g = new jqgrid($db_conf);

pierre mata answered 8 years ago

just that i did, and works with C:wampwwwphpgriddemoseditingindex.php, but when i try with other demos; like C:wampwwwphpgriddemosmaster-detailmaster-detail.php, i did the same thing and send not error, just this:"Couldn't execute query. No database selected – SELECT id,client…."

Abu Ghufran answered 8 years ago

I am unable to generate this issue. I am emailing you updated library, please test after update.
Also if issue persist, send me complete code on my email [email protected]

pierre mata answered 8 years ago

this still not work, i did what you said, this is the part of code and the path where the file is, please tellme what is wrong!

$db_conf = array();
$db_conf["type"] = "mysqli";
$db_conf["server"] = PHPGRID_DBHOST; // or you mysql ip
$db_conf["user"] = PHPGRID_DBUSER; // username
$db_conf["password"] = PHPGRID_DBPASS; // password
$db_conf["database"] = PHPGRID_DBNAME; // database

// include and create object
include(PHPGRID_LIBPATH."inc/jqgrid_dist.php");
$grid = new jqgrid($db_conf);

the message error is : Couldn't execute query. No database selected – SELECT id,client_id,invdate,amount,tax,note,total,'' as 'company' FROM invheader WHERE client_id = 0 LIMIT 1 OFFSET 0

Your Answer

8 + 11 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?