CodeIgniter Forums

Full Version: Mysql_query() function Error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello all!

Im getting this error and trying to fix it:

An uncaught Exception was encountered

Type: Error
Message: Call to undefined function mysql_query()
Filename: /home4/cultured/public_html/application/views/dashboard.php
Line Number: 332

Its from this line of code: 
$mysql=mysql_query("select * from messages order by msg_id desc");

Im connected to DB (include("application/config/database.php")); and upgraded within webhost from 5.4 to 7.0 php but still get this error. I feel that I suppose to add the table (citable) that I made within the database but not sure. How to correct this if possible?

Heart Heart ,
Mekaboo
(05-22-2019, 01:41 PM)Mekaboo Wrote: [ -> ]Hello all!

Im getting this error and trying to fix it:

An uncaught Exception was encountered

Type: Error
Message: Call to undefined function mysql_query()
Filename: /home4/cultured/public_html/application/views/dashboard.php
Line Number: 332

Its from this line of code: 
$mysql=mysql_query("select * from messages order by msg_id desc");

Im connected to DB (include("application/config/database.php")); and upgraded within webhost from 5.4 to 7.0 php but still get this error. I feel that I suppose to add the table (citable) that I made within the database but not sure. How to correct this if possible?

Heart Heart ,
Mekaboo

You are using the deprecated mysql_query function... (which is removed as of PHP 7.0)

Either you're using mysql_query manually in your script (which means your issue is not related to CI and you should read about MySQLi or PDO)

or you're using an ancient script which was set to use mysql, in that case:

Go to application => config => database.php and change from

PHP Code:
$db['default']['dbdriver'] = 'mysql'

to

PHP Code:
$db['default']['dbdriver'] = 'mysqli'

Not sure if your script can be trusted anymore in production even after this change!
(05-22-2019, 03:04 PM)noobie Wrote: [ -> ]
(05-22-2019, 01:41 PM)Mekaboo Wrote: [ -> ]Hello all!

Im getting this error and trying to fix it:

An uncaught Exception was encountered

Type: Error
Message: Call to undefined function mysql_query()
Filename: /home4/cultured/public_html/application/views/dashboard.php
Line Number: 332

Its from this line of code: 
$mysql=mysql_query("select * from messages order by msg_id desc");

Im connected to DB (include("application/config/database.php")); and upgraded within webhost from 5.4 to 7.0 php but still get this error. I feel that I suppose to add the table (citable) that I made within the database but not sure. How to correct this if possible?

Heart Heart ,
Mekaboo

You are using the deprecated mysql_query function... (which is removed as of PHP 7.0)

Either you're using mysql_query manually in your script (which means your issue is not related to CI and you should read about MySQLi or PDO)

or you're using an ancient script which was set to use mysql, in that case:

Go to application => config => database.php and change from

PHP Code:
$db['default']['dbdriver'] = 'mysql'

to

PHP Code:
$db['default']['dbdriver'] = 'mysqli'

Not sure if your script can be trusted anymore in production even after this change!

That was changed in my database.php file. I may have to take your advice and cut the code out. Thank you so very much Heart
When using all MySQLi calls they are mysqli_method
(05-23-2019, 03:06 AM)InsiteFX Wrote: [ -> ]When using all MySQLi calls they are mysqli_method

Cool beans, thank you Heart
(05-22-2019, 04:52 PM)Mekaboo Wrote: [ -> ]
(05-22-2019, 03:04 PM)noobie Wrote: [ -> ]
(05-22-2019, 01:41 PM)Mekaboo Wrote: [ -> ]Hello all!

Im getting this error and trying to fix it:

An uncaught Exception was encountered

Type: Error
Message: Call to undefined function mysql_query()
Filename: /home4/cultured/public_html/application/views/dashboard.php
Line Number: 332

Its from this line of code: 
$mysql=mysql_query("select * from messages order by msg_id desc");

Im connected to DB (include("application/config/database.php")); and upgraded within webhost from 5.4 to 7.0 php but still get this error. I feel that I suppose to add the table (citable) that I made within the database but not sure. How to correct this if possible?

Heart Heart ,
Mekaboo

You are using the deprecated  <-->Audacity Find My iPhone Origin mysql_query function... (which is removed as of PHP 7.0)

Either you're using mysql_query manually in your script (which means your issue is not related to CI and you should read about MySQLi or PDO)

or you're using an ancient script which was set to use mysql, in that case:

Go to application => config => database.php and change from

PHP Code:
$db['default']['dbdriver'] = 'mysql'

to

PHP Code:
$db['default']['dbdriver'] = 'mysqli'

Not sure if your script can be trusted anymore in production even after this change!

That was changed in my database.php file. I may have to take your advice and cut the code out. Thank you so very much Heart
Im getting this error and trying to fix it:

An uncaught Exception was encountered
(05-24-2019, 08:50 AM)MAILITY Wrote: [ -> ]
(05-22-2019, 04:52 PM)Mekaboo Wrote: [ -> ]
(05-22-2019, 03:04 PM)noobie Wrote: [ -> ]
(05-22-2019, 01:41 PM)Mekaboo Wrote: [ -> ]Hello all!

Im getting this error and trying to fix it:

An uncaught Exception was encountered

Type: Error
Message: Call to undefined function mysql_query()
Filename: /home4/cultured/public_html/application/views/dashboard.php
Line Number: 332

Its from this line of code: 
$mysql=mysql_query("select * from messages order by msg_id desc");

Im connected to DB (include("application/config/database.php")); and upgraded within webhost from 5.4 to 7.0 php but still get this error. I feel that I suppose to add the table (citable) that I made within the database but not sure. How to correct this if possible?

Heart Heart ,
Mekaboo

You are using the deprecated mysql_query function... (which is removed as of PHP 7.0)

Either you're using mysql_query manually in your script (which means your issue is not related to CI and you should read about MySQLi or PDO)

or you're using an ancient script which was set to use mysql, in that case:

Go to application => config => database.php and change from

PHP Code:
$db['default']['dbdriver'] = 'mysql'

to

PHP Code:
$db['default']['dbdriver'] = 'mysqli'

Not sure if your script can be trusted anymore in production even after this change!

That was changed in my database.php file. I may have to take your advice and cut the code out. Thank you so very much Heart
Im getting this error and trying to fix it:

An uncaught Exception was encountered
Got it caught, thank you Heart