Easy (?) PHP/MySQL question

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

    Easy (?) PHP/MySQL question

    I have installed PHP and MySQL using WAMP5 as my server on a Vista
    machine.

    I can run PHP scripts no problem.

    I can create and populate MySQL tables no problem.

    I cannot seem to get my PHP script to recognize any MySQL commands.

    The following code fails silently, i.e. even the "die" text won't
    display.
    //Database Connection
    $msdb = mysql_connect(" 127.0.0.1", "", "") or die('Could not connect
    to MySQL: ' . mysql_error());
    mysql_select_db ("test", $msdb) or die('Could not select the database:
    ' . mysql_error());

    What piece of info am I missing here? Is there some perl-style
    include that I'm missing? Or is it some configuration parameter? Any
    help appreciated.
  • Jerry Stuckle

    #2
    Re: Easy (?) PHP/MySQL question

    Stevebo wrote:
    I have installed PHP and MySQL using WAMP5 as my server on a Vista
    machine.
    >
    I can run PHP scripts no problem.
    >
    I can create and populate MySQL tables no problem.
    >
    I cannot seem to get my PHP script to recognize any MySQL commands.
    >
    The following code fails silently, i.e. even the "die" text won't
    display.
    //Database Connection
    $msdb = mysql_connect(" 127.0.0.1", "", "") or die('Could not connect
    to MySQL: ' . mysql_error());
    mysql_select_db ("test", $msdb) or die('Could not select the database:
    ' . mysql_error());
    >
    What piece of info am I missing here? Is there some perl-style
    include that I'm missing? Or is it some configuration parameter? Any
    help appreciated.
    >
    Enable all error reporting and display the errors. In your php.ini
    file, ensure you have:

    display_errors= on
    error_reporting =E_ALL

    I suspect your mysql extension isn't getting loaded.

    --
    =============== ===
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    • Richard

      #3
      Re: Easy (?) PHP/MySQL question


      "Stevebo" <fatpacking@gma il.comwrote in message
      news:b2d7f4a9-ec14-4013-b41e-6426fd0ea736@79 g2000hsk.google groups.com...
      >I have installed PHP and MySQL using WAMP5 as my server on a Vista
      machine.
      >
      I can run PHP scripts no problem.
      >
      I can create and populate MySQL tables no problem.
      >
      I cannot seem to get my PHP script to recognize any MySQL commands.
      >
      The following code fails silently, i.e. even the "die" text won't
      display.
      //Database Connection
      $msdb = mysql_connect(" 127.0.0.1", "", "") or die('Could not connect
      to MySQL: ' . mysql_error());
      mysql_select_db ("test", $msdb) or die('Could not select the
      database:
      ' . mysql_error());
      >
      What piece of info am I missing here? Is there some perl-style
      include that I'm missing? Or is it some configuration parameter?
      Any
      help appreciated.
      Can you connect to mySQL using another client?
      MySQL query browser.. mySQL admin?

      Turning on the error reporting (as Jerry suggested) is of course good.
      You can do that from the tray icon.
      While you are there, check to see if the extension for mySQL is
      loaded.
      Can you connect to the DB if you select "phpMyAdmin " from the tray
      menu?

      Richard.


      Comment

      • Stevebo

        #4
        Re: Easy (?) PHP/MySQL question

        On Sep 19, 2:20 pm, "Richard" <root@localhost wrote:
        Can you connect to mySQL using another client?
        MySQL query browser.. mySQL admin?
        Yes. i can do so with MySQL query browser
        Turning on the error reporting (as Jerry suggested) is of course good.
        I did this using the WAMP Tray Icon =Config Files, but nothing
        changed
        While you are there, check to see if the extension for mySQL is
        loaded.
        The extension = php_mysql.dll in php.ini is uncommented, but it isn't
        loaded either, nor does it show up in phpinfo()
        Can you connect to the DB if you select "phpMyAdmin " from the tray
        menu?
        No, because it's trying to use http://localhost/, which for some
        reason maps to http://www.localhost.com/ and gives an error that the
        connection was reset (essentially a 404). If I substitute http://127.0.0.1/,
        my page gets served but no database response. When I go to
        http://127.0.0.1/phpMyAdmin, I receive

        "Cannot load mysql extension. Please check your PHP configuration. -
        Documentation"

        The hosts file has hundreds of entries for localhost, most of them put
        in by Spybot. I tried to edit the hosts file, but it's read-only.
        when I remove that, and forcibly try to overwrite it, I still can't.

        Any ideas?

        Comment

        • Stevebo

          #5
          Re: Easy (?) PHP/MySQL question

          Testing. My last post disappeared.

          Comment

          • Jerry Stuckle

            #6
            Re: Easy (?) PHP/MySQL question

            Stevebo wrote:
            On Sep 19, 2:20 pm, "Richard" <root@localhost wrote:
            >Can you connect to mySQL using another client?
            >MySQL query browser.. mySQL admin?
            >
            Yes. i can do so with MySQL query browser
            >
            >Turning on the error reporting (as Jerry suggested) is of course good.
            >
            I did this using the WAMP Tray Icon =Config Files, but nothing
            changed
            >
            >While you are there, check to see if the extension for mySQL is
            >loaded.
            >
            The extension = php_mysql.dll in php.ini is uncommented, but it isn't
            loaded either, nor does it show up in phpinfo()
            >
            >Can you connect to the DB if you select "phpMyAdmin " from the tray
            >menu?
            >
            No, because it's trying to use http://localhost/, which for some
            reason maps to http://www.localhost.com/ and gives an error that the
            connection was reset (essentially a 404). If I substitute http://127.0.0.1/,
            my page gets served but no database response. When I go to
            http://127.0.0.1/phpMyAdmin, I receive
            >
            "Cannot load mysql extension. Please check your PHP configuration. -
            Documentation"
            >
            The hosts file has hundreds of entries for localhost, most of them put
            in by Spybot. I tried to edit the hosts file, but it's read-only.
            when I remove that, and forcibly try to overwrite it, I still can't.
            >
            Any ideas?
            >
            Did you stop and restart your Apache server after making changes to the
            php.ini? Are you changing the correct php.ini file (see phpinfo()).

            And are the MySQL client libraries in a place where php can access them,
            i.e. in a directory listed in your PATH environment variable?

            I've never used xampp (I do manual installs), so I don't know how it's
            set up. But once you have it set up, everything works well.

            --
            =============== ===
            Remove the "x" from my email address
            Jerry Stuckle
            JDS Computer Training Corp.
            jstucklex@attgl obal.net
            =============== ===

            Comment

            • r0g

              #7
              Re: Easy (?) PHP/MySQL question

              Stevebo wrote:
              On Sep 19, 2:20 pm, "Richard" <root@localhost wrote:
              >Can you connect to mySQL using another client?
              >MySQL query browser.. mySQL admin?
              <snip>
              The hosts file has hundreds of entries for localhost, most of them put
              in by Spybot. I tried to edit the hosts file, but it's read-only.
              when I remove that, and forcibly try to overwrite it, I still can't.
              >
              Any ideas?
              Oh that's not good. Windows can only handle a finite number of hosts
              file entries without throwing a hissy fit, plus you have no ide what is
              in there. I'd lose search and destroy, (right-click, security, advanced,
              owner) and reclaim ownership of the file and delete everything in it
              except "127.0.0.1 localhost"

              If XAMPP still isn't happy after that then try WAMP instead, I always
              found it was the better of the two :-)

              Of course, as Jerry suggests you could try the manual install. While it
              takes longer it _is_ educational :-)

              Roger.

              Comment

              • Stevebo

                #8
                Re: Easy (?) PHP/MySQL question

                On Sep 19, 5:41 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
                php.ini?  Are you changing the correct php.ini file (see phpinfo()).
                Yes Jerry, that was it! The wrong php.ini file. Strange, you would
                have thought WAMP would pick the correct path, but perhaps it got
                confused with an earlier installation of PHP.

                Also Roger, thanks for the advice regarding the hosts file, but no
                matter what I do to the file, I can't seem to unlock it, so the
                problem persists. Since Jerry's advice got me up and running for the
                moment, I'll re-visit the localhost thing when I get a chance. I'm
                mostly just trying to do local development, not necessarily run my own
                public web server.

                Thanks for all your patience with and advice about my questions.
                Steve

                Comment

                • Anonymous

                  #9
                  Re: Easy (?) PHP/MySQL question

                  Stevebo wrote:
                  The hosts file has hundreds of entries for localhost, most of them put
                  in by Spybot. I tried to edit the hosts file, but it's read-only.
                  when I remove that, and forcibly try to overwrite it, I still can't.
                  >
                  Any ideas?
                  That's a bad idea. The hosts file was never intended to do mass
                  redirections. The whole file gets parsed on every net access to see if
                  the domain should resolve to a specific address before a DNS lookup is
                  made. A long hosts file can *really* bog down your net connectivity.

                  If you can't change the hosts file you have most likely configured
                  Spybot to protect it from tampering. Switch the hosts file protection
                  off in Spybot, then you should be able to edit it just fine.

                  Bye!

                  Comment

                  Working...