1.4 PHP/MySQL
Aller à la navigation
Aller à la recherche
Se connecter et requêter une base:
$db_server = "localhost"; $db_user = "USER"; $db_pw = "PASSWORD"; $db_database = "DATABASE_NAME";
$db=mysql_connect($db_server, $db_user, $db_pw) or die("Impossible de se connecter à la base de données: $db_server ! " . mysql_error());
mysql_select_db($db_database, $db) or die ("Impossible de selectionner la base: $db_database !" . mysql_error());
$result = mysql_query($query2) or die("Impossible d'executer la requete! " . mysql_error());
while ($row=mysql_fetch_row($result)) { printf("row0 $row[0], row1 $row[1], row2 $row[2]"); }
mysql_close($db);