Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Feb 2005
    Thanked 14 Times in 14 Posts

    need include help

    I'm adding some code into a forums registration process to also register (insert) the new user into a games user table. The code seems to work just fine. A new user is registered into both tables.

    But to try and keep the game code insertion separate, I'm trying to have the code in a separate file, and then just have a one line include statement.

    So, the code I've added to the registration.php file works, and looks like this:
    PHP Code:
    $qresult makequery("INSERT INTO game.users 
                            SET login = '$username',
                            pass = '$password',
                            email = '$email'"
    $uid mysql_insert_id($conn);
    //Free the resources
    But when I move that code to its own file, and replace it with an include, it doesn't work. No errors given, just doesn't add the user to the games table.
    PHP Code:

  • #2
    Master Coder
    Join Date
    Jun 2003
    Cottage Grove, Minnesota
    Thanked 1,096 Times in 1,087 Posts
    Did you try it yet with double-quotes?


  • #3
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Florida, USA
    Thanked 406 Times in 398 Posts
    The quotes shouldn't matter unless you're using a variable in the include filename. Add error checking. var_dump() your data & resultsets.

  • #4
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Denver, Colorado USA
    Thanked 340 Times in 332 Posts
    I'm guessing that either the include path/file does not exist relative to the current working directory of the file that is including it or there are no <?php and ?> tags in the include file.

    For the first possibility, check your web server log for errors and/or turn on full php error reporting (I'm getting a little tired of needing to suggest this common sense basic first troubleshooting step when people want to know why their code is not working ) For the second possibility, check your include file, post the whole complete contents of the include file, or view the source of the page in the browser (the PHP code would appear in the source since it did not get parsed by php.)
    Last edited by CFMaBiSmAd; 11-25-2007 at 03:45 AM.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.


    Posting Permissions

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