Jump to content

Transitioning from Xampp


OzWaz

Recommended Posts

I have developed a small website with a simple database using XAMPP. It worked fine.

Now that I have uploaded it to a commercial hosting server, the PHP code that worked successfully within Xampp is being rejected

ERROR

[04-Jul-2023 02:55:12 UTC] PHP Fatal error:  Uncaught Error: Call to undefined method mysqli_stmt::get_result() in  home/n3hyilyj4kst/public_html/mydomain.online/galery/fetchit.php:22

Is this normal or is this a developing feature with commercial servers

Warren

Link to comment
Share on other sites

Thanks "requinix"  for your help

According to  XAMPP it is version: 5.2.1

That would explain this circumstance. - A bit like me asking you what you had for "smoko"?

But to deepen the mystery just a little, last year I developed a website for our local community as a noticeboard [ourplace.website] It functions perfectly and it recovers the data from the database using "$result = $stmt->get_result();" - It is hosted through GoDaddy (And still functioning)

My granddaughter has just gone to work in London and I am developing a website where she can paste information for the family and images that we can all share but does not belong to Facebook. In developing this website I use the same code that functions on ‘ourplace’ - And it to is hosted by GoDaddy - also.

I do know GoDaddy has been around for over 20 years and my understanding is that recently it changed hands and was purchased by one of the bigger conglomerates so maybe they were running an older version of PHP and the new guys have updated the system but I'm just including this information for the purposes of completeness.

So it would now be a given that the commercial server would be running the latest, how do i resolve this issues as i an really not a php Guru I just 'borrow' code for the web that does a job

Thanks - Warren 

Link to comment
Share on other sites

It's rather unlikely that GoDaddy is running a PHP that isn't using mysqlnd. And I'm not sure that existed in the time of PHP 5.2. So this situation you're describing seems backwards.

First things first, though: PHP 5.2 is extremely out of date. You need an version of XAMPP that has PHP 7.4 - to match what your real website is running.
Frankly, I'm amazed XAMPP even provides PHP 5.2...

Link to comment
Share on other sites

3 hours ago, OzWaz said:

 

I do know GoDaddy has been around for over 20 years and my understanding is that recently it changed hands and was purchased by one of the bigger conglomerates so maybe they were running an older version of PHP and the new guys have updated the system but I'm just including this information for the purposes of completeness.

 

GoDaddy has a bunch of different hosting plans, and lots of servers.  Experience with one particular server, doesn't predict exactly what you might experience with a different account, that is likely hosted on a different server.  You can get a lot of information just using phpinfo() on each.

As Requinix has already discussed, the issue points to lack of the mysqlnd driver.  In GoDaddy's cpanel, you can change php configurations using the Select PHP Version.  In the menu, I'm guessing you'll see mysqli checked, and nd_mysqli unchecked.  There should also be a choice for mysqlnd, that may or may not be checked.  If it is not checked, check it.  Uncheck the mysqli option, and check the nd_mysqli option.    Save this new configuration, and then retry your code.  Please let us know if this fixes the issue.

Link to comment
Share on other sites

Thanks Gizmola for your assistance

I am already out of my depth in this subject. I have included a screenshot of the only place in GoDaddy's  cPanel (DATABASES) I can find any mention of php and that is in the side panel of phpMyAdmin

I have been unable to locate anything in their cPanel that is labelled "Select PHP version".

Warren

 

gd1.png

Link to comment
Share on other sites

UPDATE:

To try and determine what part  php on the server plays in my problem I grabbed a domain WHYMYPHP.ONLINE and uploaded the files, that I used for my website 12 months ago containing [Line 22 "$result = $stmt->get_result();"] into a directory in my hosting plan and they still worked perfectly. [Take a look if it helps]

Now of course I don't know how GoDaddy runs their hosting business as to whether or not a single person's account and thereby their hosted websites all sit on the one server or whether like playing poker the cards get dealt, one card at a time to all the players sitting around the table. In which case my websites are spread consecutively around all the servers operated by the company.

But I think it is interesting that I can still display the material from a database onto a website with go daddy that I have just established today but not the ones in my other website (omglondon.online)

Does this help at all in your consideration of where the problem most likely lays

Thanks

Warren

Link to comment
Share on other sites

the OP's screen prints show something interesting. libmysql is specifically listed, though it is not clear if this is just how the database client is being listed or if both of those are present.

on the offending hosting, what does the mysqli section in the output from a phpinfo() statement in a .php script file show?

how much overall database specific code do you have? converting to the much simpler and more modern PDO extension would eliminate this problem completely.

Link to comment
Share on other sites

2 hours ago, OzWaz said:

UPDATE:

To try and determine what part  php on the server plays in my problem I grabbed a domain WHYMYPHP.ONLINE and uploaded the files, that I used for my website 12 months ago containing [Line 22 "$result = $stmt->get_result();"] into a directory in my hosting plan and they still worked perfectly. [Take a look if it helps]

 

I looked at the site, opened the menu and tried to navigate to:  http://whymyphp.online/galery/fetchit.php which produces a 500 error.  This is the same issue we've been looking at, and we keep coming back to the fact that mysqli is not the version that has been linked to the myslqnd driver.   This is not by any means a new issue.  See this 4 year old SO question.  The confusion relates to godaddy and cpanel, and the specific extensions that are enabled through cpanel.  

At this point, it is pretty much up to the OP to enable the right extensions through cpanel.

Link to comment
Share on other sites

Okay I have located the correct area . Godaddy's webpage does not match their current lay out  -but I found it thanks to your help

Here are my choices-Below screen print

As you will see these are the only options

There is not facility to do this "you'll see mysqli checked, and nd_mysqli unchecked.  There should also be a choice for mysqlnd, that may or may not be checked.  If it is not checked, check it.  Uncheck the mysqli option, and check the nd_mysqli option."

Thanks

Warren

gd2.png

Link to comment
Share on other sites

Have you tried putting this code into a php file and running it to see what you have?

 

<?php

// Show all information, defaults to INFO_ALL
phpinfo();

?>

 

in your web browser use edit/find in page and search for mysqlnd. That would be for firefox browser. Chrome browser would be search/find

Edited by dodgeitorelse3
added more content
Link to comment
Share on other sites

just because the mysqlnd driver is loaded, doesn't mean that mysqli (or PDO_mysql) will use it, if mysqli wasn't built to use the mysqlnd driver. the mysqli section, Client API library version, would read - mysqlnd 7.4.33, and the last line in the mysqlnd section, API extensions, would list mysqli.

to get this to work, your php installation, regardless of php version (5.3+), must be built to include the mysqlnd driver (which it apparently has been) and the mysqli extension must be built to use the mysqlnd driver (which it has not been.)

i'll ask/suggest this again -

On 7/6/2023 at 6:47 PM, mac_gyver said:

how much overall database specific code do you have? converting to the much simpler and more modern PDO extension would eliminate this problem completely.

 

Edited by mac_gyver
Link to comment
Share on other sites

why are you using an obsolete and no longer supported php version? as long as your code isn't using any previously deprecated features that have been removed in php8+, most straight-forward code should work as is under php8+.

it is more likely that the currently supported versions of php have had the mysqli extension built to use the mysqlnd driver. temporarily switch to one of the php8+ versions and check the phpinfo() output to see if/which database extensions are listed in the mysqlnd section, API extensions.

if you post your code, someone could advise how to convert it to use the PDO extension, or could possible do it for you out of shear frustration at how simple the PDO extension is to learn and use over the mysqli extension. 

Edited by mac_gyver
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.

×
×
  • 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.