Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Gr
Results 1 to 15 of 15

Thread: Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Gr

  1. #1
    Junior Member
    Join Date
    Apr 2006
    Posts
    9

    Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Gr

    I am getting the error :

    Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Group\Apache2\htdocs\firstdbprogram.php on line 4


    I have PHP 5 installed,apache and mysql.

    PHP is installed in c:\php

    IN the phph.ini I have done hte following:
    1) extension_dir = "c:\php"


    2) uncommented

    extension=php_mssql.dll
    extension=php_msql.dll
    extension=php_mysql.dll

    PHP is working fine for simple things.But it is not working when I am using MYSQL.

    THe code of fhte program is :
    <body>
    <?php

    $db=mysql_connect("abhijeet","root","desertgot123");

    mysql_select_db("mydb",$db);

    $result=mysql_query("select * from employees",$db);


    printf("first name:%s<br>\n",mysql_result($result,0,"first"));

    printf("Last Name: %s<br>\n", mysql_result($result,0,"last"));

    printf("Address: %s<br>\n", mysql_result($result,0,"address"));

    printf("Position: %s<br>\n", mysql_result($result,0,"position"));

    ?>



    </body>



    </html>


    my PATH is %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\MySQL\MySQL Server 5.0\bin;c:\jdk1.3\bin;C:\Program Files\Apache Group\Apache2bin;C:\PHP\ext;c:\windows\system32;c:\php;c:\windows

    in the c:\php the following dll are there

    libmsql.dll
    libmysqli.dll
    php_mysql.dll
    php5apache2.dll
    php5ts.dll


    also i have copied these dll's in c:\windows,c:\windows\system 32.


    Please help.
    Abhijeet

  2. #2
    Lost in Time (1970's) Houdini's Avatar
    Join Date
    Jul 2004
    Location
    Nashville TN USA
    Posts
    1,930
    Did you restart the server after the change? Apache nor PHP will see the change otherwise. Also did you edit the "acitve" php.ini if you edited the wrong copy it will not show up. do a phpinfo() to check, if after restart it doesn't show the changes in phpinfo you are not editing the "active" php.ini.

  3. #3
    Junior Member
    Join Date
    Apr 2006
    Posts
    9
    The php.ini file I am using is correctly stored in c:\windows and i am editing that only. I am restarting my server afer saving changes but hten also the error is coming.Still the error is there ,

  4. #4
    Lost in Time (1970's) Houdini's Avatar
    Join Date
    Jul 2004
    Location
    Nashville TN USA
    Posts
    1,930
    Are the changes showing when you run phpinfo()?

  5. #5
    Lost in Time (1970's) Houdini's Avatar
    Join Date
    Jul 2004
    Location
    Nashville TN USA
    Posts
    1,930
    It looks like you are using XAMPP (an older version) from the address of the error I am seeing in your post and the php.ini you need to edit is probably going to be found in the C:\Program Files\Apache Group\Apache2\bin\ folder unless you did something when going through the install besides accept the defaults. Do a hard disk search and see how many php.ini files you come up with (beside php.ini-dist and php.ini-recommended) and you will probably see that beside the one you stuck in the system or system32 folder that there is at least one other, and I am betting that that is the one you really need to edit and you problem will be solved.

  6. #6
    Junior Member
    Join Date
    Apr 2006
    Posts
    9

    still the problem persists

    hi,
    Unfortunately it seems there is only one php.ini file that is there in c:\windows only. I have copied it also in the c:\windows\system32 and also c:\windows\system directory.

    I am attaching hte log of phpifo and also my php.ini file below.See if it makes sense.

    Regards
    Abhijeet



    PHPINFO()

    Some info abt hte system that phpinfo is giving.
    you can see that its picking up php.ini file from c:\windows

    Server API CGI/FastCGI
    Virtual Directory Support enabled
    Configuration File (php.ini) Path C:\WINDOWS\php.ini
    PHP API 20041225
    PHP Extension 20050922
    Zend Extension 220051025
    Debug Build no
    Thread Safety enabled
    Zend Memory Manager enabled
    IPv6 Support enabled
    Registered PHP Streams php, file, http, ftp, compress.zlib
    Registered Stream Socket Transports tcp, udp
    Registered Stream Filters convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, zlib.*



    PHP.ini FILE

    ;
    ;;;;;;;;;;;;;;;;;;;;;;;;;
    ; Paths and Directories ;
    ;;;;;;;;;;;;;;;;;;;;;;;;;

    ; UNIX: "/path1:/path2"
    ;include_path = ".:/php/includes"
    ;
    ; Windows: "\path1;\path2"
    ;include_path = ".;c:\php\includes"

    ; The root of the PHP pages, used only if nonempty.
    ; if PHP was not compiled with FORCE_REDIRECT, you SHOULD set doc_root
    ; if you are running php as a CGI under any web server (other than IIS)
    ; see documentation for security issues. The alternate is to use the
    ; cgi.force_redirect configuration below
    doc_root =

    ; The directory under which PHP opens the script using /~username used only
    ; if nonempty.
    user_dir =

    ; Directory in which the loadable extensions (modules) reside.
    extension_dir = "c:\php\"

    ; Whether or not to enable the dl() function. The dl() function does NOT work
    ; properly in multithreaded servers, such as IIS or Zeus, and is automatically
    ; disabled on them.
    enable_dl = On

    ; cgi.force_redirect is necessary to provide security running PHP as a CGI under
    ; most web servers. Left undefined, PHP turns this on by default. You can
    ; turn it off here AT YOUR OWN RISK
    ; **You CAN safely turn this off for IIS, in fact, you MUST.**
    ; cgi.force_redirect = 1

    ; if cgi.nph is enabled it will force cgi to always sent Status: 200 with
    ; every request.
    ; cgi.nph = 1

    ; if cgi.force_redirect is turned on, and you are not running under Apache or Netscape
    ; (iPlanet) web servers, you MAY need to set an environment variable name that PHP
    ; will look for to know it is OK to continue execution. Setting this variable MAY
    ; cause security issues, KNOW WHAT YOU ARE DOING FIRST.
    ; cgi.redirect_status_env = ;

    ; FastCGI under IIS (on WINNT based OS) supports the ability to impersonate
    ; security tokens of the calling client. This allows IIS to define the
    ; security context that the request runs under. mod_fastcgi under Apache
    ; does not currently support this feature (03/17/2002)
    ; Set to 1 if running under IIS. Default is zero.
    ; fastcgi.impersonate = 1;

    ; Disable logging through FastCGI connection
    ; fastcgi.log = 0

    ; cgi.rfc2616_headers configuration option tells PHP what type of headers to
    ; use when sending HTTP response code. If it's set 0 PHP sends Status: header that
    ; is supported by Apache. When this option is set to 1 PHP will send
    ; RFC2616 compliant header.
    ; Default is zero.
    ;cgi.rfc2616_headers = 0


    ;;;;;;;;;;;;;;;;
    ; File Uploads ;
    ;;;;;;;;;;;;;;;;

    ; Whether to allow HTTP file uploads.
    file_uploads = On

    ; Temporary directory for HTTP uploaded files (will use system default if not
    ; specified).
    upload_tmp_dir = C:\PHP\uploadtemp ; temporary directory for HTTP uploaded files (will use system default if not specified)

    ; Maximum allowed size for uploaded files.
    upload_max_filesize = 2M


    ;;;;;;;;;;;;;;;;;;
    ; Fopen wrappers ;
    ;;;;;;;;;;;;;;;;;;

    ; Whether to allow the treatment of URLs (like http:// or ftp://) as files.
    allow_url_fopen = On

    ; Define the anonymous ftp password (your email address)
    ;from="john@doe.com"

    ; Define the User-Agent string
    ; user_agent="PHP"

    ; Default timeout for socket based streams (seconds)
    default_socket_timeout = 60

    ; If your scripts have to deal with files from Macintosh systems,
    ; or you are running on a Mac and need to deal with files from
    ; unix or win32 systems, setting this flag will cause PHP to
    ; automatically detect the EOL character in those files so that
    ; fgets() and file() will work regardless of the source of the file.
    ; auto_detect_line_endings = Off


    ;;;;;;;;;;;;;;;;;;;;;;
    ; Dynamic Extensions ;
    ;;;;;;;;;;;;;;;;;;;;;;
    ;
    ; If you wish to have an extension loaded automatically, use the following
    ; syntax:
    ;
    ; extension=modulename.extension
    ;
    ; For example, on Windows:
    ;
    ; extension=php_mysql.dll
    ;
    ; ... or under UNIX:
    ;
    ; extension=msql.so
    ;
    ; Note that it should be the name of the module only; no directory information
    ; needs to go here. Specify the location of the extension with the
    ; extension_dir directive above.


    ; Windows Extensions
    ; Note that ODBC support is built in, so no dll is needed for it.
    ; Note that many DLL files are located in the extensions/ (PHP 4) ext/ (PHP 5)
    ; extension folders as well as the separate PECL DLL download (PHP 5).
    ; Be sure to appropriately set the extension_dir directive.

    ;extension=php_mbstring.dll
    ;extension=php_bz2.dll
    ;extension=php_curl.dll
    ;extension=php_dba.dll
    ;extension=php_dbase.dll
    ;extension=php_exif.dll
    ;extension=php_fdf.dll
    ;extension=php_filepro.dll
    ;extension=php_gd2.dll
    ;extension=php_gettext.dll
    ;extension=php_ifx.dll
    ;extension=php_imap.dll
    ;extension=php_interbase.dll
    ;extension=php_ldap.dll
    ;extension=php_mcrypt.dll
    ;extension=php_mhash.dll
    ;extension=php_mime_magic.dll
    ;extension=php_ming.dll
    extension=php_mssql.dll
    extension=php_msql.dll
    extension=php_mysql.dll
    ;extension=php_oci8.dll
    ;extension=php_openssl.dll
    ;extension=php_oracle.dll
    ;extension=php_pgsql.dll
    ;extension=php_shmop.dll
    ;extension=php_snmp.dll
    ;extension=php_sockets.dll
    ;extension=php_sqlite.dll
    ;extension=php_sybase_ct.dll
    ;extension=php_tidy.dll
    ;extension=php_xmlrpc.dll
    ;extension=php_xsl.dll

  7. #7
    Lost in Time (1970's) Houdini's Avatar
    Join Date
    Jul 2004
    Location
    Nashville TN USA
    Posts
    1,930
    See this line
    ; Directory in which the loadable extensions (modules) reside.
    extension_dir = "c:\php\"
    Then if the ext directory is not in c:\php\ then the file can not be loaded. the files that should be in that location are
    extension=php_mssql.dll
    extension=php_msql.dll
    extension=php_mysql.dll

    if the ext file is anywhere else you will get the error. Are you using XAMPP? It usually puts everything where it belongs and unless you do something besides accept the default settings it should work after install.

  8. #8
    Junior Member
    Join Date
    Apr 2006
    Posts
    9
    I have uncommented only extension=php_mysql.dll

    and that file is in c:\php

    still things dont work
    Regards
    abhijeet

  9. #9
    Junior Member
    Join Date
    May 2006
    Posts
    2
    I have this problem too... undefined function mysql_connect...

  10. #10
    Pna lbh ernq guvf¿
    Join Date
    Jul 2004
    Location
    Kansas City area
    Posts
    19,429
    Are you positive the file isn't in c:\php\extensions\ ?

    If not, it might be that it's missing a libmysql.dll ? Do you have a c:\php\dlls\ folder?

    EDIT: Yes, PHP needs to talk to this client library. It is available with the Windows PHP download. If you don't have it, you'll need to download it. It needs to be placed in a directory within the Windows PATH environment variable. Not sure where that is? Open a DOS prompt (Start -> Run -> cmd) and type set and press enter. Look for 'Path=' followed by a list of directories (separated by a semicolon). A good bet is to place this in 'c:\windows\system32' though PHP.net doesn't recommend this for some reason (it's what I've always done in the past anyway, though). (Reference: MySQL - Installation on Windows Systems)

    EDIT2: Also, forgot to mention... since you're using PHP5, you also have the option fo switching to the new-and-improved MySQLi extension.
    Last edited by bradgrafelman; 05-05-2006 at 07:41 PM.

  11. #11
    Junior Member
    Join Date
    May 2006
    Posts
    2
    Yes libmysql.dll is missing also there no c:/php/dlls folder. How can ı find them?. I set the PATH variable to c:/php but nothing changed.

  12. #12
    Pna lbh ernq guvf¿
    Join Date
    Jul 2004
    Location
    Kansas City area
    Posts
    19,429
    libmysql.dll is included in the downloadable .zip from http://www.php.net/get/php-5.1.4-Win.../from/a/mirror . You'll find libmysql.dll in the main directory inside the .zip file, along with some other dlls necessary for various extensions.

    If you've correctly added c:\php to the Path environment variable as you've said, you can simply place these dlls in c:\php. Otherwise, you'll need to put them in a location such as c:\windows\system32.

  13. #13
    Junior Member
    Join Date
    Oct 2007
    Posts
    1
    des: ZEND: Fatal error: Call to undefined function mysql_connect()

    you are not allone , 100.. also need it:
    http://www.google.de/search?as_q=ZEN...s=&safe=images

    can anybody fix it ?

    ......



    hi all ,

    the window run as a web is ok , but in debug mysql dont work :-(

    ZEND: Fatal error: Call to undefined function mysql_connect()
    in C:\xampp\htdocs\var\www\users\a6000000\wc\inc\#mysq6000.inc
    on line 8

    what to do for ZEND 5.0 and for ZEND neon ?
    where to find a tutorial for zend debug with xampp mysql ?

    php
    C:\xampp\php\php.exe
    // or? C:\xampp\php\php-cgi.exe
    // ? C:\xampp\php\php-win.exe
    mysql:
    C:\xampp\mysql
    C:\xampp\mysql\bin\mysql.exe

    Currently used php.ini (guess) : C:\xampp\php\php.ini
    Loaded Configuration File : C:\xampp\apache\bin\php.ini
    PEAR IS OK:
    Current include path : .;C:\xampp\php\pear\
    Configured directory : C:\xampp\php\pear
    ZEND WORKSPACE
    C:\xampp\htdocs\zendworkspace

    ------
    help:: create a connection profile to your database
    To create a JDBC connection profile:

    Open the Database Development perspective by going to Window | Open Perspective | Other | Database Development.
    In the Data Source Explorer view, click the Create New SQL

    In the Data Source Explorer view, click the Create New SQL Connection icon
    .. its funny hide..
    -or- right-click SQL Databases and select New


    URL jdbc:mysql://localhost:3306/ // delete "database"
    usr: root
    pass: ******

    ping and connect is ok ,
    but debug dont work : ZEND: Fatal error: Call to undefined function mysql_connect()

    please , what todo ??

  14. #14
    Pna lbh ernq guvf¿
    Join Date
    Jul 2004
    Location
    Kansas City area
    Posts
    19,429
    Where is libmysql.dll ? Is that directory in your system's PATH environment variable?

  15. #15
    Junior Member
    Join Date
    Aug 2011
    Posts
    1

    Lightbulb I resolved mine with this

    Firstly, I edited the php.ini file and removed the colon prefix on the
    extension=php_mssql.dll line so as to enable it.

    Secondly, on php.ini file, I changed the value of the parameter below from Off to On. As shown: mssql.secure_connection = on
    This is because the SQL Server was configured to use Windows authentication.

    Thirdly, I restarted my apache web server.

    One you have followed the three steps above, the problem would be solved.

    Good luck and have fun.


    Kingisley (from Nigeria)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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