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 8730177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:57:58+00:00 2026-06-13T08:57:58+00:00

So its simple, I need to replace the number 1 with 2 then 3

  • 0

So its simple, I need to replace the number 1 with 2 then 3 and so on 32 times. I know how to create simple PHP loops and everything but want to leave this “Clean” so its easier for you guys to help me.

Thank you for any help you can provide me.

<?php
  $con = mysql_connect("localhost","user","pass");
  if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }

  mysql_select_db("mbbcom1_rfhl", $con);

  $sql="UPDATE `mbbcom1_rfhl`.`_statbu`
  SET gp= gp + '$_POST[gp1]', g= g + '$_POST[g1]', a= a + '$_POST[a1]', shot= shot + '$_POST[s1]', pm= pm + '$_POST[pm1]', ppg= ppg + '$_POST[ppg1]', shg= shg + '$_POST[shg1]', bs= bs + '$_POST[blk1]', gwg= gwg + '$_POST[gwg1]', sog= sog + '$_POST[sog1]', soa= soa + '$_POST[soa1]', pim= pim + '$_POST[pim1]' WHERE `season` =9 AND `_statbu`.`player_id` = 1";
  if (!mysql_query($sql,$con))
    {
    die('Error: ' . mysql_error());
    }
  mysql_close($con)
  ?>

So just to be clear, i need the next loop to do the same thing but with ‘$_POST[gp2]’, g= g + ‘$_POST[g2]’ ….ect

Once again, thank you

  • 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-06-13T08:57:59+00:00Added an answer on June 13, 2026 at 8:57 am

    Wow, you need to look up SQL INJECTION. This code is NOT, NOT, NOT safe. You need to, at a bare minimum mysql_real_escape_string() on all of that posted data (example below).

    As to how to loop. If this is all updating the same table and you :

    //do your connection and db select here
    for( $i=1; $i <= 32; $i++ ) {
        $sql = "gp='".mysql_real_escape_string($_POST["gp{$i}"])."'...
        //mysql_query() here
    }
    //mysql_close() here
    

    You only wnat to die() on mysql_query if you want one query failing to break the other 31 or however many are left. Otherwise you can fail more gracefully and just ignore it, but leave yourself a message.

    You might also want to look into PDO if you have it available as it’s a bit simpler to use.

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

Sidebar

Related Questions

import sys, os X = os.system(ipconfig) print X 0 I know its simple, I'm
Its a simple question, but I'm not aware of the answer and I couldn't
May be its a simple question but it's really driving me crazy. I just
I think its a rather simple question but I couldn't really find an answer
So what I want to do seems relatively simple, but for the life of
I'm writing my own simple drop-down...and it's not going so well. I need only
Well, I have a simple question, at least I hope its simple. I was
I'm developing a desktop Mac OS X App that saves its very simple data
How to run javascript/Jquery functions on user specific time scenario its so simple when
I have a class CollectionOfThings . As its name suggests its a simple collection

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.