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)) {
}

Share this:
Share this page via Email Share this page via Stumble Upon Share this page via Digg this Share this page via Facebook Share this page via Twitter

You may also like...

Leave a Reply

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