como puedo hacer para que si la pagina no existe me muestre un mensaje y si no hay conexion con la base de datos me muestre otro mensaje.
si le agrego el archivo funciones.php aparece el mensaje de que el servidor me reedirigio muchas veces
error.php
Código HTML:
Ver original<?php
require 'funciones.php';
$id = isset($_GET['id']) ? (int)$_GET['id'] : false;
?>
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<link href="https://fonts.googleapis.com/css?family=Slabo+27px" rel="stylesheet"> <link rel="stylesheet" href="css/estilos.css">
<?php if(!$id): ?>
<div style="font-size: 80px; text-align: center;
position: relative;
top: 35%;">
<p>Error 404 - Not found
</p></font></center> <div style="font-size: 23px; text-align: center;
position: relative;
top: 36%;">
<p>La página solicitada no existe
</p> <?php endif ?>
<?php if(!$conexion): ?>
<div style="font-size: 80px; text-align: center;
position: relative;
top:35%;">
<p>Error 500
<img src="images/error.png" width="10px" height="10px"></p> <div style="font-size: 23px; text-align: center;
position: relative;
top:36%;">
<p>Hay un problema con el servidor, por favor intente mas tarde
</p> <?php endif ?>
funciones.php
Código PHP:
Ver original<?php
function conexion($db, $usuario, $pass){
try {
$conexion = new PDO("mysql:host=localhost;dbname=$db", $usuario, $pass);
return $conexion;
} catch (PDOException $e) {
return false;
}
}
$conexion = conexion('galeria', 'root', '');
if (!$conexion) {
}
?>