Home » Categories » Multiple Categories

How do I query MySQL Database in PHP ?

Please follow the following guidelines:

<html>
     <head>
             <title>MySQL Test Code</title>
     </head>
     <body>
             <h1>MySQL Test Code Results</h1>
             <p>
                     <table border="1">
                               <tr>
                                          <td>pkID</td>
                                          <td>username</td>
                                          <td>password</td>
                               </tr>
             <?php

             /*
             * 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);
 
             }

             ?>
            </table>
      </p>

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




Attachments Attachments
There are no attachments for this article.
Related Articles RSS Feed
I cannot see my website. What should I do?
Viewed 2210 times since Thu, May 3, 2012
Do you allow custom COM components?
Viewed 1596 times since Tue, May 1, 2012
My website session times out earlier than expected. Why?
Viewed 2788 times since Tue, May 1, 2012
How to Solve an Error Message "Validation of viewstate MAC failed"
Viewed 6421 times since Tue, Apr 2, 2013
Domain Name Server (DNS) Amplification Attack
Viewed 1856 times since Wed, Oct 15, 2014
Can i login to my MySQL database via my own mySQL tool?
Viewed 1736 times since Mon, May 7, 2012
Do you support MySQL WebAdmin Access?
Viewed 1869 times since Tue, May 1, 2012