User Tools

Site Tools


informatica:linux:php:mysql

Conectar a mysql desde php

<?php
$link =  mysql_connect('localhost', 'd6_guifitest', 'guifinet');
if (!$link) {
    die('No pudo conectarse: ' . mysql_error());
}
echo 'Conectado  satisfactoriamente';

if (!mysql_select_db('d6_guifitest')) {
    die('Could not select database: ' . mysql_error());
}

$query = "SELECT * FROM guifi_location where zone_id='11031'";

$result = mysql_query($query);
if (!$result) {
    die('Could not query:' . mysql_error());
}

while ($row = mysql_fetch_assoc($result)) {
    echo $row['nick'].$row['lat'].$row['lon']."<br>";
}

mysql_close($link);
?>

Copia de seguridad

Hacer un dump

mysqldump --routines --single-transaction --add-drop-database --databases furgolife  > furgolife_$(date +%d-%m-%y).sql -u root -p
informatica/linux/php/mysql.txt · Last modified: 2016/03/24 18:05 by jose