LeonLatex Posted June 8, 2022 Share Posted June 8, 2022 I work on, or more rightly said, I found a tutorial online I am trying to learn from. This has been working for others, I know that. No matter what I do, writing the total script myself or downloading the finished files, I get the same error message. I think there can be two reasons because of this. The database is empty or the CMS doesn't support the old MySQL and PHP versions that is on my Web-hotel-room which is: MySQL 5.7.23 and PHP 7.1.33 I tried to fill in some information in the DB manually, but I am unsure if this was correct or successful. What do you think guys? This is the error msg. i get: Β Quote Link to comment Share on other sites More sharing options...
Barand Posted June 8, 2022 Share Posted June 8, 2022 mysqli::get_result() is not available on all implementations Another reason to ditch mysqli for PDO. 1 Quote Link to comment Share on other sites More sharing options...
LeonLatex Posted June 8, 2022 Author Share Posted June 8, 2022 Ahaaaaa.... now I see. Thank you Barand. You have told me about all the advantages of PDO compared to MySQLi. Sorry for not listening well enough when you said that to me. In a way, I met myself at the door now. Note to my self: Listen to others. As long as I know the MySQL on the server got a MySQLi add-on, what is your suggestion to do? Would it help to get rid of the add on in favor of a clean installation of MySQL 8.x.x ? Quote Link to comment Share on other sites More sharing options...
Barand Posted June 8, 2022 Share Posted June 8, 2022 As your CMS is using mysqli there isn't much you can do at that end (unless you want to rewrite it using PDO instead). You need to ensure that whatever version of MySql you use is implemented with the native driver (mysqlndnd) Β [PS] https://dev.mysql.com/downloads/connector/php-mysqlnd/ 1 Quote Link to comment Share on other sites More sharing options...
LeonLatex Posted June 8, 2022 Author Share Posted June 8, 2022 Thanks for the information Barand. I will ask my oldΒ colleagues to fix this. Quote Link to comment Share on other sites More sharing options...
LeonLatex Posted June 8, 2022 Author Share Posted June 8, 2022 I realized that I can activate this myself inside my control panel at the web hotel. Did so, but it did not help me. If there are no other solutions, I can call Erik tomorrow. Quote Link to comment Share on other sites More sharing options...
Barand Posted June 8, 2022 Share Posted June 8, 2022 Diid you try switching off then on again π 1 Quote Link to comment Share on other sites More sharing options...
LeonLatex Posted June 8, 2022 Author Share Posted June 8, 2022 (edited) Can someone please tell me what to activate and deactivate in the control panel so I can have the MySQL Native Driver work? Β Β Edited June 8, 2022 by LeonLatex Quote Link to comment Share on other sites More sharing options...
LeonLatex Posted June 8, 2022 Author Share Posted June 8, 2022 Yes, I have tried to switch it on and off again, but I suspect some of my choices can be in conflict with each other. So I need help with activating and deactivating the right choices. Se the image above Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted June 9, 2022 Share Posted June 9, 2022 the php mysqli extension on your system must be compiled to use the mysqlnd driver, for the get_result and a few other functions/methods to be available -Β https://www.php.net/manual/en/mysqlnd.install.phpΒ i'm not sure this can be accomplishedΒ just through the hosting control panel. you will know when you are successful when there is a mysqlnd section in the phpinfo() output on your system. if you cannot enable this, your choices are, rewrite the code to - use the much simpler, more consistent, and better designed PDO extension. it has no mysqlnd driver gotya's like this. eliminate the use of the mysqli get_result function/method, which will require you to useΒ mysqli_stmt::bind_result, and a bunch of code to dynamicallyΒ fetch data as a result set or do a bunch of typing for all the columns/variables you are selecting from each query. however, if you are going to go through this much work, for each query, you might as well just spend the time to do item #1. converting a mysqli prepared queryΒ to use the PDO extension is fairly straight forwardΒ - make the database connection using PDO, storing the connection in a variable uniquely named, such as $pdo, so that you can identify/search which code has been converted or not. the use of ? positional prepared query place-holders is the same between mysqli and PDO. change the $mysqli->prepare() calls to use the $pdo connection variable, e.g.Β $pdo->prepare(). take the list of variables you are supplying to the ->bind_param() call, and supply them as an array to the ->execute([...]) call. remove the bind_param() calls and the get_result() calls. fetch the data using one of PDO's fetch methods - fetch(), fetchAll(), ... note: if you are using a foreach() loop to iterateΒ over the msyqli result object (from the get_result call), you can loop over the PDO statement object in exactly the same way. for a non-prepared query, you would just use the PDO ->query() method instead of the mysqli ->query() method, thenΒ fetch/loop over the data as described above. any use of last insert id, num rows, or affected rows would need to use the equivalent PDO statements. 1 Quote Link to comment Share on other sites More sharing options...
LeonLatex Posted June 9, 2022 Author Share Posted June 9, 2022 (edited) I understand mac_gyver. I liked your suggestion to save the connection as a separate variable so that it can be easily rewritten automatically to POD. It's the simplest. I see it. But then I found some chapters in a book I bought here a while ago about this about rewriting from MySQLi to POD. So I guess I'll read up on this for a few days and give myself a try. Maybe I can put my name on it and hand it over to the developer and get as much credit as cred for the work of converting the database connection from MySQLi to POD. Barand tried over a year ago to make me understand why Pod instead of MySQLi. I have understood what he has said, but did not quite understand it anyway. Not until now do I see all the benefits of PDOs. At least some of them so as not to express myself too harshly. Because when I opened the book, I recognized so much of what Mr. B has said and tried to learn before. So sorry Barand for not listening to you enough. What I thought was most about simplicity was really security, and only security. And i also understand why so much is deprecated from PHP 7.0 and up today. The reason is because The old MySQL library and MySQL is outdated for reason(s). I understand much of the reason is: Security and because much of it is not excisting any more. Am I totaly wrong? Edited June 9, 2022 by LeonLatex Quote Link to comment Share on other sites More sharing options...
LeonLatex Posted June 9, 2022 Author Share Posted June 9, 2022 .........and that PDO has a user-friendliness that surpasses everything that has been before in relation to a PDO connection / querry fit on databases from MS SQL, Oracle, MySQL AB etc. Actually, Oracle is the developer of MySQL, isn't that right? Quote Link to comment Share on other sites More sharing options...
Strider64 Posted June 9, 2022 Share Posted June 9, 2022 A good website to understand PDO that I found is this one -> https://phpdelusions.net/pdo and I suggest creating a PHP sandbox to play around with PDO. After reading this thread I think you're concentrating too much on the mysql and other databases (which PDO can handle) than PHP PDO? I have been using PDO for sometime now, but I don't think it's easier to learn than mysqli, though once learned it is more versatile.Β 1 Quote Link to comment Share on other sites More sharing options...
LeonLatex Posted June 9, 2022 Author Share Posted June 9, 2022 Thanks Strider64. I will check it out. Sorry for my bad English sometimes. Of course, it was versatile I ment. Not friendliness as I said ππ Sorry for forcing you guys to read between theΒ lines sometimes π€ππ€ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.