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.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Feb 2005
    Posts
    663
    Thanks
    5
    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
            
    @mysql_free_result($qresult); 
    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:
    include_once('includes/game_activation.php'); 

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,470
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    Did you try it yet with double-quotes?

    include_once("includes/game_activation.php");

  • #3
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 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
    Location
    Denver, Colorado USA
    Posts
    3,026
    Thanks
    2
    Thanked 315 Times in 307 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 02: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
    •