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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:16:55+00:00 2026-06-05T13:16:55+00:00

Website. This feels like a common problem, but it’s a difficult one to Google!

  • 0

Website.

This feels like a common problem, but it’s a difficult one to Google!

As explained in the comment in the code, inserting the value was previously not a problem but stopped working when I added the additional INSERT queries below it.

$user = $_POST['name'];
$night = $_POST['club'];
$query = mysql_query("SELECT day FROM nights WHERE name = '$night'");
$email = $_POST['email'];

while ($row = mysql_fetch_assoc($query)) {

    $date = getFullDateString($row['day']);
    $date2 = getDateString($row['day']);

}

// this one previously worked but now enters into the database with $user as "Array"
mysql_query("INSERT INTO guestlists (guest, night, date) VALUES('$user', '$night', '$date') ") or die(mysql_error());

$guest1 = $_POST['name1'];
$guest2 = $_POST['name2'];

// these were added later and work fine but seem to have had an effect on the query above
mysql_query("INSERT INTO guestlists (guest, night, date) VALUES('$guest1', '$night', '$date') ") or die(mysql_error());
mysql_query("INSERT INTO guestlists (guest, night, date) VALUES('$guest2', '$night', '$date') ") or die(mysql_error());

foreach ($_POST as $key){
    if (is_array($key)){
        foreach ($key as $key2 => $value){
            mysql_query("INSERT INTO guestlists (guest, night, date) VALUES('$value', '$night', '$date') ") or die(mysql_error());

        }
    }
}
  • 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-05T13:16:57+00:00Added an answer on June 5, 2026 at 1:16 pm

    You should rename the guest HTML inputs to guests[] instead of using name again. You have a naming conflict.

    You need to fix this in your javascript code:

    var name = $("<p><input class='input' type='text' name='guests[]' value='' /></p>");
    

    And in your HTML code:

    <input class="input" type="text" name="guests[]" />
    

    After that, your PHP code should handle the guest variable as an array:

    $guests = $_POST['guests'];
    
    foreach ($guests as $guest)
    {
        mysql_query("INSERT INTO guestlists (guest, night, date) VALUES('$guest', '$night', '$date') ") 
        or die(mysql_error());
    }
    

    Note that you don’t need to go guests[1], guests[2], guests[3] etc.

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

Sidebar

Related Questions

use this website a lot but first time posting. My program creates a number
I have this website iloveforwards.com created using drupal. I would like to have a
this is my first post on this website, but I'm all the time getting
I feel like the answer to this question is probably very simple, but I'm
I've encountered a purely hypothetical problem which feels like it has an easy solution
I feel like such a noob asking this but, for some reason a horizontal
Visit this website. https://zapier.com/ See this portion of the website. I wan that same
In this website there are a list of for loop variations. I can understand
In this website, users can register under a username and password, and can also
I have this website I am designing and I want to make it to

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.