connect to mysql

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Evan Jou

    #1

    connect to mysql

    Hi there,

    I have a simple question for you experts here that I've installed
    Apache, PHP and MySQL on my Windows machine and set up a test
    script(test.php ) like what is listed in a book. It's like

    <?php
    @mysql_connect( "localhost","ro ot","password ")
    or die("Could not connect to MySQL server!);
    @mysql_select_d b("mysql")
    or die("Could not select database!);
    echo "You're connected to a MySQL database!";
    mysql_close();
    ?>

    After I opened the browser and selected the test.php, nothing happened.
    I look in the php.ini file and uncomment the line

    extension=php_m ysql.dll

    and change extension_dir = ".\" to extension_dir = "c:\php\ext \"

    I also make sure libmysql.dll resides on the Windows system path as
    told in the book. Then I restart the computer and open the browser again and
    select test.php. Still nothing happens. What did I miss? :(

    Thank you in advance for your help.

    Evan Jou



  • Rik Wasmus

    #2
    Re: connect to mysql

    On Sat, 13 Oct 2007 23:00:42 +0200, Evan Jou <l.jou@att.netw rote:
    Hi there,
    >
    I have a simple question for you experts here that I've installed
    Apache, PHP and MySQL on my Windows machine and set up a test
    script(test.php ) like what is listed in a book. It's like
    >
    <?php
    @mysql_connect( "localhost","ro ot","password ")
    or die("Could not connect to MySQL server!);
    @mysql_select_d b("mysql")
    or die("Could not select database!);
    echo "You're connected to a MySQL database!";
    mysql_close();
    ?>
    >
    After I opened the browser and selected the test.php, nothing
    happened.
    I look in the php.ini file and uncomment the line
    >
    extension=php_m ysql.dll
    >
    and change extension_dir = ".\" to extension_dir = "c:\php\ext \"
    >
    I also make sure libmysql.dll resides on the Windows system path as
    told in the book. Then I restart the computer and open the browser again
    and
    select test.php. Still nothing happens. What did I miss? :(
    >
    Thank you in advance for your help.
    First rule of debugging: show, don't supress errors. So remove the @ and
    tell us what it sais.

    Also: what does phpinfo(); tell you? Is the mysql extention loaded? Have
    you edited the php.ini it uses or perhaps another one?
    --
    Rik Wasmus

    Comment

    • Evan Jou

      #3
      Re: connect to mysql


      "Rik Wasmus" <luiheidsgoeroe @hotmail.comwro te in message
      news:op.tz5l78h m5bnjuv@metalli um.lan...
      >First rule of debugging: show, don't supress errors. So remove the @ and
      >tell us what it sais.
      >
      >Also: what does phpinfo(); tell you? Is the mysql extention loaded? Have
      >you edited the php.ini it uses or perhaps another one?
      >--
      >Rik Wasmus
      remove the @ didn't change it, still nothing shown in the browser.

      Oh! phpinfo() show that mysql.default_h ost, mysql.default_p assword,
      mysql.default_p ort, mysql.default_s ocket, mysql.default_u ser all "no value",
      is that the reason for what happened? My php.ini file is located in c:\php\,
      it should be the one in use. So what should I do next? Thank you!

      Evan Jou




      Comment

      • Rik Wasmus

        #4
        Re: connect to mysql

        On Sun, 14 Oct 2007 00:21:52 +0200, Evan Jou <l.jou@att.netw rote:
        >
        "Rik Wasmus" <luiheidsgoeroe @hotmail.comwro te in message
        news:op.tz5l78h m5bnjuv@metalli um.lan...
        >
        >First rule of debugging: show, don't supress errors. So remove the @ and
        >tell us what it sais.
        >>
        >Also: what does phpinfo(); tell you? Is the mysql extention loaded? Have
        >you edited the php.ini it uses or perhaps another one?
        >--
        >Rik Wasmus
        >
        remove the @ didn't change it, still nothing shown in the browser.
        >
        Oh! phpinfo() show that mysql.default_h ost, mysql.default_p assword,
        mysql.default_p ort, mysql.default_s ocket, mysql.default_u ser all "no
        value",
        is that the reason for what happened? My php.ini file is located in
        c:\php\,
        it should be the one in use. So what should I do next? Thank you!
        Hmmmz, enable error_reporting & display_errors in php.ini for your
        development server. Most likely it will report a parse error. Use an
        editor with syntax highlighting: much easier to spot the missing closing
        quotes on line 3:
        or die("Could not connect to MySQL server!);
        --
        Rik Wasmus

        Comment

        • Evan Jou

          #5
          Re: connect to mysql


          "Rik Wasmus" <luiheidsgoeroe @hotmail.comwro te in message
          news:op.tz5p7ed u5bnjuv@metalli um.lan...
          On Sun, 14 Oct 2007 00:21:52 +0200, Evan Jou <l.jou@att.netw rote:
          >
          >>
          >"Rik Wasmus" <luiheidsgoeroe @hotmail.comwro te in message
          >news:op.tz5l78 hm5bnjuv@metall ium.lan...
          >>
          >>First rule of debugging: show, don't supress errors. So remove the @ and
          >>tell us what it sais.
          >>>
          >>Also: what does phpinfo(); tell you? Is the mysql extention loaded? Have
          >>you edited the php.ini it uses or perhaps another one?
          >>--
          >>Rik Wasmus
          >>
          > remove the @ didn't change it, still nothing shown in the browser.
          >>
          > Oh! phpinfo() show that mysql.default_h ost, mysql.default_p assword,
          >mysql.default_ port, mysql.default_s ocket, mysql.default_u ser all "no
          >value",
          >is that the reason for what happened? My php.ini file is located in
          >c:\php\,
          >it should be the one in use. So what should I do next? Thank you!
          >
          Hmmmz, enable error_reporting & display_errors in php.ini for your
          development server. Most likely it will report a parse error. Use an
          editor with syntax highlighting: much easier to spot the missing closing
          quotes on line 3:
          or die("Could not connect to MySQL server!);
          --
          Rik Wasmus
          Oh! Thank you! It is a parse error. Now I get the right result. Thank you!

          Evan Jou


          Comment

          • Henri

            #6
            Re: connect to mysql

            On Sat, 13 Oct 2007 21:00:42 +0000, Evan Jou wrote:
            Hi there,
            >
            I have a simple question for you experts here that I've installed
            Apache, PHP and MySQL on my Windows machine and set up a test
            script(test.php ) like what is listed in a book. It's like
            >
            <?php
            @mysql_connect( "localhost","ro ot","password ")
            or die("Could not connect to MySQL server!);
            @mysql_select_d b("mysql")
            or die("Could not select database!);
            echo "You're connected to a MySQL database!"; mysql_close();
            ?>
            >
            After I opened the browser and selected the test.php, nothing
            happened.
            I look in the php.ini file and uncomment the line
            >
            extension=php_m ysql.dll
            >
            and change extension_dir = ".\" to extension_dir = "c:\php\ext \"
            >
            I also make sure libmysql.dll resides on the Windows system path as
            told in the book. Then I restart the computer and open the browser again
            and select test.php. Still nothing happens. What did I miss? :(
            >
            Thank you in advance for your help.
            >
            Evan Jou
            your die messages lack the closing quotes.

            Comment

            Working...