mySQL kommandoer i PHP

Lidt kommandoer til at arbejde med mySQl
Koble sig til en mySQL server
$mysql_server = “localhost”;
$mysql_bruger = “bruger”;
$mysql_password = “password”;
$mysql_database = “database”;
if (!mysql_connect(“$mysql_server”,”$mysql_bruger”,”$mysql_password”)) {
echo(“Kunne ikke oprette en forbindelse til MySQL.”);
exit;
}
if(!mysql_select_db(“$mysql_database”)) {
echo(“Kunne ikke vælge databasen: $database”);
exit;
}

Hente data ud fra en mySQL
$sql = mysql_query(“SELECT * FROM table”);
while ($rs = mysql_fetch_array($sql)) {
}

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *