TecTao Posted January 11, 2019 Share Posted January 11, 2019 I've been out of coding for about 4 years. My client called and said that they upgraded his server and now nothing works. I've don't done some reading and see that there are changes to queries. I originally wrote the program using mysql_query which is now deprecated replaced with MySQLi and PDO_MySQL which I thought would be that simple. Apparently not. My code is below. The error I get is Fatal error: Call to undefined function MySQLi() in /home1/zipclick/public_html/marketingteamates.com/_ZABP_merchants/main-w.php on line 304 which leads me to believe that the upgrade is now solely object oriented. $result = MySQLi( "SELECT * FROM $users WHERE username = '$username'" ) or die("SELECT Error: ". mysqli_errno()); $num_rows = mysqli_num_rows($result); while ($row = mysqli_fetch_array($result)) { extract($row); } Quote Link to comment Share on other sites More sharing options...
benanamen Posted January 11, 2019 Share Posted January 11, 2019 (edited) 19 minutes ago, TecTao said: $result = MySQLi( "SELECT * FROM $users WHERE username = '$username'" ) That is not real code. Perhaps the manual will be of help. You will have to break it to your client that his "upgrade" is still hundreds and hundreds of releases behind. The whole bit of the code you posted shows there is quite a bit of work that will need to be done to bring the app up to date. Version 5.5 reached end of life many years ago. http://php.net/manual/en/mysqli.query.php Edited January 11, 2019 by benanamen Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted January 12, 2019 Share Posted January 12, 2019 (edited) it would help to know what the old php version was. just an update to 5.5 (which should have or soon will be an update to 7+) doesn't break the mysql_ functions. it's more likely that the code is dependent on register_globals in order to function. if so, it will take rewriting all the code to use the actual php super global variables where the external $_GET, $_POST, $_FILES, $_COOKIE, and some $_SERVER variables are at. you would also want to update the code to use one of the current database extensions, and since query security also went away in php 5.4, in order to keep from having to add a bunch of code, it is better to switch to use prepared queries, with the php PDO extension, and to use exceptions to handle database statement errors. doing this will result in the simplest php code and simplest sql query syntax, which will reduce the amount of things you have to update, i.e. you can just eliminate a bunch of stuff, rather than to spend time on updating it. Edited January 12, 2019 by mac_gyver 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.