SitePoint Sponsor

User Tag List

Results 1 to 12 of 12

Threaded View

  1. #1
    SitePoint Member
    Join Date
    Dec 2010
    0 Post(s)
    0 Thread(s)

    Need help connecting to MySql from PHP

    Hello all,

    Please be patient with me as I try to explain my problem, I'm a total newb to all of this. I could really use some assistance on this as I have searched for days trying to find the answer and have failed to find the answer.

    The setup you need to know:

    1) Apache Server is installed and up and running fine
    2) MySql service is running
    3) I can use mysql through command console to see my DB and tables
    4) I'm running on Windows XP Media Edition

    What's happenning:

    As I work my way through the tutorials in the SitePoint Book titled "Build your own Database Driven Web Site, Using PHP and MySQL" everything worked fine; installation of Apache, installation of MySQL, and even the chapters on adding tables..etc. The problem occurs when I get to the part where I have to connect to MySql through PHP.

    When I type http://localhost:8080/test/chapter4/connect and hit enter in the browser I get nothing...ziltch...nada...If I view source it's empty. I've tried variations of connections and still I'm getting nothing. HALP! what am I doing wrong? For those of you familiar with the book I'm stuck on page 121.

    I suspect the problem is something related to the root of mySql but I haven't been able to figure out what. Is there something I have to do with mySql to tell it the root?

    Two files (located at htdocs/test/chapter4/connect)

    the scripts:


    PHP Code:
    if (!
    $output 'Unable to connect to the database server.';

    if (!
    $output 'Unable to set database connection encoding.';

    if (!
    $output 'Unable to locate the joke database.';

    $output 'Database connection established.';


    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    <html xmlns="" xml:lang="en" lang="en">
            <title>PHP Output</title>
            <meta http-equiv="content-type"
                    content="text/html; charset=utf-8"/>
                <?php echo $output?>
    Last edited by SpacePhoenix; Dec 11, 2010 at 17:19. Reason: put php tags round php code to improve readability


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts