Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 336169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:13:02+00:00 2026-05-12T10:13:02+00:00

I am trying to update a field in a table by increasing its integer

  • 0

I am trying to update a field in a table by increasing its integer value by 1. Here is what I am using:

function updateViews($id){

$sql = "UPDATE tweets SET tweet_views = tweet_views + 1 WHERE tweet_key = '$id'";

$result = mysql_query($sql) or die("DB Error : ". mysql_error());

return $result;

}

However, I find its incrementing by 2 each time rather than 1? What am I doing wrong?

Thanks

Update

From the answers the SQL is correct. Do you think this may be affected by the rewrite engine??? I ask because I am 100% sure this doesn’t run twice or that I don’t make the call since there are two scripts. One that calls the function and one that holds the function! This is confusing.

Update 2

Using the debug function. I get this output:

array(4) {
  ["file"]=>
  string(35) "/home/magic/public_html/dbUpdate.php"
  ["line"]=>
  int(16)
  ["function"]=>
  string(15) "myDebugFunction"
  ["args"]=>
  array(0) {
  }
}

array(4) {
  ["file"]=>
  string(31) "/home/magic/public_html/view.php"
  ["line"]=>
  int(10)
  ["function"]=>
  string(11) "updateViews"
  ["args"]=>
  array(1) {
    [0]=>
    &string(5) "7jjdd"
  }
}

It looks as if the script is being called once but it is still getting updated twice??? HELP! 🙁

Also from the Log file, it looks as if the scripts are being called three times??

13:16:28 id:4a6c9d7cf38016.29304000
  _SERVER[REQUEST_URI]=/lucic
  _SERVER[REDIRECT_URL]=/lucic
  /home/magic/public_html/dbUpdate.php@16 :myDebugFunction
  /home/magic/public_html/view.php@10 :updateViews
13:16:30 id:4a6c9d7eaf93e3.88114161
  _SERVER[REQUEST_URI]=/lucic
  _SERVER[REDIRECT_URL]=/lucic
  /home/magic/public_html/dbUpdate.php@16 :myDebugFunction
  /home/magic/public_html/view.php@10 :updateViews
13:16:31 id:4a6c9d7f846557.12618673
  _SERVER[REQUEST_URI]=/lucic
  _SERVER[REDIRECT_URL]=/lucic
  /home/magic/public_html/dbUpdate.php@16 :myDebugFunction
  /home/magic/public_html/view.php@10 :updateViews

UPDATE 3

Here is the contents of my htaccess file which may be causing a problem.

# REWRITE DEFAULTS
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^www\.mysite\.com$ [NC]
RewriteRule ^(.*)$ http://mysite.com/$1 [R=301,L]

# /view.php?t=h5k6 externally to /h5k6
RewriteCond %{THE_REQUEST} ^GET\ /view\.php
RewriteCond %{QUERY_STRING} ^([^&]*&)*t=([^&]+)&?.*$
RewriteRule ^view\.php$ /%2? [L,R=301]

# /h5k6 internally to /view.php?t=h5k6
RewriteRule ^([0-9a-z]+)$ view.php?t=$1 [L]
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T10:13:02+00:00Added an answer on May 12, 2026 at 10:13 am

    You may want to include the HTML of the resulting page here. Its possible a script, link (css) or img tag are not formatted properly, and are getting into the rewrite by just being “”, “#” or “?” since those will ‘resolve’ to the same url. If you’re not absolute-pathing all of the urls (images/header.gif instead of /images/header.gif, etc) some of those may be falling through, especially since to a browser those short urls look like directories. Try doing the request in curl (without mirroring, just a simple GET) and see if it happens there.

    Also, turn on HTTP access and rewrite logging and see whats happening at that level (note, you have to put rewritelog directives in the compiled config, it wont work in a .htaccess). Failing that, watch the request in something like tamperdata, or even better, wireshark, to see the actual requests being made.

    Other things to think about: MultiViews On in your apache conf could be trying to add a suffix extension and it could be getting caught oddly by your rewrite (not sure how, but who knows) – and your rewrite log will show that. mod_dir could be trying to add a trailing slash (since those short urls look sort of like directories), though, you’d probably see that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 164k
  • Answers 164k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You may want to store the image content directly in… May 12, 2026 at 12:22 pm
  • Editorial Team
    Editorial Team added an answer You can use determinant to calculate values of x y… May 12, 2026 at 12:22 pm
  • Editorial Team
    Editorial Team added an answer I wouldn't base it on being called by the test… May 12, 2026 at 12:22 pm

Related Questions

I am trying to update a field in a table with data from another
I have a MS SQL DB with various tables, and one field in particular
I am trying to program a plugin to bbPress (the open source forum software)
Link I'm using ASP.NET with C# and trying to use linq to sql to
I'm using VS2008 C# Express and the Northwind database on a Windows Form application.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.