Home >Backend Development >PHP Tutorial >Example of PHP accessing MySQL database

Example of PHP accessing MySQL database

WBOY
WBOYOriginal
2016-08-08 09:34:021032browse

PHP存取MySQL数据库的示例:


php+MySQL 例子


请在文本区域输入数据并且确定






  

  $connect_id=mysql_connect("localhost","username","passWord");
  if(isset($txt)) {
     $dbtime=date("Y-m-d H:i:s");
     mysql_db_query("usernamedb","insert into test values (0,'$dbtime','$txt')");
  }
?>







  $result=mysql_db_query("usernamedb","select * from test");
  while($userdb=mysql_fetch_row($result))
  {
     echo "<".$userdb[0].">:      ".$userdb[1]."     ".$userdb[2]."
n";
  }
   mysql_close($connect_id);
?>



  


以上就介绍了PHP存取MySQL数据库的示例,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn