Skip to content

Instantly share code, notes, and snippets.

@manviny
Created April 30, 2015 10:35
Show Gist options
  • Save manviny/1b0a0e348bbf3e022f83 to your computer and use it in GitHub Desktop.
Save manviny/1b0a0e348bbf3e022f83 to your computer and use it in GitHub Desktop.
conexion BD desde PHP con mysql
<?php
// // 1.- mysql -u root -p
$enlace = mysql_connect('localhost', 'bn_processwire', 'd1ac70ac0d' );
if (!$enlace) {
die('No pudo conectarse: ' . mysql_error());
}
echo 'Conectado satisfactoriamente';
// 2.- use mydatabase
mysql_select_db('bitnami_processwire') or die("No se pudo conectar a esa BD");
// 3.- SELECT * FROM templates
$query = 'SELECT * FROM templates';
$result = mysql_query($query) or die ("Consulta fallida");
while($line=mysql_fetch_array($result)){
echo '<br>'.$line['name'];
}
// exit
mysql_close($enlace);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment