Database access

sixis

yeaaaa

from the code module section i succeeded whith this:

//Auslesen
$query = "SELECT * FROM tablename WHERE ID = 1";
$get_content = $database->query($query);

$content = $get_content->fetchRow(MYSQLI_ASSOC);
$content = ($content['email']);  // \htmlspecialchars

echo $content;


THANK YOU ALL

dbs

You should have a look into core modules (like news, form, code) to learn.
E.g. to read a single result you can use
$database->get_one('SELECT ...
[url="https://onkel-franky.de"]https://onkel-franky.de[/url]

sixis

You are my hero  :-D
Thank you

Updating works nice :-)

I realize i have to learn a lot e.g. how to readout the table

$database->query("SELECT * FROM wb_users WHERE username = test");
while ($data = mysqli_fetch_assoc($database))
{$mailadress=$data[email];
echo $mailadress;
}

Ruud

WB2.8.1 used MySQL, where the current WB versions (and PHP) use MySQLi.
mysqli_query() needs the handle that was created when the connection to the database was made.

WB has the $database class you can use. The correct way would be:
<?php 
$database
->query("YOUR QUERY");
// if you want to crash on errors (not recommended)
if($database->is_error()) die("Error: ".$database->get_error();


[url=https://dev4me.com/modules-snippets/]Dev4me - WebsiteBaker modules[/url] - [url=https://wbhelp.org/]WBhelp.org[/url]

sixis

After updating to 2.12.2 i cant access the database in the code section as before (2.8.1)

Maybe someone has in idea whats wrong with my code.

mysqli_query ("UPDATE tablename SET column ='$xxxxxxx' WHERE ID=1") or die ("MySQL-Fehler: " . mysqli_error());

old code that worked:

mysql_query ("UPDATE tablename SET column ='$xxxxxxx' WHERE ID=1") or die ("MySQL-Fehler: " . mysql_error());