I have a database on my site with the users and their passwords to be able to enter the page. The database is fine, the same with the login page, they worked fine without any problem. Until a few days ago, for no apparent reason, it stopped working. This is the code I used to connect:
<?php
class conexion {
public static function conectar ()
{
try {
$cn = new PDO("mysql:host=localhost:3306;dbname=misitio_bdatos","miusuario","qaz123");
return $cn;
} catch (PDOException $ex) {
die($ex->getMessage() );
}
}
} //sin etiqueta de cierre por ser parte de un require
So I decided to check if these data were really correct, with the following code that I found on the internet and named as check.php
<?php
function Conectarse()
{
$host='localhost:3306';
$usuariodb='miusuario';
$passwdb='qaz123';
$nombredb='misitio_bdatos';
if (!($link=mysql_connect($host,$usuariodb,$passwdb)))
{
echo "Error conectando a la base de datos.";
exit();
}
if (!mysql_select_db($nombredb,$link))
{
echo "Error seleccionando la base de datos, verifique que el nombre de usuario utilizado este asociado a la base de datos.";
exit();
}
return $link;
}
$link=Conectarse();
echo "Conexión con la base de datos conseguida.
";
mysql_close($link); //cierra la conexion
?>
But when I go to that file in mysite.com/check.php it shows me the message
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
How can I verify that this connection is actually being made correctly?
I am working with PDO to validate logins.
Thank you very much :)
If you are working with PDO you can try this connection