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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:17:50+00:00 2026-06-07T03:17:50+00:00

I have multiple arrays which I am passing to a file sales_process.php on the

  • 0

I have multiple arrays which I am passing to a file sales_process.php on the form submit action. The arrays are named like this : boards1 = {a , b , c}, boards2 = {b , c , d}, boards3 = {a , c , d} . . and so on (The values are not a,b,c,d). I am passing them through multiple ‘multiple select boxes’ in my form like this where a,b,c,d are my multiple select options :

for ($count=1;$count<10;$count++)
echo "<td>"."<select name='boards".$count."[]' multiple='multiple'>".showOptionsDrop($boards,$arr)."</select></td>";  

Now when i pass them to the file sales_process.php, i want to convert these arrays into strings using implode function so that i can store them into my ‘schools’ table. In sales_process.php file, I am doing this:

for ($i=0;$i<$count;$i++) {
$board = implode(',',${'boards'.$i});
$query = "UPDATE schools SET board = '$board' where schoolcode = (some_no)";
$result = mysql_query($query) or die("Error in updating table :".mysql_error());
}  

So in this way, every time my loop runs, the values of boardsX gets converted into string and gets stored in the table, where X is 1,2,3…. and so on.
The problem is the implode function is not working and giving error :
Warning: implode() [function.implode]: Invalid arguments passed in C:\xampp\htdocs\relationshipReport\sales_process.php on line 18

Now if you say that the variable ${'boards'.$i} is not an array, i did this and found out that its giving me an array only :

$i=1;
var_dump(${'boards'.$i});
print_r(${'boards'.$i});  

which gives the output as :

array(3) { [0]=> string(4) "CBSE" [1]=> string(4) "ICSE" [2]=> string(5) "IGCSE" }
Array ( [0] => CBSE [1] => ICSE [2] => IGCSE )  

I hope my question is clear. Please help me in finding out whats going wrong in the implode function. If you don’t understand the question, please mention it.

  • 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-07T03:17:52+00:00Added an answer on June 7, 2026 at 3:17 am

    From your examples, I believe this is your current code:

    for ($i=0;$i<$count;$i++) {
        $board = implode(',',${'boards'.$i});
        $query = "UPDATE schools SET board = '$board' where schoolcode = (some_no)";
        $result = mysql_query($query) or die("Error in updating table :".mysql_error());
    } 
    

    If so, try altering it so it looks like this:

    for ($i=0;$i<$count;$i++) {
        if(isset($_POST['boards'.$i]))
        {
            $board = mysql_real_escape_string(implode(',',$_POST['boards'.$i]));
            $query = "UPDATE schools SET board = '$board' where schoolcode = (some_no)";
            $result = mysql_query($query) or die("Error in updating table :".mysql_error());
        }
        else
        {
            echo '$_POST[\'boards' . $i . '\'] doesn\'t exist or is null.<br>';
        }
    } 
    

    This contains an if condition, checking that the array entry actually exists. If it does exist, it runs the query. If it doesn’t, it echos back a message, telling you which one doesn’t exist.

    Even if you have confirmed at the frontend with Javascript, you should always check before running code, just to be sure it won’t break it. You can never be too safe, especially if your code contains sensitive information.

    Try this, and let me know how you go.

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

Sidebar

Related Questions

I have this ingredients array which contains multiple variables (like name, icon, value etc.).
I have an html document with multiple commented-out PHP arrays, e.g.: <!-- Array (
I have a binary file, inside of which has multiple frames. Each frame starts
I have multiple String arrays in my program (of which i have made individual
I have multiple arrays shown below. <?php $arrLayout = array( section1 => array( wXBMCLibrary
i have function which is something like this function multiple_delete($entity1,$entity2,$entity2) { $query = SELECT
I have multiple arrays with string values and I want to compare them and
Assume that we have multiple arrays of integers. You can consider each array as
I have a multidimensional array, and I would have multiple arrays within it. Some
Is it possible to calculate the mean of multiple arrays, when they may have

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.