How Schrödinger’s PHP method causing website crashed

Cyrus Chan
2 min readSep 13, 2021

Photo by Ben Griffiths on Unsplash

I just migrated my website from PHP 7.4 to 8.0 which using cPanel (and yes, 8.1 is in release candidate now). After the migration, I notice my navigation bar and footer is not rendered. Here is a PHP script:

(This PHP script will create a controller for storing LinkMeta which containing link’s name and URL address, then convert the controller to JSON object and parse as JavaScript to handle webpage render by DOM)

When I go to the PHP script site, it throw an error like this:

“Uncaught Error: Call to undefined method mysqli_stmt::get_result()”

(line 33 in navbar_footer.php)

And solved by replacing “get_result()” to store and bind result in the statement object (and luckily that only one file need to be modified):

However, PHP documentation said it supported PHP 8 here:

In theory, I can convert to PHP 8 without modify my code from PHP 7.4 since it said supported. But I searched and find a bunch of tutorials of fixing this error which released before the date of releasing PHP 8’s first version. It is confirmed that this method suppose should be defined but not with unknown reason. If this method is going to deprecated, why I can’t find any related content in the documentations?

In conclusion, “mysqli_stmt::get_result()” with unknown availability causing my website crashed. It should be have a better explanation on installing and using this method. Otherwise, just like me replacing an alternative code which proofed it worked.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Cyrus Chan
Cyrus Chan

Written by Cyrus Chan

0 Followers

Official rk0cc Medium account. With pushing opinion of my viewpoint of IT and gaming related topic

Responses (2)

Write a response

You are mixing PHP and JS code in same script, you're using SQL requests in code despite ORM exists, your PHP code doesn't respect PSR rules : thois is a very bad article with very bad code.
Try frameworks like Laravel or Symfony, your code will be better.

--

Yikes, this code looks like it was written in 2001 and never revised.

--