SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Newbie to PHP and MySQL

    Hi everyone,

    I see that a lot of people have been having problems connecting MySQL with PHP - I am another! Have been through a lot of posts on the topic, but alas I am still having problems! Working with MySQL5.0 and PHP 5.1.2.

    Using Kevin Yank's book - problem arises with jokelist.php.

    Error message is "Fatal error: Call to undefined function mysql_connect() in c:\Inetpub\wwwroot\chapter4\jokelist.php on line 12"

    Have tried a load of things to try and resolve this, and have downloaded the .dlls from http://dev.mysql.com/downloads/connector/php/ which have been mentioned previously on the posts.

    Would really appreciate help on resolving this problem!

  2. #2
    Sell crazy someplace else markl999's Avatar
    Join Date
    Aug 2003
    Location
    Manchester, UK
    Posts
    4,007
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Edit your php.ini file and add/uncomment the line:
    extension=php_mysql.dll

    Then restart your web server.

  3. #3
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your reply Mark - have tried that, still no luck!
    fyi i am using:
    $dbcnx = mysql_connect('localhost', 'root', 'mypassword);
    if (!$dbcnx) {
    exit('<p>Unable to connect to the ' .
    'database server at this time.</p>');
    }

  4. #4
    Sell crazy someplace else markl999's Avatar
    Join Date
    Aug 2003
    Location
    Manchester, UK
    Posts
    4,007
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    "Call to undefined function mysql_connect()" means you have no MySQL support in your PHP installation. On Windows, in 99.9% of cases you just need to uncomment the line I mentioned above in your php.ini file.
    Create a page with just the following in it:
    <?php phpinfo() ?>

    It will tell you which php.ini file you should be editing. When you have MySQL support enabled you'll also see a MySQL section on that page too with various MySQL info.

  5. #5
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Mark again for your comments; I have created the php information page - the path of my php.ini file is c:\windows.

    Have uncommented
    extension=php_mysql.dll, and have also previously added (and uncommented)
    extension=php_mysqli.dll (this was done since I was directed to http://dev.mysql.com/downloads/connector/php/....

    Many thanks for your help.

  6. #6
    Sell crazy someplace else markl999's Avatar
    Join Date
    Aug 2003
    Location
    Manchester, UK
    Posts
    4,007
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The dll definetly isn't loading correctly.
    I've never had any issues with the dll provided by the PHP download so I'm not sure if the problem lies with the version you have from mysql.com
    Have you also copied libmysql.dll to the correct place? If you're using apache I'd expect there to be some sort of error when you start it, something like "The specified module could not be found.." But until the module is loaded ok and you see the MySQL section in your phpinfo() page you won't have access to the mysql_* functions.

  7. #7
    SitePoint Wizard cmuench's Avatar
    Join Date
    Jul 2005
    Location
    At my computer
    Posts
    2,251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Xampp by apachefriends.org

  8. #8
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Mark,
    thanks for your reply - I have libmysql.dll at the following locations:

    c:\php\php-5.1.2-Win32
    c:\windows\system32
    c:\program files\mysql\mysql\mysql server 5.0\bin

    Also, I dont know if this will help, but have php_mysql.dll at:
    c:\php\ext

    And php_mysqli.dll at:
    c:\php\ext

    Copied php5ts.dll to c:\windows\system32

    Also, in terms of viewing the correct information for MySQL in phpinfo, what should I be looking for?

    Many thanks

  9. #9
    SitePoint Enthusiast vehicau's Avatar
    Join Date
    Apr 2006
    Location
    Australia
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Hello

    Quote Originally Posted by daisydoo
    Hi everyone,

    I see that a lot of people have been having problems connecting MySQL with PHP - I am another! Have been through a lot of posts on the topic, but alas I am still having problems! Working with MySQL5.0 and PHP 5.1.2.

    Using Kevin Yank's book - problem arises with jokelist.php.

    Error message is "Fatal error: Call to undefined function mysql_connect() in c:\Inetpub\wwwroot\chapter4\jokelist.php on line 12"

    Have tried a load of things to try and resolve this, and have downloaded the .dlls from http://dev.mysql.com/downloads/connector/php/ which have been mentioned previously on the posts.

    Would really appreciate help on resolving this problem!

    A few comments,

    1. Maybe you are using a folder path to jokelist.php. You must use a url like http://Your Computers Name/chapter4/jokelist.php . PHP must be processed by a server before viewing in a browser to work. Using a folder path means the file is opened without the server processing the file.

    2. ('localhost', 'root', 'mypassword); a quote is missing and replace mypassword with a real password if you are not doing this already.

    3. Try re-reading and re-doing the previous chapters in the book.

    Q. Can you open other php files from other chapters and view correctly?

    Q. Do the 3 comments help or seem to be pointing in the right direction?

  10. #10
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Mark and Vehicau,
    I have solved the problem! (at last!).
    I had downloaded the php files to c:\php\php-5.1.2-win32 which Kevin Yank told me was incorrect - so I downloaded them just to c:\php.
    Made sure the "php.ini" file was named correctly, and hey presto I'm connected!
    Thanks for all your help - much appreciated.


Bookmarks

Posting Permissions

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