and something i have noticed, is that with functions, i am having to include the databse connection script inside the newly created function... aswell as at the start -.- lol
is there any way of getting custom functions to use the single included connection script added at the top of the page?
the same is happening with my $uid variable... i have to reset that inside the function aswell ¬¬
Code: Select all
require "../_scripts/session_check.php";
require "../_scripts/connect_to_db.php";
$uid = $_SESSION['uid'];
$locationRow = mysql_fetch_assoc(mysql_query("SELECT * FROM user_map_location WHERE user_id='$uid'",$dbconec1));
$mapnameinfo = mysql_fetch_assoc(mysql_query("SELECT map_name, map_type, x_size, y_size FROM map_name WHERE map_id='$locationRow[map_id]'",$dbconec1));
function makeHunt(){
require "../_scripts/connect_to_db.php";
$uid = $_SESSION['uid'];
$locationRow = mysql_fetch_assoc(mysql_query("SELECT * FROM user_map_location WHERE user_id='$uid'",$dbconec1));
$table = "active_info_" . $locationRow['map_id'];
$huntInfo = mysql_fetch_assoc(mysql_query("SELECT * FROM `$table` WHERE type='2'",$dbconec1));
$length = strlen($huntInfo['x_loc']);
$xLocN = 1;
for($x=0; $x<=$length; $x++){
if(mb_substr($huntInfo['x_loc'],$x,1) != ";"){
$huntXloc[$n] = mb_substr($huntInfo['x_loc'],$x,1);
$huntYloc[$n] = mb_substr($huntInfo['y_loc'],$x,1);
$huntXsec[$n] = mb_substr($huntInfo['x_sec'],$x,1);
$huntYsec[$n] = mb_substr($huntInfo['y_sec'],$x,1);
$huntLvl[$n] = mb_substr($huntInfo['level'],$x,1);
} else {
$n++;
}
}
for($x=1; $x<=$n; $x++){
if(($huntXloc[$x] == $locationRow['map_x']) && ($huntYloc[$x] == $locationRow['map_y'])){
print "<div id='MAPsection" . $huntXsec[$x] . $huntYsec[$x] . "'>";
$display = "Hunt<br>Difficulty level: " . $huntLvl[$x];
print "<a onMouseover=\"ddrivetip('" . $display . "')\" onMouseout=\"hideddrivetip()\" href='hunt.php?map=0'><img src='../_img/map/hunt.png' border='0'></a>
</div>";
}
}
}