Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Location
    Earth
    Posts
    113
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Fatal error: Call to undefined function: dbconnect()

    if you refer to my 'member login' topic, you will see the link to the tutorial.

    http://www.webmasterbase.com/article/319/20

    i followed it to a T.

    now i keep getting this error when i try to test the database.

    Fatal error: Call to undefined function: dbconnect()

    i don't even know if it's even connecting. for me, line 55 (where the error is) is this part:

    <?php
    else:
    // Process signup submission
    dbConnect('sessions');


    i even created a database well the name of the table is 'use', and i placed 'use' there, and STILL no go.

    what am i doing wrong?

    my hosts give me only one database, which i have a lot of galleries in, is that the problem?
    Life is funny, especially when you're poor.

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    the Netherlands
    Posts
    215
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Have you included the part wich defines the dbConnect function?

    Code:
    function dbConnect($db="") {
        global $dbhost, $dbuser, $dbpass;
    
        $dbcnx = @mysql_connect($dbhost, $dbuser, $dbpass)
            or die("The site database appears to be down.");
    
        if ($db!="" and !@mysql_select_db($db))
            die("The site database is unavailable.");
    
        return $dbcnx;
    }
    You need that function, because you call it in line 55; or you could connect manualy using mysql_connect.

    Mzzl, Chris

  • #3
    Regular Coder
    Join Date
    Jul 2002
    Location
    Earth
    Posts
    113
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry

    yes. i did


    *SCREAMS*!



    I've only gotten a member login to work ONCE in my life. ONCE, that's it.


    i put the 'user' for the user name i need in order to enter mysql. i put the DATAbase, as the name of the mysql database that's there.

    BUT HOW WILL IT KNOW WHICH TABLE TO POINT TO? I DIDN'T SEE IT IN THE CODE.

    and why won't it connect to my database

    and what's this mean?

    <?php
    else:
    // Process signup submission
    dbConnect('sessions');


    is that the table?


    GRRR!!!


    p.s. i'm not angry with you, i'm angry with this STUPID script.
    Life is funny, especially when you're poor.

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    the Netherlands
    Posts
    215
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Could you post the whole script?

    (Ofcourse you can cut out your password and username )

    Mzzl, Chris

  • #5
    Regular Coder
    Join Date
    Jul 2002
    Location
    Earth
    Posts
    113
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy

    thank you


    this is the original db script:

    PHP Code:
    <?php // db.php
    $dbhost "localhost";
    $dbuser "user";
    $dbpass "password";

    function 
    dbConnect($db="") {    global $dbhost$dbuser$dbpass;

            
    $dbcnx = @mysql_connect($dbhost$dbuser$dbpass)
                    or die(
    "The site database appears to be down.");
                    
        if (
    $db!="" and !@mysql_select_db($db))
                die(
    "The site database is unavailable.");
                        return 
    $dbcnx;
    }
    ?>
    this is what i've done so far to change it

    PHP Code:
    <?php // db.php
    $dbhost "localhost";
    $dbuser "THE NAME I USE TO ENTER MYSQL";
    $dbpass "THE PWD I USE TO ENTER MYSQL";

    function 
    dbConnect($db="") {    global $dbhost$dbuser$dbpass;

            
    $dbcnx = @mysql_connect($dbhost$dbuser$dbpass)
                    or die(
    "The site database appears to be down.");
                    
        if (
    $db!="" and !@mysql_select_db($db))
                die(
    "The site database is unavailable.");
                        return 
    $dbcnx;
    }
    ?>

    strange that it gives me
    $dbhost
    etc. etc. but not
    $db=

    anyhow, and here goes also

    the script:

    PHP Code:
    <?php // signup.php

    require ("common.php");
    require (
    "db.php");

    if (!isset(
    $submitok)):
    // Display the user signup form
    ?>
    <html>
    <head><title>New User Registration</title></head>
    <body>
    <h3>New User Registration Form</h3><p><font color=orangered size=+1><TT><B>*</B></TT></font>
       indicates a required field</p><form method=post action="<?=$PHP_SELF?>"><table border=0 cellpadding=0 cellspacing=5>
        <tr>
            <td align=right>
                <p>User ID</p>
            </td>
            <td>
                <input name=newid type=text maxlength=100 size=25>
                <font color=orangered size=+1><TT><B>*</B></TT></font>        </td>
        </tr>
        <tr>
            <td align=right>
                <p>Full Name</p>
            </td>
            <td>
                <input name=newname type=text maxlength=100 size=25>
                <font color=orangered size=+1><TT><B>*</B></TT></font>        </td>
        </tr>
        <tr>
            <td align=right>
                <p>E-Mail Address</p>
            </td>
            <td>
                <input name=newemail type=text maxlength=100 size=25>
                <font color=orangered size=+1><TT><B>*</B></TT></font>        </td>
        </tr>
        <tr valign=top>
            <td align=right>
                <p>Other Notes</p>
            </td>
            <td>
                <textarea wrap name=newnotes rows=5 cols=30></textarea>        </td>
        </tr>
        <tr>
            <td align=right colspan=2>
                <hr noshade color=black>
                <input type=reset value="Reset Form">
                <input type=submit name="submitok" value="   OK   ">
            </td>
        </tr></table></form>
        <?php
        
    else:
        
    // Process signup submission
        
    dbConnect('sessions');
        
    if (
    $newid=="" or $newname=="" or $newemail=="") {
        
    error("One or more required fields were left blank.\\n".
                  
    "Please fill them in and try again.");    }
                  
       
    // Check for existing user with the new id
       
    $sql "SELECT COUNT(*) FROM user WHERE userid = '$newid'";
       
    $result mysql_query($sql);
       if (!
    $result) {
             
    error("A database error occurred in processing your ".
                       
    "submission.\\nIf this error persists, please ".
                       
    "contact [email]me@me.com[/email].");    }
       if (@
    mysql_result($result,0,0)>0) {
           
    error("A user already exists with your chosen userid.\\n".
                 
    "Please try another.");    }
       
    $newpass substr(md5(time()),0,6);
       
    $sql "INSERT INTO user SET
              userid = '$newid',
              password = PASSWORD('$newpass'),
              fullname = '$newname',
              email = '$newemail',
              notes = '$newnotes'"
    ;
    if (!
    mysql_query($sql))
        
    error("A database error occurred in processing your ".
              
    "submission.\\nIf this error persists, please ".
              
    "contact [email]me@me.com[/email].");
         
    // Email the new password to the person.
    $message "New member

    Your personal account for the Me Web Site has been created. To log in, proceed to the following address:

        [url]http://www.me.com/[/url]

    Your personal login ID and password are as follows:

        userid: $newid
        password: $newpass

    You can change your password at any time after you have logged in.
    If you have any problems, feel free to contact us at<me@me.com>.

    Webmaster"
    ;
        
    mail($newemail,"Your Password for the Project Website",
         
    $message"From:Webmaster <webmaster@ame.com>");
        
    ?>
        <html>
        <head><title> Registration Complete </title></head>
        <body>
        <p><strong>User registration successful!</strong></p>
        <p>Your userid and password have been emailed to
           <strong><?=$newemail?></strong>, the email address
           you just provided in your registration form. To log in,
           click <a href="index.php">here</a> to return to the login
           page, and enter your new personal userid and password.</p>
        </body>
        </html>
        <?php
        
    endif;
        
    ?>
    Life is funny, especially when you're poor.

  • #6
    Regular Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    577
    Thanks
    0
    Thanked 0 Times in 0 Posts
    maybe a slight syntax change

    PHP Code:
    function dbConnect($db) {
    global 
    $dbhost$dbuser$dbpass;
    $dbcnx = @mysql_connect($dbhost$dbuser$dbpass)
                    or die(
    "The site database appears to be down.");
    if (
    $db!=="") {
    @
    mysql_select_db($db);
    return 
    $dbcnx;
    }
    else {
    die(
    'errrr the database has disappeared');
    }

    Maybe trying to pass values in as $db while using ($db="") was
    glitching -
    Ökii - formerly pootergeist
    teckis - take your time and it'll save you time.

  • #7
    Regular Coder
    Join Date
    Jul 2002
    Location
    Earth
    Posts
    113
    Thanks
    0
    Thanked 0 Times in 0 Posts
    parse error in ...


    no luck. now it gives me a phrase error.

    the real error comes here...

    Call to undefined function: dbconnect()


    which is this part of the code:

    PHP Code:
    dbConnect('sessions'); 
    it keeps teling me it's undefined.

    WHERE DO I DEFINE THE DB,. could someone go throught the code and write what i put where.

    it keeps telling me that it cannot find my database now, after i've changes some things


    *cries*
    Life is funny, especially when you're poor.

  • #8
    Regular Coder
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    126
    Thanks
    0
    Thanked 0 Times in 0 Posts
    As you can tell from the PHP highlighting there is clearly something wrong just here:

    PHP Code:
    $message "New member

    Your personal account for the Me Web Site has been created. To log in, proceed to the following address:

        <a href="
    http://www.me.com/" target="_blank">[url]http://www.me.com/[/url]</a>

    Your personal login ID and password are as follows:

        
    userid$newid
        password
    $newpass

    You can change your password at any time after you have logged in
    .
    If 
    you have any problemsfeel free to contact us at<me@me.com>.

    Webmaster"; 
    Try adding backslashes in front of the double quotes inside the string.

    Not too sure whether this has anything to do with the error message - but you should fix this anyway, because it won't work if you don't.

  • #9
    Regular Coder
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    126
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hmm... this is all a bit weird...

    Are you sure that the db.php file is in the same directory?
    By the way the $db="" syntax is just a way of making "" a default value for the $db variable if none is passed to the function.

    But then it should throw up an error if it couldn't find the file if this was the case, since you're using require.

    Try fixing the little problem I noticed and then see if you still get the problem.. I can't see that the two are related though.

  • #10
    New Coder
    Join Date
    Jan 2003
    Location
    Rochester, NY
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    any resolution

    This is the exact same problem i am having - I posted on it, but none of the help seemed to help. Anyway, after another fresh install of rh 8 , with mysql and php. I get this error whenever i try to use mysql_connect()

    Fatal error: Call to undefined function: mysql_connect() in /var/www/html/PHP/test2.php on line 6

    Line 6 being -

    $db = mysql_connect("localhost", "user", "pass");

    grr.. haven't gotten this working yet..

  • #11
    New Coder
    Join Date
    Jan 2003
    Location
    Rochester, NY
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Does anyone look at this stuff?

  • #12
    Regular Coder
    Join Date
    Nov 2002
    Location
    Bristol, UK
    Posts
    932
    Thanks
    0
    Thanked 0 Times in 0 Posts
    applefool - I have looked over your code but the cause of the original error is not immediately apparent, however there are errors in the last piece of code you posted - the quotes are wrongly used, as mouldygoat pointed out.

    I totally understand if you want to solve this problem, but I can offer an alternative solution. I have just finished a rewrite (version 2.0) of my security scripts, and I would be happy to let you use them and give me some feedback. It's up to you

    ::] krycek [::
    ithium | SOAPI | SDP | PTPScript manual
    "ithium is a non-profit webhost, which is pretty much unique. The mission of ithium is to provide free hosting resources for worthwhile and needy non-profit projects, which otherwise may not be able to obtain such facilities. The money from commercial customers goes to maintain ithium's servers and further development."

  • #13
    New Coder
    Join Date
    Jan 2003
    Location
    Rochester, NY
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The bit of code with quote comes right out of a book for php/mysql.

    This is just a means of connecting to the mysql db as far as i know.

    As i said this is a fresh install of redhat 8, so i am unclear as to why no one else has this problem. Anything i try using the mysql_connect() fails with the above mentioned error. I am positive my php code is not the problem, as i have tried various bits of php code all using mysql_connect() and all return that same error.

    Surely, someone must have set up a linux to use mysql and php..

  • #14
    Regular Coder
    Join Date
    Nov 2002
    Location
    Bristol, UK
    Posts
    932
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Lol, I use both windows and linux for my php.

    believe me, your code that I and others have pointed at, is wrong, no matter where it came from.

    if you ask for help, and you don't believe the answers, that's not our fault!

    ::] krycek [::
    ithium | SOAPI | SDP | PTPScript manual
    "ithium is a non-profit webhost, which is pretty much unique. The mission of ithium is to provide free hosting resources for worthwhile and needy non-profit projects, which otherwise may not be able to obtain such facilities. The money from commercial customers goes to maintain ithium's servers and further development."

  • #15
    Regular Coder
    Join Date
    Nov 2002
    Location
    Bristol, UK
    Posts
    932
    Thanks
    0
    Thanked 0 Times in 0 Posts
    oh yeah, one thing, with regard to the mysql error....... you have got mysql installed and running yeah? and compiled into php?

    simply create a page with <?php phpinfo(); ?> on it and run it. then look at the mysql details.

    also, try installing phpMyAdmin. if that works, your system is setup ok.

    ::] krycek [::
    ithium | SOAPI | SDP | PTPScript manual
    "ithium is a non-profit webhost, which is pretty much unique. The mission of ithium is to provide free hosting resources for worthwhile and needy non-profit projects, which otherwise may not be able to obtain such facilities. The money from commercial customers goes to maintain ithium's servers and further development."


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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