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

  • SEARCH
  • Home
  • 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 7403519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:06:21+00:00 2026-05-29T05:06:21+00:00

Thanks in advance, here is what is going on: if(isset($_POST[‘submit’])) { $var = $_GET[‘var’];

  • 0

Thanks in advance, here is what is going on:

if(isset($_POST['submit']))
{
$var = $_GET['var'];

foreach((array)$_POST['content'] as $area => $contents)
    {

        $result = 'UPDATE $table SET '.$area.' = "'.mysql_real_escape_string(stripslashes($contents)).'" WHERE var = "'.$_GET['var'].'";';
        mysql_query ($result);
    }


$query = 'UPDATE $table SET '.
            'title = "'.mysql_real_escape_string(stripslashes($_POST["title"])).'", '.
            'template = "'.mysql_real_escape_string($_POST["templateid"]).'", '.
            'description = "'.mysql_real_escape_string(stripslashes($_POST["description"])).'", '.
            'keywords = "'.mysql_real_escape_string(stripslashes($_POST["keywords"])).'" '.
            ' WHERE var = "'.$_GET['var'].'";';

mysql_query ($query);// or die(mysql_error());

}

I am unable to get the if statement to go beyond the for each loop. It will not update the database with the $query mysql statement. It simple updates the table for everything inside the for each loop and then exists. Do I need to do an If while or else if? And I tried looking up php conditional statements, is there such a thing as and statements? Such as: If post submit do this AND this? That is essentially what I am trying to do, If post submit, do for each loop AND do $query.

Let me know if you need more information.

  • 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-29T05:06:22+00:00Added an answer on May 29, 2026 at 5:06 am

    Well, is $_POST['content'] defined at all? In cases like this you may want to start debugging with print_r($_POST) to see all values that you get.

    What you probably intended to do is:

    foreach ($_POST as $key => $val)
    

    Edit:
    And you should really escape that $_GET['var'] as well as the $area in the loop!!! Escape ALL user input, always!!!

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

Sidebar

Related Questions

newbie here, so thanks in advance for help! I have a Wordpress site with
I am going nuts here, I have an array of checkboxes from a form
I can't figure out what's going on here... I'm trying to copy an array,
Thanks in advance to anyone who can think of a more efficient or a
Thanks in advance for your help. I have a need within an application to
thanks in advance for looking at this. Essentially, I'm calling didInsertElement() and binding an
Thanks in advance for your assistance. I have the following exported part: [Export (typeof(INewComponent))]
Thanks in advance for any help you can provide on this issue! I manage
Thanks in advance for taking the time to read my question. I'm using MySQL
Thanks in advance for your help experts. I want to be able to copy

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.