Home » Categories » Multiple Categories

How do I query MySQL Database in PHP ?

Please follow the following guidelines:

             <title>MySQL Test Code</title>
             <h1>MySQL Test Code Results</h1>
                     <table border="1">

             * Configuration Information and Definitions
             $mysql_host = mysql01.discountasp.net;
             $mysql_user = username;
             $mysql_pass = password;
             $mysql_db = database;
             $query = SELECT * from table1;

             mysql_connect($mysql_host, $mysql_user, $mysql_pass) or die("Connection to MySQL-server failed!");

             mysql_select_db($mysql_db) or die("Selection of database $mysql_db failed!");

             $result = mysql_query($query) or die("Invalid Query, " . mysql_error());

             while( list( $pkid, $user, $pass ) = mysql_fetch_row($result) )
                      printf("<tr><td>%d</td><td>%s</td><td>%s</td></tr>", $pkid, $user, $pass);


<h1>End MySQL Test Code Results</h1>

Attachments Attachments
There are no attachments for this article.
Related Articles RSS Feed
How to Solve an Error Message "Validation of viewstate MAC failed"
Viewed 8201 times since Tue, Apr 2, 2013
Do you allow custom COM components?
Viewed 2157 times since Tue, May 1, 2012
What is the connection string for my mariaDB database?
Viewed 762 times since Fri, Jun 26, 2020
My site is showing 500 Internal Server error message. What is wrong here?
Viewed 2734 times since Thu, May 3, 2012
About Azure Key Vault
Viewed 594 times since Mon, Nov 2, 2020
How can I enable ASP.NET 3.5 on your Control Panel?
Viewed 3150 times since Wed, May 2, 2012
Sample Code to Send email using ASP.NET1.1
Viewed 4448 times since Tue, May 1, 2012