Jump to content

[SOLVED] Dynamic requirement of include file?


YourNameHere

Recommended Posts

session_start();
require('../config.php');
$classfunction = $race . '-functions.php';
//require($classfunction);
$con = mysql_connect($server, $db_user, $db_pass);
mysql_select_db($db); 
// Insert into chars
$sql = "Insert Into 'chars' (cname, class, owner, race) values ('$name', '$class', '$player', '$race')";
$result = mysql_query($sql);
//Insert into CharStats
$sql = "Insert Into 'charStats' (cname, dex, str, wis, int, con, cha, dexMod, strMod, wisMod, intMod, conMod, chaMod, ac, will, fort, ref, hp, speed, perception, init )
values ('$name', '$dex', '$str', '$wis', '$int', '$con', '$cha', '$dexMod', '$strMod', '$wisMod', '$intMod' '$conMod', '$chaMod', '$ac', '$will', '$fort', '$ref', '$hp', '$speed', '$perception', '$dexMod')";
// Set Variables
$race= $_POST['race'];

Link to comment
Share on other sites

As I said before $race isn't defined before you use it. Do you mean:

 

$classfunction = $_POST['race'] . '-functions.php';

?

 

Edit, just move your defining of $race to above where you're using it..

Link to comment
Share on other sites

Yes Thorpe, I saw that I posted the wrong one and fixed it sorry.

 

It worked when I did it your way but I thought that you could define something anywhere in your code and use it anywhere as opposed to the way javascript does it where you have to define THEN use. I cant remember where I was tought that.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.