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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:03:31+00:00 2026-06-14T15:03:31+00:00

My code is: HTML part for POST: <form action=’key.php’ method=’POST’> <input type=’number’ name=’consumervar[]’ value=’512’/>

  • 0

My code is:

HTML part for POST:

<form action='key.php' method='POST'> 
<input type='number' name='consumervar[]' value='512'/>
<input type='number' name='consumervar[]' value='256'/>
<input type='number' name='consumervar[]' value='1024'/>
<input type='submit'/>
</form>

PHP Code for key.php:

<?PHP
  foreach ($_POST as $key => $value) {
    $consumervar = $value*64;
  }
  print_r($consumervar); // this is for for debug (see array contents)
?>

BUt when i run everything it reproduces:

Fatal error: Unsupported operand types in /var/blahblah/blahblah/key.php on line 3

Please help. How to do it correctly? It need to multiply every posted value with integer 64.

  • 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-14T15:03:32+00:00Added an answer on June 14, 2026 at 3:03 pm

    the loop should be

    foreach($_POST['consumervar'] as $key => $value) {
                  ^^^^^^^^^^^^^^^
    

    as written, your code pulls out the ARRAY of consumervar values, which you try to multiply. You cannot “multiply” arrays in php.

    As well, note that the $key/$value produced by the loop are simply copies of what exists in the array. You are not changing the array’s values. For that, you should be doing

     $_POST['consumervar'][$key] = $value * 64;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So here is my html code: <!doctype html> <html lang=fr> ... <form action=servlet method=post>
my problem is the following: This is a part of my HTML-Code: <form method='GET'
I have the following code: HTML <div id='foo'> <input type='checkbox' value='english' name='bar[english]' /> <input
Jquery: <script type=text/javascript> $(document).ready(function(){ $(form.register).change(function() { $.post(check.php, $(form.register).serialize(), function( data ) { if( data.username
I have some old code with document.write in it. <script type=text/javascript language=JavaScript1.2> document.write('<form name=InvGenPayDonation
Here is a part of my html code (video urls marked with a django-template
For the most part, when I want to display some HTML code to be
I am using this code to send mail with php http://www.siteduzero.com/tutoriel-3-35146-e-mail-envoyer-un-e-mail-en-php.html#ss_part_4 . This code
Here is my code html> <head></head> <body> <?php $dir = 'folder/'; $files = scandir($dir);
Pls check code .html form gets submitted even if javascript returns false. <form id=form1

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.