<?php
try {
$conexion = new PDO('mysql:host=tanukilibros.com;dbname=tanukili_tanuki;charset=utf8', 'username', 'password');
} catch (PDOException $e) {
echo "ERROR: " . $e->getMessage();
die;
}
<?php $booksInfo = $conexion->prepare( "SELECT libros.Titulo, autores.nombres, autores.apellidos, libros.cubierta, libros.link FROM libros INNER JOIN autores ON libros.Autor = autores.ID ORDER BY libros.ID DESC LIMIT 4;" ); $booksInfo->execute(); $booksInfo = $booksInfo->fetchAll ();
This question has been answered by BobRay. See the first response.
[[snippet1]] [[snippet2]]
/* Snippet1 */ $x = 'hello';
/* Snippet2 */ return 'Value of x is ' . $x;
Value of x is
return 'Unable to make DB connection in snippet1';
$modx->log(modX::LOG_LEVEL_ERROR, 'Unable to make db connection in snippet1';
$conexion = new PDO('mysql:host=tanukilibros.com;dbname=tanukili_tanuki;charset=utf8', 'username', 'password');
$conexion->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);$conexion = new PDO('mysql:host=tanukilibros.com;dbname=tanukili_tanuki;charset=utf8', 'username', 'password');
if (!$conexion) {
/* connection failed */
}
include($modx->getOption('core_path')."external/database.class.php");