473,587 Members | 2,443 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

mysql update statements running 4 times

6 New Member
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.ph p
[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,$q uery_log,$confi g;
$query_count++;
if ($config['query_logging'])
{
$query_log .= '<li>'.$query;
}
//echo "<br>counte d 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>('.$quer y.')</small>';
return $result;
}

function return_first_re sult($query)
{

//
// EXAMPLE USAGE
//
//$test = $db->return_first_r esult("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("local host", "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_gz handler");

# Get the configurations
require_once('c onfig.inc.php') ;

# Set variables (if any)
$user = new user();

$uid = $user->uid_check($_RE QUEST['uid']);

//$user->load_tables('u ser_sleep');

//write('test');
# display main content
//print($buffer);
//$user_info = $user->load_tables('u ser_sleep,user_ stats,user_sett ings');

include_once($c onfig['dir_inc'] . 'header.inc.php ');
//load_page($_REQ UEST['step']);
echo "<p><br><H1>Deb ug</h1><P>";
echo "<small><b>Quer y Log</b> ($query_count): $query_log<BR></small><BR>";
echo '</p>';
echo '<pre>';
echo var_dump(get_de fined_vars());
echo '</pre>';
include_once($c onfig['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 1437
dougans
6 New Member
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 Recognized Expert Expert
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
dougans
6 New Member
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 Recognized Expert Expert
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
3252
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 configuration:
0
2129
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 + replication + windows XP PROF Hi, it's my story.
0
3938
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 version of this document can be found at: http://prdownloads.sourceforge.net/souptonuts/README_mysql.txt?download
16
16996
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 must be UPDATED, if not, they must be INSERTED. Logically then, I would like to SELECT * FROM <TABLE> WHERE ....<Values entered here>, and then IF FOUND UPDATE <TABLE> SET .... <Values entered here> ELSE INSERT INTO <TABLE> VALUES <Values...
2
3809
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 breaking point. The application is a typical web application w/ 2 web servers running Apache/Tomcat connecting to a dedicated DB server running only MySQL. This seems to occur as a result of running many statements in a single transaction, both...
5
2263
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 this but it's clear that I'm misunderstanding $variable persistence. I posted a similar enquiry over at alt.php.mysql, but I guess this is a more appropriate forum because the problems I'm having relate to PHP. Any help appreciated. ...
110
10529
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 case scenario for MyISAM backend? Also is it possible to not to lose data but get them corrupted?
14
2885
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 statement. I first connect to the database... self.con = MySQLdb.connect(user=username, passwd =password) self.cursor = self.con.cursor() self.cursor.execute("SET max_error_count=0")
2
1463
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 timestamps to record hours spent on different projects in a mysql database. If users try to enter times using the php interface, they are getting recorded correctly in the database because I can directly access it and see the entries there. ...
0
7924
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7854
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8349
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8221
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5395
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3845
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3882
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2364
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1192
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.