Running PHP and MySQL

  1. To run an application involving a database, create the database in command-line mode using MySQL. Click on Start > Run. Make sure the word command is in the box. Enter cd.. twice and then cd mysql, followed by cd bin. This will take you to the mysql\bin folder. Enter mysql. This starts MySQL. Assuming quiz is the name you want for your database, type:

        create database quiz;     quit;
  2. Close the command prompt window. Click End Now.

  3. In Notepad, write the following and save it as opendbq.php.

        <?php     global $DBname, $link;     $host="localhost";     $user="root";     $password="12345";     $DBname="quiz";     $link=mysql_connect($host,$user,$password);     mysql_select_db($DBname,$link);     ?>
  4. Use include or require as appropriate to include opendbq.php in all your files requiring access to this database.

  5. Note: files can be in any descendant folder of wwwroot. For example, you can create a subfolder of phpstuff called quizphp and place all the quiz scripts in it. You would start the game by entering:


Creating Database Web Applications with PHP and ASP
Creating Database Web Applications with PHP and ASP (Charles River Media Internet & Web Design)
ISBN: 1584502649
EAN: 2147483647
Year: 2005
Pages: 125
Authors: Jeanine Meyer

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: