Kenneth Qvistgaard Dalbjerg, IT Konsulent i århus
Citrix Certified

mySQL kommandoer i PHP

August 25th, 2005 Posted in Programmering

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 and Enjoy:
  • Print
  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Twitter
  • Google Bookmarks
  • PDF
  • email
  • RSS
If you like this content, please support me and press the google adsense in the top of this post, thank you



Post a Comment