44 lines
1.3 KiB
PHP
44 lines
1.3 KiB
PHP
<?php
|
|
function Conectarse(){
|
|
//if(!($link = mysqli_connect('132.248.80.194', 'usr_desayuno', 'jenera-zionX'))) {
|
|
if(!($link = mysqli_connect('132.248.80.194', 'des_gabriel', 'dsa08kurk*11'))) {
|
|
imprimeError();
|
|
exit();
|
|
}else{
|
|
mysql_set_charset('utf8');
|
|
}
|
|
//if(!mysqli_select_db($link,"kalinga_desayuno")){
|
|
if(!mysqli_select_db($link,"P_orion_desayuno")){
|
|
echo "Error con la BD.";
|
|
exit();
|
|
}
|
|
return $link;
|
|
}
|
|
|
|
|
|
|
|
|
|
function conexion_pdo() {
|
|
//$db = new PDO("mysql:host=132.248.80.194;dbname=kalinga_desayuno", "usr_desayuno", "jenera-zionX");
|
|
$db = new PDO("mysql:host=132.248.80.194;dbname=P_orion_desayuno", "des_gabriel", "dsa08kurk*11");
|
|
return $db;
|
|
}
|
|
|
|
|
|
|
|
//Función en mysqli que devuelve una cadena que describe el último error
|
|
function imprimeError(){
|
|
//$link = mysqli_connect('132.248.80.194', 'usr_desayuno', 'jenera-zionX');
|
|
$link = mysqli_connect('132.248.80.194', 'des_gabriel', 'dsa08kurk*11');
|
|
/* Comprueba la conexión */
|
|
if (mysqli_connect_errno()) {
|
|
printf("Connect failed: %s\n", mysqli_connect_error());
|
|
exit();
|
|
}
|
|
if (!mysqli_query($link, "SET a=1")) {
|
|
printf("Errormessage: %s\n", mysqli_error($link));
|
|
}
|
|
/* Cierra la conexión */
|
|
mysqli_close($link);
|
|
}
|