Learning PHP and MySQL

Example 09-04 Including the connection values and calling mysql_connect

<?php include('db_login.php');
$connection mysql_connect($db_host$db_username$db_password);
if (!
$connection){
  
die ("Could not connect to the database: <br />"mysql_error());
}
?>

Posted by on 08/07 at 05:23 PM
  1. Hello!  I’ve enjoyed reading the book!  I’ve been attempting to learn any type of programmning that I can get my hands on, and recently have became interested in PHP.  Mainly due to my past work with good ol’ html.  I had some initial installation problems mainly due to using the newer versions of PHP and Apache but found the fixes on their associated websites.  When I came to Example 9-4, I ended up a little confused but eventually put together that I needed a db_login.php file and another file that included the db_login.php file in it.  The issue that I ran across is that when I ran the .php file with example 9-4’s code.  I didn’t see anything show in the browser.  However it didn’t show an error either.  I am wondering if this meant the connection was successful?  I didn’t include any query’s etc to the code.  I am using IE7 Beta 3.  I’ve been a bit frustrated and finally found this site!  grin

    Posted by Justin  on  08/17  at  05:36 PM
  2. Page 1 of 1 pages

Next entry: Example 09-05 Displaying the books and authors

Previous entry: Example 09-03 The SQL to recreate the test objects8

<< Back to main