Results 1 to 22 of 22

Thread: Undefined Function Error MySQL_Connect

  1. #1

    Thread Starter
    Fanatic Member MikkyThomeon's Avatar
    Join Date
    Oct 2002
    Location
    At work...
    Posts
    648

    Undefined Function Error MySQL_Connect

    I have a problem when trying to use mysql_connect. Apache returns and undefined function 'MySQL' error. I have just loaded RH linux 8 and php is processing requests and the MySQL daemon is running and active - I am able to use the db fine.

    Any ideas on how to solve this would be appreciated.

    In terms of what version of apache I am using, I need to find out. I am wrking right now but will reply in 5 hours.

    Thanks in advance
    mike

  2. #2
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    also need the version of mysql and php

  3. #3
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    The exact error message would probably also help.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  4. #4

    Thread Starter
    Fanatic Member MikkyThomeon's Avatar
    Join Date
    Oct 2002
    Location
    At work...
    Posts
    648
    UNDEFINED function 'mysql_connect' error on line8. The version of the httpd server is version 2.0

    Sorry I did not respond earlier but i am having dns errors this side that mkes it impossible to view some web sites.

    Could there be a shared module that is missing? Until now I have been working with MS only but have been called on to develop a site using PHP. I learnt PHP in a week but learning about configuring apache and mysql looks like that could take a while longer. Thanks for your replies

  5. #5
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    for one you still didn't tell us the version of php.


    and I highly doubt it you learned php in a week, maybe the fundamentals but not the whole thing.

    if you are using php5.0 then mysql has been taken out of it. you have to install the module and get it working. also what version of mysql is installed? you did install mysql didn't you?

  6. #6
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    I learned PHP in a week, if it was even that long. Is that hard to believe?

    Coming from a Perl, C++, and JavaScript background, I picked it up right away.

    Granted, learning to work with MySQL and cookies probably took an 8th day, but that doesn't count.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  7. #7
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    Originally posted by phpman
    and I highly doubt it you learned php in a week, maybe the fundamentals but not the whole thing.
    So, much does one need to know to know a language?
    I've never learned the "whole thing" about VB.... don't care to.... but I know enough to feel like I've learned VB....
    Same w/ PHP, granted it might have taken me more than a week, but I attribut that to only being able to dedicate a couple of hours at a time, but I've gotten the hang of PHP pretty well.... again, I don't know it all, nor do I care to, but I know enough....
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  8. #8
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    boy you guys are missing the point. I have been working in php for a year and a half and I don't know it all. I learn something new each day.

    it is easy to learn php, granted, but you don't know it. you know all the functions and have used them? I bet not. that is learning php.

    when I here "I have learned php in a week" I think it means you know it all. sure you know how to use it but you don't know it.

    so according to you guys I can say

    <?php
    echo "hello";
    ?>

    means I know php?? that is not even knowing it.

  9. #9
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    I think you're missing the point.

    Are you trying to tell me that I don't know English? Because I'm pretty damn sure I don't know half the words in the English language, but I seem to speak it just fine.

    No, I don't know ALL of PHP, but I know a damn lot. And if I ever came across something I didn't know, I'm sure it wouldn't take me more than an hour to figure it out.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  10. #10
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    everybody knows the fundamentals of anything. doesn't mean you know it all.

    if you told me you learned php in a week you should be able to tell me everything about it, right? that is my meaning of learned it in a week.

    everything would have been fine if they said I understand php pretty good or I know the fundamentals of php.

    lets not nit pick there hobo, you knew what I meant.

  11. #11
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    No, I didn't, actually.

    So if I were to tell you "I learned English", you would tell me that I didn't?

    Has anyone learned anything, then? Besides stuff like: "I learned how to pronounce 'the'"?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  12. #12
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    totally different scenrio. english is far different than php, granted it is similiar in some ways eg. your learning a new language, BUT, english doesn't have boundaries, php does.

    english has slang, php doesn't. so don't compare english to php.

    my version of learning something is totally different than yours, apparently. so lets just leave it as that.

  13. #13
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Learn: To gain knowledge, comprehension, or mastery of through experience or study.

    I believe I have mastered PHP through experience and study. Therefor I have learned it.

    And I believe my comparison was very valid, whether you accept it or not.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  14. #14
    Hyperactive Member deane034's Avatar
    Join Date
    May 2001
    Location
    Sri Lanka
    Posts
    485
    commin back to the question guys..

    i have the same prob with php 4.3.2 and mysql 4

    give us a solution...
    me.life = VB

  15. #15
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    I learned PHP in an hour

    Once you know 1 language like C++, you can pick up alot of any other language within minutes to hours.

    Learning all the functions is another story. You don't need to learn them all and if you do learn them all, well nice job.

    Who really cares if you do know all of the functions or not. If you don't, you can write your own and if you can write functions, you're good to go.

    Originally posted by deane034
    commin back to the question guys..

    i have the same prob with php 4.3.2 and mysql 4

    give us a solution...
    Post the code you used, same with the other guy. It says error on line 8, SO POST LINE 8!

  16. #16

    Thread Starter
    Fanatic Member MikkyThomeon's Avatar
    Join Date
    Oct 2002
    Location
    At work...
    Posts
    648

    Angry

    I had a DNS error here and wasn't able to connect to the site for a few days sadly.

    hi phpman: The mysql server is running - I use MySQL for my VB apps every day. I can open a terminal window and execute scripts. in Linux without any hassles.

    Is there a site around where I can learn about how to configure the mysql module into apache so that it can work ... Then I can ask more questions if needed. I have been searching for a mysql module in the apache directory but the RH installer did not seem to install it properly to work with apache.

    The line of code read:

    mysql_connect("localhost");

    ...and there are no permissions on the database. I was logged in as root admin.

    Admittedly I don't know enough about sessions and security, but you guys will teach me, won't you?. I took a year before I stopped crawling in VB which was my first 4GL language, and no doubt is will be the same with php. In C,C++,PhP and other languages there are also a lot to learn, so I credit you all as being excellant in what you do and hopefully I will become as good as all of you!

  17. #17
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    apache has nothing to do with mysql, it is php tha tmakes the connection. what version of php do you have?

  18. #18
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Did you try creating a phpinfo page to see if you even have MySQL support?

    Create a page with this in it:

    Code:
    <?php phpinfo() ?>
    And see if there's a MySQL category anywhere. If not, then you probably don't have the MySQL modules installed for PHP.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  19. #19
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    The manual also gives this bit of information:

    By using the --with-mysql[=DIR] configuration option you enable PHP to access MySQL databases. If you use this option without specifying the path to MySQL, PHP will use the built-in MySQL client libraries. With PHP 4 MySQL support is always enabled; if you don't specify the configure option, the bundled libraries are used.

    Users who run other applications that use MySQL (for example, running PHP 3 and PHP 4 as concurrent apache modules, or auth-mysql) should always specify the path to MySQL: --with-mysql=/path/to/mysql. This will force PHP to use the client libraries installed by MySQL, avoiding any conflicts.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  20. #20

    Thread Starter
    Fanatic Member MikkyThomeon's Avatar
    Join Date
    Oct 2002
    Location
    At work...
    Posts
    648

    Some output from phpinfo();

    Running php 4.4.2
    Zend Engine v1.2.0

    Compiled Modules:
    Yp
    XML
    wddx
    sysvshm
    sysvsem
    standard
    sockets
    shmop
    session
    pspell
    posix
    pcre
    openssl
    ncurses
    iconv
    gmp
    gettext
    gd
    ftp
    exif
    domxml
    dio
    dbx
    dba
    curl
    ctype
    calendar
    bzz
    bcmath
    zlib
    imap
    ldap

    The exact error call: Call to undefined funtion mysql_connect() in /var/www/html/feedback.php on Line 9

    Line 9:

    %conn = mysql_connect("localhost");


    There are no compiled in modules despite the fact that I am using version 4.2.2. I appreciate the comments despite the fact that I have taken yonks to respond - I learn programming at home and program at work, if that provides explanation. It seems that I need to compile a MySQL module into php. Any pointers here...?

    Many Thanks
    Mike

  21. #21
    Are you using just

    Code:
    mysql_connect("localhost");
    ? You may need a username and password, if you've just installed it then there will be user "root" with a blank password:

    Code:
    mysql_connect("localhost", "root", "");
    After that you choose a database to work with:

    Code:
    mysql_connect("localhost", "root", "");
    mysql_select_db("mydb");

    <edit />
    Doh! Wasn't thinking If its undefined then there's no point to try alternate ways

    For mysql, try configuring PHP with mysql:

    ./configure --with-mysql

  22. #22

    Thread Starter
    Fanatic Member MikkyThomeon's Avatar
    Join Date
    Oct 2002
    Location
    At work...
    Posts
    648
    I will have a look at the configure option 2night and report back tomorrow.

    Thanks again.....

Posting Permissions

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



Click Here to Expand Forum to Full Width