Atom.CMS icon indicating copy to clipboard operation
Atom.CMS copied to clipboard

Video -19 Creating a settings table in the MySQL Databace

Open Someshojha opened this issue 9 years ago • 1 comments

Hi,

I am getting below error after pasting the code on data.php from setup.php:

Fatal error: Uncaught Error: Call to undefined function mysql_fetch_assoc() in C:\xampp\htdocs\project\Dynamic\AtomCMS\Functions\data.php:8 Stack trace: #0 C:\xampp\htdocs\project\Dynamic\AtomCMS\Config\setup.php(15): data_setting_value(Object(mysqli), 'debug-status') #1 C:\xampp\htdocs\project\Dynamic\AtomCMS\index.php(1): include('C:\xampp\htdocs...') #2 {main} thrown in C:\xampp\htdocs\project\Dynamic\AtomCMS\Functions\data.php on line 8

This the code on data.php: function data_setting_value($dbc, $id){ $q = "SELECT * FROM settings WHERE id = '$id'"; $r = mysqli_query($dbc, $q);

$data = mysql_fetch_assoc($r);

return $data['value'];

}

and this the code on setup.php:

$debug = data_setting_value($dbc, 'debug-status');

Why it is not taking $r variable? Please help, i am stuck.

Someshojha avatar May 09 '16 07:05 Someshojha

You have to use mysqli, and not mysql. Code:

$data = mysqli_fetch_assoc($r);

creptor avatar May 09 '16 22:05 creptor