The following articles mainly introduce the actual application code of connecting MySQL to the database. We all know that the application rate of connecting MySQL to the database has become more and more extensive, therefore, the knowledge about MySQL database connection is becoming more and more popular. The following describes the specific content of the article.
- <?
- $lnk = mysql_connect('localhost', 'root', '') or die ('Not connected : ' . mysql_error());
- mysql_select_db('phpbb205', $lnk) or die ('Can\'t use foo : ' . mysql_error());
- $query = "SELECT * FROM phpbb_forums";
- $result = mysql_query($query);
- //$row = mysql_num_rows($result) ;
- while($result_row = mysql_fetch_row($result))
- {
- echo $result_row[2].$result_row[3];
- }
- ?>
The above content is an introduction to the Code for connecting MySQL to the database. I hope you will gain some benefits.