php database connection example

php connect to mysql database, oracle database


  1. <?php 
  2. @$dbcnnct = mysql_connect("localhost", "username", "password");
  3. if(!$dbcnnct)
  4. {
  5. echo "could not connect";
  6. }
  7. @$db=mysql_select_db("project");
  8. if(!$db)
  9. {
  10. echo "could not select";
  11. }

  12. $sql = mysql_query("SELECT * FROM country ");
  13. if(!$sql)
  14. echo "error==".mysql_error($sql);
  15.         while($row = mysql_fetch_array($sql))
  16.         {
  17.             
  18. echo ("$row[table column name]");
  19.         }

  20. @$dbcls = mysql_close($dbcnnct);
  21. ?>


Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation