Jump to content

Error in a PHP MySQL CMS.


LeonLatex
 Share

Recommended Posts

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:

 

err_msg.png

Link to comment
Share on other sites

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 ?

Link to comment
Share on other sites

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 -

  1. use the much simpler, more consistent, and better designed PDO extension. it has no mysqlnd driver gotya's like this.
  2. 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.
  • Great Answer 1
Link to comment
Share on other sites

Posted (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 by LeonLatex
Link to comment
Share on other sites

.........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?

Link to comment
Share on other sites

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. 

  • Great Answer 1
Link to comment
Share on other sites

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 🤓🙄🤐

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.