Advertisement
Guest User

web

a guest
Apr 26th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. <?php
  2.  
  3. echo '<pre>';
  4. echo $_SERVER["SERVER_NAME"];
  5. echo ' : ';
  6. echo $_SERVER["SERVER_ADDR"];
  7. echo ':';
  8. echo $_SERVER["SERVER_PORT"];
  9. echo '</pre><p>';
  10.  
  11. $username = "root";
  12. $password = "";
  13. $hostname = "127.0.0.1";
  14.  
  15. //connection to the database
  16. $dbhandle = mysql_connect($hostname, $username, $password)
  17. or die("Unable to connect to MySQL");
  18. echo "MySQL Ok<p>";
  19. echo "SELECT id, nom,annee FROM autos<p>";
  20.  
  21. //select a database to work with
  22. $selected = mysql_select_db("exemple",$dbhandle)
  23. or die("Could not select examples");
  24.  
  25. //execute the SQL query and return records
  26. $result = mysql_query("SELECT id, nom,annee FROM autos");
  27.  
  28. //fetch tha data from the database
  29. while ($row = mysql_fetch_array($result)) {
  30. echo "ID:".$row{'id'}." Nom:".$row{'nom'}."Annee: ". //display the results
  31. $row{'annee'}."<br>";
  32. }
  33. //close the connection
  34. mysql_close($dbhandle);
  35. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement