View Full Version : need include help

11-25-2007, 01:04 AM
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:

$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.


11-25-2007, 03:10 AM
Did you try it yet with double-quotes?


11-25-2007, 03:16 AM
The quotes shouldn't matter unless you're using a variable in the include filename. Add error checking. var_dump() your data & resultsets.

11-25-2007, 03:43 AM
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.)