OE and Mysql |
Post Reply | Page 123> |
Author | |
Consult
Newbie Joined: Jan 28 2020 Location: Belgium Status: Offline Points: 13 |
Post Options
Thanks(0)
Posted: Jan 29 2020 at 6:49pm |
Hello, for a couple of weeks i'm having trouble showing a webpage with on it a table showing content from a mysql database. I managed to write the code for that outside OE and when i run it in my server everything is fine. But I would like to use it inside OE and I tried everything, with code blocks, source and visual, all kind of combinations, so far nothing really happened. Is there anyone out there who can help me with this? Thanks in advance.
|
|
Hobby001
Admin Group Joined: Jun 05 2018 Location: Canada, Québec Status: Offline Points: 6195 |
Post Options
Thanks(0)
|
Hello,
After that you will have connect to to it. Therefore I can't help any further but Hoping that it will help you, Hobby001
Edited by Hobby001 - Jan 29 2020 at 8:11pm |
|
Consult
Newbie Joined: Jan 28 2020 Location: Belgium Status: Offline Points: 13 |
Post Options
Thanks(0)
|
Thank you Hobby001. But I don't think this solves my problem. I tried this allready. The Userspace gives you connection to a database backend used mainly for user control etc. What i want is to connect to one of my own databases, do a sql query on one of my own tables, and display the content on a webpage.
Thanks anyway.
|
|
Hobby001
Admin Group Joined: Jun 05 2018 Location: Canada, Québec Status: Offline Points: 6195 |
Post Options
Thanks(0)
|
Consult
Newbie Joined: Jan 28 2020 Location: Belgium Status: Offline Points: 13 |
Post Options
Thanks(0)
|
Thank you to send me this link. I used it also to write my php code outside OE to connect to my database. It works. On the other hand, i want to do this now from within OE and it doesn't work at all.
See my code below : <?php include_once('connection.php'); $query='select naam, straat, nr, gemeente from veggieresto order by naam'; $result=mysqli_query($connection,$query); ?> <!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8" / <title> </title> </head> <body> <table align="center" border="3px" style="width:800px; line-height:20px"; cellpadding="4"> <tr> <th colspan="4"><h2>Vegetarische Eetgelegenheden</h2></th> </tr> <tr><th> Naam</th><th>Straat</th><th>Nr</th><th>Gemeente</th> </tr> <?php if $connection echo 'Verbinding met database geslaagd'; while($rows=mysqli_fetch_assoc($result)) { ?> <tr> <td><?php echo $rows['naam']; ?></td> <td><?php echo $rows['straat']; ?></td> <td align="right"><?php echo $rows['nr']; ?></td> <td><?php echo $rows['gemeente']; ?></td> </tr> <?php } ?> </table> </body> </html> In the include statement in the first line, i include another php script 'connection.php', where i make the connection with the database. What you see here works fine outside Open Element. |
|
Hobby001
Admin Group Joined: Jun 05 2018 Location: Canada, Québec Status: Offline Points: 6195 |
Post Options
Thanks(0)
|
First question, do you have positive connection confirtmation?
|
|
Consult
Newbie Joined: Jan 28 2020 Location: Belgium Status: Offline Points: 13 |
Post Options
Thanks(0)
|
With the above listed code, i have a positive confirmation about my connection, if i use it stand alone, outside OE. From within OE I receive nothing. The only thing I can see on my webpage in OE is the heading of my table that is declared between the <th> and </th> elements. For the rest i can see nothing. So, probably the connection with my database is not established, but i'm asking myself then why it works outside OE? Is there something in OE I should do diffirently, i really don't know. Thanks for all the help you're trying to give me.
|
|
Hobby001
Admin Group Joined: Jun 05 2018 Location: Canada, Québec Status: Offline Points: 6195 |
Post Options
Thanks(0)
|
Can you echo some values to Chrome console^
Not absolutely sure on syntax.
|
|
Consult
Newbie Joined: Jan 28 2020 Location: Belgium Status: Offline Points: 13 |
Post Options
Thanks(0)
|
I'm not sure what you mean by 'Chrome console'.
It's a fact that I can run my code, as you saw it in my previous post, in my local webserver through the localhost. When I run other pages from my OE website via localhost everything is fine. I read also psts by DMIT who says that if you want to use Mysql database, you cannot use the preview provided by OE, but you have to run it against localhost webserver. I use WAMP who displays my normal OE webpages correctly, only when i want to use values from Mysql database, it won't work.
|
|
Hobby001
Admin Group Joined: Jun 05 2018 Location: Canada, Québec Status: Offline Points: 6195 |
Post Options
Thanks(0)
|
When you use Chrome to see a web page, press <F12> to access the console to see user messages. This is where you can see messages that comes from console.log javascript command.
I was asking if you can echo some info from your database to the console trying to troubleshoot without any access to your system. |
|
Post Reply | Page 123> |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |