php - Changing from MYSQL to MYSQLI funstions -


i trying learn how create crud tool first taste of playing mysql. using following tutorial: http://trendinquirer.com/simple-crud-in-php-add-edit-delete-view-in-php/

building on wamp server locally.

i have functions working every page giving me mysql deprecation warnings.

i new , wondering if can give me pointers seem new make sense of php manual.

when change:

<?php mysql_connect('localhost','username','password'); /** syntax ==> mysql_connect(servername,username,password); **/    mysql_select_db('development_logs'); /** select databasename **/ 

to:

$connection = mysqli_connect('localhost','username','password'); if (!$connection) { die("database connection failed: " . mysqli_error()); }  // 2. select database use  $db_select = mysqli_select_db($connection, 'development_logs'); if (!$db_select) { die("database selection failed: " . mysqli_error()); } 

i whole new set of errors corresponding index.php page around string:

<?php $result = mysql_query("select * website_logs"); while($data = mysql_fetch_object($result) ): ?> 

any on @ least getting past point hugely appreciated.

you need use mysqli_connect_error() report problem mysqli_connect(), because mysqli_error() requires connection argument.

once open connection, have use mysqli_query() , mysqli_fetch_object(). mysqli_query() requires $connection first argument:

$result = mysqli_query($connection, "select * website_logs") or die ("query failed: " . mysqli_error($connection)); while ($data = mysqli_fetch_object($result)) {     ... } 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -