PHP MySql Unable to connect Are there recent changes
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Plusnet Community
- :
- Forum
- :
- Help with my Plusnet services
- :
- Everything else
- :
- Re: PHP MySql Unable to connect Are there recent c...
PHP MySql Unable to connect Are there recent changes
19-08-2018 4:33 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Until very recently I have had a page that serves up a database on ccgi.username.plus.com.
Today, the PHP seems to be working, but the page that completes the connection does not complete, or issue an error message.
The php line I use is:
$connection = mysql_connect($host,$user,$password) or die ("couldn't connect to new server");
I have verified that the $host, $user and $password have been set correctly using the MySql Manager at hosting.plus.com
I saw another thread that there has been an upgrade to PHP7.
Do I need to change some basic PHP functions?
Before you ask, I have verified that the data is visible in the Database manager on hosting.plus.com
Re: PHP MySql Unable to connect Are there recent changes
19-08-2018 4:45 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
This subject came up a few days back. Suggest you read https://community.plus.net/t5/Everything-else/PHP-files-not-being-served-at-ccgi-username-plus-com/m... particularly @bobpullen post #10
Hopefully that Topic will give you some clues?
Superusers are not staff, but they do have a direct line of communication into the business in order to raise issues, concerns and feedback from the community.
Re: PHP MySql Unable to connect Are there recent changes
19-08-2018 7:14 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Bob Pullen
Plusnet Product Team
If I've been helpful then please give thanks ⤵
Re: PHP MySql Unable to connect Are there recent changes
19-08-2018 7:41 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Yes, as mentioned in the topic @MauriceC linked to the version of PHP was updated a few days ago to version 7.1.15. Whilst continued use of mysql_* functions was deprecated some time ago, the complete extension was removed in PHP 7 and needs to be replaced by mysqli_* equivalents. For example the equivalent of your mysql_connect statement, and the mysql_select_db statement which will follow it is
$connection = @mysqli_connect($host, $user, $password, $database) or die('Connect Error ('
. mysqli_connect_errno() . ') ' . mysqli_connect_error());
It is necessary that $connection is the first parameter in subsequent mysqli_* statements which access the database (rather than just manipulating query result objects).
The PHP manual which references all the mysqli functions can be found at http://php.net/manual/en/mysqli.construct.php
Updating from mysql_* to mysqli_* requires care but is not difficult.
Re: PHP MySql Unable to connect Are there recent changes
19-08-2018 8:50 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Many thanks to all respondents
I have temporarily reverted to PHP5, and renamed htaccess. file.
I shall be looking to revise to mySqli in the very near future.
David
Re: PHP MySql Unable to connect Are there recent changes
30-08-2018 4:57 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
I am having the same difficulty. Nothing has changed on the client or the server but no data is retrieved.
Using Linux, PHP, MySQL and Javascript to retrieve data into a series of Javascript dropdowns.
Has worked perfectly for years yet Plusnet techies can find no reason why nothiing is being retrieved.
It's as though the Database functionality is of relatively little interest.
I'd move my Database to another host but that evades the issue of why it's stopped.
Re: PHP MySql Unable to connect Are there recent changes
30-08-2018 5:21 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Almost certainly the problem will be because Hostopis recently updated PHP to version 7.1.15. This version no longer provides the basic MySQL extension which was accessed using mysql_* function calls. All such calls need to be replaced by improved MySQL equivalents which include a letter "i", ie mysqli_*
Guidance on what is required is given in message 4 above which is expanded on in post https://community.plus.net/t5/Everything-else/PHP-files-not-being-served-at-ccgi-username-plus-com/m...
The ereg extension was also removed which includes the split and spliti functions. preg_split is a suitable replacement for those.
It is possible to use phpManager from the Hosting Control Panel to temporarily switch back to PHP 5.6 but doing that could cause problems if PHP sessions are used.
Re: PHP MySql Unable to connect Are there recent changes
06-02-2019 8:13 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Can anyone pleas help!
With the upgrade to PHP7 all may session/mysql related php pages became inaccessible.
After weeks of reading forum posts, I have finally managed to sort out most mysql to mysgli issues.
However I am stuck on one problem which throws a Fatal error, namely: Uncaught Error: Call to undefined function mysqli_result() in /services/webpages/util/c/c/ccgi….. file.php:43 Stack trace: #0 {main} thrown in /services/webpages/util/c/c/ccgi……..file.php on line 43
The php code in question is as follows:
Re: PHP MySql Unable to connect Are there recent changes
06-02-2019 11:51 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Doesn't look like there's a mysqli_result() function in PHP7.
Bob Pullen
Plusnet Product Team
If I've been helpful then please give thanks ⤵
Re: PHP MySql Unable to connect Are there recent changes
07-02-2019 1:21 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
As Bob said the PHP developers did not replace mysql_result when building the mysqli extension. This was for very good reasons.
To make your code work try
$row = mysqli_fetch_row($result);
to extract the complete row from the query resource (albeit an array with only one element(, then use $row[0] in place of the failing mysqli_result() call on line 43.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Plusnet Community
- :
- Forum
- :
- Help with my Plusnet services
- :
- Everything else
- :
- Re: PHP MySql Unable to connect Are there recent c...