473,322 Members | 1,501 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

mysql update statements running 4 times

Hey there people,

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>-&gt; <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
  1.  
  2.     <div style="text-align: center;">
  3. <p></p>
  4.  
  5. <p></p>
  6.  
  7. <p>Copyright &copy; <a href="http://www.ikahootz.com/">iKahootz.com</a>
  8. MMVII<br />
  9.  
  10. <small>Designed by <a href="http://www.edg3.co.uk/">edg3.co.uk</a></small><br />
  11. <br />
  12.  
  13. </p>
  14.  
  15. </div>
  16.  
  17. </div>
  18.  
  19. <div class="center"><!-- DO NOT REMOVE THIS CENTER SECTION AS IT IS NEEDED BY THE DESIGN--> </div>
  20.  
  21. <div class="right"> <img style="width: 300px; height: 168px;" src="image/rome04.gif" alt="01" /><br />
  22.  
  23. <br />
  24.  
  25. <img style="width: 300px; height: 144px;" src="image/rome08.gif" alt="02" /><br />
  26.  
  27. <br />
  28.  
  29. <img style="width: 300px; height: 387px;" src="image/rome11.gif" alt="01" /><br />
  30.  
  31. <br />
  32.  
  33. <br />
  34.  
  35. <br />
  36.  
  37. </div>
  38.  
  39. </div>
  40.  
  41.  
  42. </body>
  43. </html>
  44.  
Aug 16 '07 #1
4 1415
update: if I delete the contents of footer.inc.php (all of which are shown above) the UPDATE statement runs normally...


header.inc.php (in case its worth mentioning)
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head profile="http://gmpg.org/xfn/11">
  4.  
  5. <!-- Earthy Colours by christopher robinson http://www.edg3.co.uk/ hope you enjoy it and find it usefull :) -->
  6.   <title>Europa 100 AD :: Ancient Rome Online RPG Strategy Game</title>
  7.  
  8.  
  9.   <link rel="shortcut icon" href="/favicon.ico" />
  10.  
  11.   <link rel="stylesheet" href="/style.css" type="text/css" media="screen" />
  12.  
  13.   <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
  14.  
  15.   <meta http-equiv="content-language" content="en-gb" />
  16.  
  17.   <meta http-equiv="imagetoolbar" content="false" />
  18.  
  19.   <meta name="author" content="iKahootz.com" />
  20.  
  21.   <meta name="copyright" content="Copyright (c) Christopher Robinson 2005 - 2007" />
  22.  
  23.   <meta name="description" content="" />
  24.  
  25.   <meta name="keywords" content="" />
  26.  
  27.   <meta name="last-modified" content="Sat, 01 Jan 2007 00:00:00 GMT" />
  28.  
  29.   <meta name="mssmarttagspreventparsing" content="true" />
  30.  
  31.   <meta name="robots" content="index, follow, noarchive" />
  32.  
  33.   <meta name="revisit-after" content="7 days" />
  34.  
  35. </head>
  36.  
  37.  
  38. <body>
  39.  
  40. <div id="header">
  41. <div id="header_inside">
  42. <h1>Europa 100 AD...</h1>
  43.  
  44. <h2>the road to success</h2>
  45.  
  46. </div>
  47.  
  48. </div>
  49.  
  50. <div id="navigation">
  51. <ul>
  52.  
  53.     <p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><li><a href=""  class="active">home</a></li><li><a href="" >rome</a></li>
  54.  
  55.  
  56. </ul>
  57.  
  58. </div>
  59.  
  60. <div id="content">
  61. <div class="left">
  62.  
  63.  
Aug 16 '07 #2
pbmods
5,821 Expert 4TB
Heya, dougans.

Any chance you have images with empty src attributes? Perhaps an improperly-set background image in a CSS file?

An empty URL will (in the absence of a BASE tag in the HEAD) default to the current page, which could explain why the query gets called too many times.

I didn't see anything in the code you posted that might suggest that this is the case, but you are more familiar with it than I am (I hope!), and maybe this will give you a starting point.
Aug 16 '07 #3
Heya, dougans.

Any chance you have images with empty src attributes? Perhaps an improperly-set background image in a CSS file?

An empty URL will (in the absence of a BASE tag in the HEAD) default to the current page, which could explain why the query gets called too many times.

I didn't see anything in the code you posted that might suggest that this is the case, but you are more familiar with it than I am (I hope!), and maybe this will give you a starting point.

I have four words for you, please arrange them into a well known phrase...

LEGEND A ARE YOU

I don't feel so bad now, as I've never claimed to be an expert at CSS... thanks a billion. I have 3 images I've moved physically but not yet in the CSS sheet, that'll be the problem there.

For future reference though; excluding the obvious ("fixing the broken link") what can you do to avoid this problem in the future (you say something about a base tag)?
Aug 17 '07 #4
pbmods
5,821 Expert 4TB
Heya, dougans.

For an explanation of how the BASE tag (commonly referred to as base href) works, check out this article.

Glad to hear you got it working! Good luck with your project, and if you ever need anything, post back anytime :)
Aug 17 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: I.P. | last post by:
Hi, it's my story. I have two 4.0.14 mysql server on one machine with win XP Professional polish version. First acts as master: on port 3300 Second acts as slave: on port 3301 below my...
0
by: I.P. | last post by:
No one has replied to my post. ----- Original Message ----- From: "I.P." <jancio_wodnik@wp.pl> To: <mysql@lists.mysql.com> Sent: Monday, August 18, 2003 1:01 PM Subject: mysql 4.0.14 +...
0
by: Mike Chirico | last post by:
Interesting Things to Know about MySQL Mike Chirico (mchirico@users.sourceforge.net) Copyright (GPU Free Documentation License) 2004 Last Updated: Mon Jun 7 10:37:28 EDT 2004 The latest...
16
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
2
by: saran | last post by:
I am having a problem with MySQL consuming a lot of memory and eventually throwing an Out of Memory error and restarting itself. The symptoms are that swap usage continues to rise until some...
5
by: strawberry | last post by:
In the function below, I'd like to extend the scope of the $table variable such that, once assigned it would become available to other parts of the function. I thought 'global $table;' would solve...
110
by: alf | last post by:
Hi, is it possible that due to OS crash or mysql itself crash or some e.g. SCSI failure to lose all the data stored in the table (let's say million of 1KB rows). In other words what is the worst...
14
by: Ben | last post by:
I don't know whether anyone can help, but I have an odd problem. I have a PSP (Spyce) script that makes many calls to populate a database. They all work without any problem except for one...
2
by: Troy Piggins | last post by:
We have some php pages on our intranet at work that have been working fine for years. As a result, they rarely get edited. The page I'm having trouble with is a timesheet entry page which uses...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.