I have some difficulty loading the database
I have tried various solutions but I always get errors that prevent the page from being displayed
Wanting to simplify to the minimum, in order to coexist with a Wappler page, how should PHP code be set before HTML?
Where am I wrong?
…
The php code should be BEFORE the tag, cant tell from your screenshot. What are the errors?
Yes the code is before html and close after /html
But with this code the page not work and Google report HTTP ERROR 500
A 500 error is a generic error. You need to show us the actual error via this procedure
In my honest opinion one thing i would try is before
$servername = "localhost"
Add another line and store your $_GET
inside it’s own php variable, then call the variable in the $stmt
rather. Right now you are kind of mixing languages together if that makes sense, and the AppConnect language and bindings would only work inside either a <body is="dmx-app">
or <html is="dmx-app">
So first test by trying a simple <?php echo $_GET['id']; ?>
and see if anything is even output, i have a feeling it won’t.
Good idea Paul
try adding (in the parameters section)
$id = $_GET['id'];
change your select statement to:
"SELECT * FROM products where idprod =" . $id
Not to confuse anything but just something for my own learning too is there any difference between these two ways of writing it @Hyperbytes or would it make no difference as such. I always try use the most semantically correct way, and yours looks cleaner, so just checking.
"SELECT * FROM products WHERE idprod = '$id'"
the way i would have written it vs your way of
"SELECT * FROM products where idprod =" . $id
Just went with code i have on an existing live page so I know it works, 100% sure
Should both work
EDIT: i hate nesting quote types if that can be avoided, just one of my many coding peculiarities
With your advice, the page now opens regularly, but the database call
gives me an error in the Facebook Debugger
If set like this,
it is OK but of course it only considers the first record it finds
I tried in every way, but I absolutely cannot get Facebook sharing to work dynamically
@Marzio could you share a link to the page so we can try it inside the facebook debugger please.
The tutorial was based on my own website, and it is used as I showed every day and seems to work fine in facebook, please take a look at one of my pages, sorry it kept changing the link so you will have to copy and paste it in
https://developers.facebook.com/tools/debug/?q=https%3A%2F%2Fwww.africacollection.com%2Fthe-seychelles-travel-itinerary-packages%2Fseychelles-purely-beach-holiday-travel-itinerary%2F
To better verify the problem I am recreating the procedure on a currently unused domain
If I still encounter the problem, it will be easier to locate the error
I will give you the link to the page as soon as completed
I created a test connection on vacanzemarine.it domain
This is the file that lists the contents of the database
https://www.vacanzemarine.it/test/index.php
This is the test page (see code source)
https://www.vacanzemarine.it/test/test_fb.php
This is the Facebook Debugger page (with code = 1) that doesn’t work
https://developers.facebook.com/tools/debug/?q=https%3A%2F%2Fwww.vacanzemarine.it%2Ftest%2Ftest_fb.php%3Fprod%3D1
On your test page please click App inside the App Stucture tree, then in the properties where you have App Root, please make sure that is set to Page and not Body or App Connect will ignore all the stuff in the head.
Let me know if that fixes it please.
If you are using PHP code in the meta tags it doesn’t matter where the app root is set to.
PHP code is rendered on the server side before the page is loaded.
I figured, but i cant see his real code, only that tiny part, so not sure whats going on in there, just figured it could be worth a try
it is now configured on Page but nothing has changed