Noob Problem: I have an older script that works at PHP 5.6. would like to upgrade my server from PHP 5.6 to PHP 7.3 but this one piece of code is preventing me from doing so.
Here is the code snippet that it works OK at PHP 5.6:
16 <?php include("../admin/includes/database.php"); ?>
17 <?php function get_material($id_material,$conn)
18 { if (is_numeric($id_material)) {
19 $rrr="select * from materials where id_material=$id_material";
20 $rr=mysqli_query($conn,$rrr) ;
21 $r=mysqli_fetch_array($rr,MYSQLI_ASSOC);
22 if (mysql_error()) {return " ";} else {return $r["name_material"];}
23 } else return ""; }?>
This is the error that is output when upgrading the server to PHP 7.3
Fatal error: Uncaught Error: Call to undefined function mysql_error() in …/designer/user/print.php:23 Stack trace: #0 …/designer/user/print.php(409): get_material(‘11’, Object(mysqli)) #1 {main} thrown in …/designer/user/print.php on line 23
And this is the error when line 22 is changed to “mysqli_error” running on PHP 5.6.
Warning: mysqli_error() expects exactly 1 parameter, 0 given in …/designer/user/print.php on line 22
Any idea on how I can make this work on PHP 7.3
Thanks!