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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:28:59+00:00 2026-06-03T04:28:59+00:00

I am currently trying to post the value of xml title to an array

  • 0

I am currently trying to post the value of xml title to an array which in turn will be used to save a holiday. I am still getting no error messages and have used a var_dump to gather the following infomation. (ticked a few check box’s relating to reading the RSS feed)

array(7) { [0]=> string(21) "{$currentItem->title}" [1]=> string(21)"{$currentItem->title}" [2]=> string(21) "{$currentItem->title}" [3]=> string(21) "{$currentItem->title}" [4]=> string(21) "{$currentItem->title}" [5]=> string(21) "{$currentItem->title}" [6]=> string(21) "{$currentItem->title}" } :S 

This to me shows that the array side is working but it is not holding the information set within the value parameters for the check box as all strings are 21?.
21 is the number of characters between the quotes of the value of saveBox!!

Section from index.php

$index = 1;
    foreach ($allHolidays as $currentItem)
        {
            echo '<tr>';
            if (isset($_SESSION['login']))
                {
                    echo '<td valign="top">';
                    //echo '<input type="hidden" name="guid$index" value="{$currentItem->guid}">';name="saveBox$index[]"
                    echo '<input type="checkbox" name="saveBox[]" value="{$currentItem->title}">';
                    echo '</td>';
                }
            echo '<td>';
            echo "<p><a href=\"{$currentItem->link}\">{$currentItem->title}</a><br/>";
            echo "{$currentItem->description}<br/>";
            echo "{$currentItem->pubDate}<br/></p>";
            echo '</td>';
            echo '</tr>';
            $index++;
        }

saveProcess.php

<?php   
    header("refresh:555; url='index.php'");
    session_start();

    echo "Thank you for saving a holiday";
    echo '<input type="checkbox" name="saveBox[]" value="'.
    htmlspecialchars($currentItem->title).'">';
    include "top.php";
    var_dump($_POST['saveBox']);

    try
    {

        foreach ($_POST['saveBox'] as $savedHoliday)
        {
            $user = $_SESSION['login'];
            $currentSave = $savedHoliday;
            $save = "channel/item[title=\"$currentSave\"]";
            $holidaysXML = simplexml_load_file('holidays.xml');
            $savePath = $holidaysXML->xpath($save);
            foreach($savePath as $currentSavePath)
                    {
                        echo "<p><a href='{$currentSavePath->link}'>{$currentSavePath->title}</a>"."<br\>".
                        "{$currentSavePath->description}"."<br\>".
                        "{$currentSavePath->pubDate}"."<br\></p>";

                        $insertSave = $db->prepare("INSERT INTO `saved_holidays` (`subscriberID`, `link`, `pubDate`, `title`, `description`)
                        VALUES ('$user', '$currentSavePath->link', '$currentSavePath->pubDate', '$currentSavePath->title', '$currentSavePath->description')");

                        $insertSave->execute();
                    }

        }
    }
    catch(PDOException $e)
        {
            echo $e->getMessage();
        }
  • 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-03T04:29:01+00:00Added an answer on June 3, 2026 at 4:29 am

    You are using the construct saveBox$index[] wrong. You should simply name your inputs saveBox[] and forget the index. PHP will automatically give you an array when you read $_POST['saveBox'] on the receiving side.

    Don’t forget that you should also call htmlspecialchars on all data you embed into HTML:

    echo '<input type="checkbox" name="saveBox[]" value="'.
         htmlspecialchars($currentItem->title).'">';
    

    And:

    foreach ($_POST['saveBox'] as $savedHoliday)
    

    As an aside, you should always call header and session_start before you produce any output, so if top.php produces output it should move a few lines downwards.

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

Sidebar

Related Questions

Currently I was trying the jquery,css dropdown which is from here. http://www.jankoatwarpspeed.com/post/2009/07/28/reinventing-drop-down-with-css-jquery.aspx I added
I'm currently trying to post a JSON object from my view to my controller
1st post on stackoverflow, hope to have great feedback :) I'm currently trying to
I'm currently trying to create a little C/C++ program which emulates a key-press on
I am currently creating a class to handle all my form data which will
I'm currently trying to pass Silverlight a string value from the parent JavaScript. The
I'm trying to measure the popularity of a post but there's no current system
I'm trying to create an auto generated post excerpt from the current page's post
Currently trying at add ajax to a site, after much reading I discovered that
Im currently trying to downlaod a audio track from a WCF, i need some

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.