BullGuard Antivirus Sale - 60% Off with openElement !
openElement Website Homepage
Forum Home Forum Home >

openElement

> Dynamic OE - Databases, etc
  New Posts New Posts RSS Feed - OE and Mysql
  FAQ FAQ  Forum Search   Register Register  Login Login

OE and Mysql

 Post Reply Post Reply Page  123>
Author
Message
Consult View Drop Down
Newbie
Newbie


Joined: 28 Jan 2020
Location: Belgium
Status: Offline
Points: 13
Post Options Post Options   Thanks (0) Thanks(0)   Quote Consult Quote  Post ReplyReply Direct Link To This Post Topic: OE and Mysql
    Posted: 29 Jan 2020 at 19:49
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.
Back to Top
Hobby001 View Drop Down
Admin Group
Admin Group
Avatar

Joined: 05 Juin 2018
Location: Canada, Québec
Status: Offline
Points: 4589
Post Options Post Options   Thanks (0) Thanks(0)   Quote Hobby001 Quote  Post ReplyReply Direct Link To This Post Posted: 29 Jan 2020 at 20:46
Hello,

I am answering without a large experience with OE and databases

Look in the site Explorer pannel.

Under databases there is a default database.

Double click on it and select MySQL instead of SqlLite for server connection 

After that you will have connect to to it.  Therefore I can't help any further but

You may take a blank new project, select your database  and then install the packs UserSpace01.

This process creates php pages with connections to a database.  You may start from there to define your own process.

Hoping that it will  help you,

Hobby001


Edited by Hobby001 - 29 Jan 2020 at 21:11
Anyone who wants to put something on line gets hooked by something big
Back to Top
Consult View Drop Down
Newbie
Newbie


Joined: 28 Jan 2020
Location: Belgium
Status: Offline
Points: 13
Post Options Post Options   Thanks (0) Thanks(0)   Quote Consult Quote  Post ReplyReply Direct Link To This Post Posted: 29 Jan 2020 at 21:57
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.
Back to Top
Hobby001 View Drop Down
Admin Group
Admin Group
Avatar

Joined: 05 Juin 2018
Location: Canada, Québec
Status: Offline
Points: 4589
Post Options Post Options   Thanks (0) Thanks(0)   Quote Hobby001 Quote  Post ReplyReply Direct Link To This Post Posted: 29 Jan 2020 at 22:25
Anyone who wants to put something on line gets hooked by something big
Back to Top
Consult View Drop Down
Newbie
Newbie


Joined: 28 Jan 2020
Location: Belgium
Status: Offline
Points: 13
Post Options Post Options   Thanks (0) Thanks(0)   Quote Consult Quote  Post ReplyReply Direct Link To This Post Posted: 29 Jan 2020 at 23:03
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.

Back to Top
Hobby001 View Drop Down
Admin Group
Admin Group
Avatar

Joined: 05 Juin 2018
Location: Canada, Québec
Status: Offline
Points: 4589
Post Options Post Options   Thanks (0) Thanks(0)   Quote Hobby001 Quote  Post ReplyReply Direct Link To This Post Posted: 30 Jan 2020 at 03:54
First question, do you have positive connection confirtmation?
Anyone who wants to put something on line gets hooked by something big
Back to Top
Consult View Drop Down
Newbie
Newbie


Joined: 28 Jan 2020
Location: Belgium
Status: Offline
Points: 13
Post Options Post Options   Thanks (0) Thanks(0)   Quote Consult Quote  Post ReplyReply Direct Link To This Post Posted: 30 Jan 2020 at 13:34
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.
Back to Top
Hobby001 View Drop Down
Admin Group
Admin Group
Avatar

Joined: 05 Juin 2018
Location: Canada, Québec
Status: Offline
Points: 4589
Post Options Post Options   Thanks (0) Thanks(0)   Quote Hobby001 Quote  Post ReplyReply Direct Link To This Post Posted: 30 Jan 2020 at 15:00
Can you echo some values to Chrome console^

$variable = "some values from your database";
echo "<script>console.log('$variable');</script>";

Not absolutely sure on syntax.
Anyone who wants to put something on line gets hooked by something big
Back to Top
Consult View Drop Down
Newbie
Newbie


Joined: 28 Jan 2020
Location: Belgium
Status: Offline
Points: 13
Post Options Post Options   Thanks (0) Thanks(0)   Quote Consult Quote  Post ReplyReply Direct Link To This Post Posted: 30 Jan 2020 at 15:40
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.
Back to Top
Hobby001 View Drop Down
Admin Group
Admin Group
Avatar

Joined: 05 Juin 2018
Location: Canada, Québec
Status: Offline
Points: 4589
Post Options Post Options   Thanks (0) Thanks(0)   Quote Hobby001 Quote  Post ReplyReply Direct Link To This Post Posted: 30 Jan 2020 at 20:10
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.


Anyone who wants to put something on line gets hooked by something big
Back to Top
 Post Reply Post Reply Page  123>
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 10.11
Copyright ©2001-2012 Web Wiz Ltd.

This page was generated in 0,031 seconds.