PHP Ionic Angularjs Phonegap AJAX Javascript CSS MySQL jQuery Forum

PHP MySQL connecting script and function

25 September 2008 By


การติดต่อฐาน MySQL ด้วย PHP


  1. <?
  2. // hostname or ip of server
  3. $servername='localhost';

  4. // username and password to log onto db server
  5. $dbusername='';
  6. $dbpassword='';

  7. // name of database
  8. $dbname='mydb_name';

  9. ////////////// Do not edit below/////////

  10. connecttodb($servername,$dbname,$dbusername,$dbpassword);
  11. function connecttodb($servername,$dbname,$dbuser,$dbpassword)
  12. {
  13. global $link;
  14. $link=mysql_connect ("$servername","$dbuser","$dbpassword");
  15. if(!$link){die("Could not connect to MySQL");}
  16. mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error());
  17. }
  18. ?>



Tags:: mysql php





URL สำหรับอ้างอิง