Database viewer not showing anything except the search field
Author: Gabriella T.
Visited 604,
Followers 1,
Shared 0
Hello, here's my issue:
I created a form on my website which sends data to a database.
This part works, data is saved and I can visualize it if I connect to the database myself.
Next, I bought the Database Viewer object to integrate it to a page for people to see the data saved in the database by the form.
I exported the project, and it only shows the search field.
The name of the table in the object's configuration is correct, I quadruple checked it.
What could be going wrong ? It appears as it should in websitex5's preview, but when exported, it's broken.
Posted on the
Hello Gabriella,
Is the database hosted on the same server as your WebSite X5 project?
During your testing phase (when the Database Viewer worked correctly) were you connecting to a different (perhaps local) database?
WebSite X5 will currently work with any version of PHP from 7.1 to 7.4, and any version of MySQL newer than 5.6 - MariaDB databases can be a little awkward to configure.
Kind regards,
Paul
Search the WebSite X5 Help Center
Author
Hello Paul,
Thank you for your answer.
Yes the database is hosted on the same server as the website.
When the datbaseviewer worked, it was in the built-in preview of websitex5. So not online and not yet connected to my database.
I checked versions of PHP and MySQL, PHP is already on 7.4, and I updated MySQL from 5.6 to 5.7. After updating, I deleted the database, recreated a new one to make a new test, and it's still not working.
The user's login informations I provided in the step 1 data parameters has permission to read, write and admin.
I tried to login manually with phpMyAdmin, and surely I can view or edit the database. I can also confirm that the website is successful at creating new tables and writing on them.
So I really don't know where else to look. If the website was not able to READ the database, it should still show the "design" of the Database Viewer, right ? Instead of just the search field.
I thought maybe my table had too many fields (9) so I created a new form with 4 fields. Form successfully created a new table with correct data on the database, but this table is also not showing with Database Viewer.
Thanks for the additional information, Gabriella.
The image and data shown in your screenshot of the WebSite X5 Preview is dummy data which acts as placeholder text - all WebSite X5 projects will show this same fake data while previewing. It's not real data, and it doesn't represent a connection to your actual database. In actual fact, it's not possible to verify the Database Viewer operation in the Preview mode alone, as borne out by the text highlighted below:
The WebSite X5 Preview doesn't utilise PHP in any way, so it can't use PHP scripts to connect to your database. This can only happen once your project has been exported to the server.
I've run some tests for you this afternoon, and I can't find any issue whilst using the Database Viewer in the current version of WebSite X5 (2020.2.6), so I'm quietly confident this is not a bug. If you're not already on 2020.2.6 then it would be a good idea to update the software.
My next suggestion would be to look at the error logs on the server, because when the database operation does not succeed this will almost certainly be noted there. This could provide a valuable clue as to which part of the WebSite X5/PHP/MySQL jigsaw is not configured correctly.
There is a built-in Website Test section within the online control panel of each WebSite X5 project:
WebSite X5 online control panel
This can help you verify whether PHP and MySQL are installed correctly on your server. Can you run the tests and check whether you get 'PASSES' for each?
Author
Hello Paul,
Thanks a lot for your advices.
I started by updating WebSite X5, which did not fixe the issue but was indeed a good thing to do, and then tried to use the website control panel.
In the website test section, on the fourth line, the "mysql database parameters" gets a green "PASS".
I get a green pass for the four tests.
However, as you can see on the screenshot, there are two error messages appearing at the top of the window :
Deprecated: Unparenthesized `a ? b : c ? d : e` is deprecated. Use either `(a ? b : c) ? d : e` or `a ? b : (c ? d : e)` in /home/clients/b924db045193eaaca8b70ce0f1f57a66/web/res/x5engine.php on line 5719
Deprecated: Unparenthesized `a ? b : c ? d : e` is deprecated. Use either `(a ? b : c) ? d : e` or `a ? b : (c ? d : e)` in /home/clients/b924db045193eaaca8b70ce0f1f57a66/web/res/x5engine.php on line 7462
I opened that file (x5engine.php) on the server's FTP to have a look at these lines, which are:
5719:
$conditions[] = (is_string($value) ? 'BINARY ' : '') . '`' . $column . '` ' . (is_null($value) ? 'IS' : is_array($value) ? 'IN' : '=') . ' ' . $this->_to_sql_value($value);
7462:
$id_condition = $ids_count == 1 ? intval($ids[0]) : $ids_count > 1 ? array_map('intval', $ids) : false;
I have no idea if this may be related to my problem or not... I have 0 coding experience in any language. But the line 5719 seems to be related to sql so... maybe ?
Thanks again for your help.
Kind Regards,
Gabriella
This could indeed have a bearing on the problem, Gabriella.
It would appear that your server is currently configured to display PHP 'notices' - unfortunately, this can halt PHP script execution. Your issue in this regard is almost identical to the one in the following thread:
https://helpcenter.websitex5.com/en/post/232677
Please ask your webhost to suppress the display of PHP notices (it's fine to log them silently in the background), or you can do this yourself if you know how and have the necessary access to your server.
Then please try logging in to the WebSite X5 online control panel once more, and also try using the Database Viewer as before.
Author
Hello again Paul,
So I contacted my host as to how disable php notices, I did not find any option on their control panel.
However, in the meantime, I decided to downgrade the php version for the website from 7.4 to 7.3, and now it seems to work. Database Viewer object is indeed showing correctly on the exported website.
Also, there's no more php notice on the admin page. So this might have been the problem (even though the notice was only present on the /admin page).
So I guess that will do for now! I'll still try to run it with php 7.4 and the notice disabled once the host gets iback to me.
Thanks a lot for your time and your help!
Kind Regards
Gabriella
You're welcome, and you have definitely got to the heart of the matter.
What's happening here is as a result of the continual evolution and revision of the PHP language.
Deprecated code at some point needs to be addressed (and will be, of that I have no doubt) - but it is also still valid code for the time being, and the point behind the PHP 'notice' is to remind the developers of the need to revise this part of the codebase, behind the scenes during the testing and development phase only. Notices should not be active on a public facing website.
You did exactly the right thing in going back to PHP 7.3 for now.
That should work just fine
Good luck with your web design!