Undefined function mysql_connect()

Discussion in 'PHP' started by ngontro86, May 27, 2007.

  1. #1
    Hey everybody,
    just stuck here! since the error received is: Fatal error: Call to undefined function Mysql_connect() in C:\Apache2\Apache2\htdocs\study.php on line 3... Any experts can enlighten this for me? any problems with installing?...
     
    ngontro86, May 27, 2007 IP
  2. manilodisan

    manilodisan Peon

    Messages:
    224
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Can you post the code that is trying to do the connect?
     
    manilodisan, May 27, 2007 IP
  3. coderbari

    coderbari Well-Known Member

    Messages:
    3,168
    Likes Received:
    193
    Best Answers:
    0
    Trophy Points:
    135
    #3
    yes.let us see your code.
     
    coderbari, May 27, 2007 IP
  4. ngontro86

    ngontro86 Peon

    Messages:
    28
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Sure, very simple one:
    ----------------
    <?php
    $link = mysql_connect("localhost","username","password");
    if(!$link)
    die('Could not open connect:'.mysql_error());
    else echo "Connected sucessfully!";
    ?>
    ----------------
    I want to mention that the function I used : mysql_connect() is undefined! So that is seemingly sure some problems with my soft, therefore problems with installation?....
    Thanks for your interest. Help me, plzz!
     
    ngontro86, May 28, 2007 IP
  5. daboss

    daboss Guest

    Messages:
    2,249
    Likes Received:
    151
    Best Answers:
    0
    Trophy Points:
    0
    #5
    are you running your own server? are the mysql functions enabled in your php setup?

    if you are, open up your php.ini file and perform a search for 'mysql'
     
    daboss, May 28, 2007 IP
  6. NoamBarz

    NoamBarz Active Member

    Messages:
    242
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    58
    #6
    what version of php are you running?
    mysql_connect is not set up by default on php 5 as it used to be on php 4.
    You need to access the php.ini file and enable this extension by uncommenting it.

    Hope this helps
     
    NoamBarz, May 28, 2007 IP
  7. ngontro86

    ngontro86 Peon

    Messages:
    28
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Oh yeah, I am using PHP 5! I will check your suggestions. Thanks for your all quick assistances.
     
    ngontro86, May 28, 2007 IP
  8. ngontro86

    ngontro86 Peon

    Messages:
    28
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    After all try, I am still stuck!can you tell me how to enable these functions (mysql_connect(), mysql_error()...) in the php.ini file?
     
    ngontro86, Jun 2, 2007 IP
  9. mattcch2007

    mattcch2007 Peon

    Messages:
    562
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #9
    as i know unix/linux is case senitive,

    can you try renname the function with Mysql_connect(),

    the letter with capitalized 'M'.,

    and try it to see wether it is ok
     
    mattcch2007, Jun 2, 2007 IP
  10. mrmonster

    mrmonster Active Member

    Messages:
    374
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    60
    #10
    Since you are running this on windows, chances are you didn't install MySQL/PHP correctly.

    Theres some specific MySQL.dll files you need to move to the right places for MySQL to load up with PHP when you start Apache.

    Check your Apache error logs, theres probably something about not being able to load MySQL module.
     
    mrmonster, Jun 2, 2007 IP
  11. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #11
    Did you install Apache, PHP etc. individually? I'd recommend installing with a package installer such as XAMPP so you don't need to worry about issues like this.

    Back to the issue, have you checked if MySQL is even installed (and configured properly)? You can check error logs as MrMonster said or use phpinfo() to find out.
     
    krt, Jun 2, 2007 IP
  12. ngontro86

    ngontro86 Peon

    Messages:
    28
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Thanks all and sorry for late respond!
    I did tried XAMPP, and one other soft similar like that(with a forum coming with) however, this is the traditional way, rite? should handle this first!
    All other normal-used functions are okey! Only can not connect to the database...:-(
    More abt this, I follow this link to configure Apache and Php: tanguay.info/wamp/installPhp5.php5?step=6
     
    ngontro86, Jun 3, 2007 IP
  13. ngontro86

    ngontro86 Peon

    Messages:
    28
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #13
    Finally, today (my off-day :p) I found the line which disables MySQL extensions in php.ini. Just want to share to other newbie(like me) to quickly resolve it.
    -------
    In Php.ini file, find the comment line: extension=php_mysql.dll and then remove the leading semicolon. That's all, u'r done! easy, rite?
    Thanks all, guys and gals!!
     
    ngontro86, Jun 4, 2007 IP