Need help on this one if you can spare me a second!!!
No idea why, been trying for 2 hours to fix this now and I feel like a complete loser haha.
Anyone have any idea why my UPDATE statements seem to be running 4 times when footer.inc.php is included but when I comment it out the UPDATE statement does not multiply the amount by 4????
It's the craziest thing I've ever seen, and the first ever time I'm seriously thinking it's a bug rather than my bad coding. Hopefully one of you can prove me wrong :-D
database.inc.php
[PHP]
<?php
// Europa100AD
//
// Database Connection - Aug 2007
//
// To be inclued in every file.
//
$query_count = 0;
class database extends mysqli
{
// Redefine the parent method
function query($query)
{
global $query_count,$query_log,$config;
$query_count++;
if ($config['query_logging'])
{
$query_log .= '<li>'.$query;
}
//echo "<br>counted query: total $query_count<br>\n";
$result = parent::query($query);
if($result === FALSE)
{
die("Query failed: $query <br>\n".$db->error);
}
echo '<br>-> <small>('.$query.')</small>';
return $result;
}
function return_first_result($query)
{
//
// EXAMPLE USAGE
//
//$test = $db->return_first_result("SELECT * FROM user_sleep");
//echo $test['assoc_id'];
$result = $this->query($query);
if($result === FALSE)
{
die("Query failed: $query <br>\n".$db->error);
}
return $result->fetch_assoc();
}
}
$db = new database("localhost", "db", "pass", "db");
/* check connection */
# Check the connection and print an error and stop the page if it can't connect
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
//printf("Host information: %s\n", $database->host_info);
?>
[/PHP]
index.php
[PHP]
<?php
// EUROPA 100 AD
//
// Main Handler
//
// August 2007
# Compress the output
ob_start("ob_gzhandler");
# Get the configurations
require_once('config.inc.php');
# Set variables (if any)
$user = new user();
$uid = $user->uid_check($_REQUEST['uid']);
//$user->load_tables('user_sleep');
//write('test');
# display main content
//print($buffer);
//$user_info = $user->load_tables('user_sleep,user_stats,user_settings' );
include_once($config['dir_inc'] . 'header.inc.php');
//load_page($_REQUEST['step']);
echo "<p><br><H1>Debug</h1><P>";
echo "<small><b>Query Log</b> ($query_count): $query_log<BR></small><BR>";
echo '</p>';
echo '<pre>';
echo var_dump(get_defined_vars());
echo '</pre>';
include_once($config['dir_inc'] . 'footer.inc.php');
# Dump the output to browser
ob_end_flush();
$sql = "UPDATE `user_finances` SET `quadrans` = `quadrans`+1 WHERE `assoc_id` ='27'";
$db->query($sql);
?>
[/PHP]
footer.inc.php
Expand|Select|Wrap|Line Numbers
- <div style="text-align: center;">
- <p></p>
- <p></p>
- <p>Copyright © <a href="http://www.ikahootz.com/">iKahootz.com</a>
- MMVII<br />
- <small>Designed by <a href="http://www.edg3.co.uk/">edg3.co.uk</a></small><br />
- <br />
- </p>
- </div>
- </div>
- <div class="center"><!-- DO NOT REMOVE THIS CENTER SECTION AS IT IS NEEDED BY THE DESIGN--> </div>
- <div class="right"> <img style="width: 300px; height: 168px;" src="image/rome04.gif" alt="01" /><br />
- <br />
- <img style="width: 300px; height: 144px;" src="image/rome08.gif" alt="02" /><br />
- <br />
- <img style="width: 300px; height: 387px;" src="image/rome11.gif" alt="01" /><br />
- <br />
- <br />
- <br />
- </div>
- </div>
- </body>
- </html>