mysql_connect error on local webserver

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Shawn Northrop
    New Member
    • Jan 2007
    • 67

    mysql_connect error on local webserver

    I have recently setup an apache server with php support. When i call the function mysql_connect i am getting an error saying undefined function. I am sure i either need to include a file or i did something wrong when setting up the php support. I am not sure where to look however. Any suggestions? thanks
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, Shawn.

    If the mysql_connect() function is undefined, that means that PHP was not compiled with MySQL support.

    To verify this, run the following PHP command:[code=php]<?php phpinfo(); ?>[/code]

    If MySQL support is installed, you'll see '--with-mysql=/usr/local/mysql' (or something similar) in the 'Configure Options' box, and there will be a section entitled 'MySQL'.

    To add MySQL support to PHP, you have to have MySQL installed. Then reconfigure PHP and add '--with-mysql=/path/to/mysql/base/directory' to the configure options.

    E.g.:
    Code:
    './configure' '--enable-shared' '--disable-static' '--with-apxs2=/usr/local/apache2/bin/apxs' '--with-libxml-dir=/usr/local' '--with-openssl=/usr/local/ssl' '--with-pcre-regex=/usr/local' '--with-zlib-dir=/usr/local' '--with-db4=/usr/local/BerkeleyDB.4.5' '--with-libxml-dir=/usr/local' '--with-jpeg-dir=/usr/local' '--with-png-dir=/usr/local' '--with-freetype-dir=/usr/local' '--with-gd' '--with-iconv=/usr/local' [b]'--with-mysql=/usr/local/mysql'[/b]

    Comment

    • Shawn Northrop
      New Member
      • Jan 2007
      • 67

      #3
      That would be the reason, i just installed mysql (after installing php) I dont remember compileing php, i simply downloaded the package and changed the httpd.conf settings for my server. To compile do i run php.exe or php-win.exe? Im sure thats a whole other topic to research in itself. Thanks.

      Comment

      • Shawn Northrop
        New Member
        • Jan 2007
        • 67

        #4
        So ive spent the entire day sitting infront of my computer to no avail. I am trying to connect to a mysql server on localhost through php and i get an error saying undefined function. I have gone into the php.ini and removed the ; infront of php_mysql.dll and added the location to the dll to my path. This was the instructions i found for installing mysql on windows. I am not sure if the dll is being loaded, however, if i rename the dll file i get no errors when restarting apache. I am at a loss. Anyone have any experience resolving this issue? I have read numerous posts about this problem but no one seems to have clarified anything. Also, is there a way to determine if the dll has been loaded?

        Comment

        • pbmods
          Recognized Expert Expert
          • Apr 2007
          • 5821

          #5
          Heya, Shawn.

          Are you installing PHP on a Windows server?

          In the PHP installer .msi program, there should be an 'additional options' (or something like that) button. Click on it and make sure the 'MySQL' checkbox is checked before continuing.

          Comment

          Working...