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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:49:30+00:00 2026-06-17T12:49:30+00:00

I am trying to insert data into the database but I am recieving this

  • 0

I am trying to insert data into the database but I am recieving this error in my bind_param():

Fatal error: Only variables can be passed by reference in ... on line 48 

I have been searching on the net but I don’t quite understand what this error means as out of al the inserts I have done this is first time I have recieved this error.

What is the problem which is causing this error?

Below is the insert code:

 $answersql = "INSERT INTO Penalty_Marks (PenaltyAnswer, PenaltyMarks, QuestionId) 
    VALUES (?, ?, ?)";

if (!$insertanswer = $mysqli->prepare($answersql)) {
    // Handle errors with prepare operation here
}

   $c = count($_POST['incorrect']);

    for($i = 0;  $i < $c; $i++ )
    {


$insertanswer->bind_param('iii', $_POST['incorrect'][$i], $_POST['answerMarks'][$i], $_POST['numQuestion'][$i]);

Below is the form where it retrieves the details (this form below has been cut down for easier viewing):

<form id="PenaltyMarks" action="insertpenaltymarks.php" method="post">

    <table id='penaltytbl'>
    <?php

    foreach($ques_ans as $questionId => $inc_ans)
    {
        $q_row_span = count($inc_ans);
        $row_count = 0;
        $inc_ans = array_values($inc_ans);

    ?>

    <tr class="questiontd">
    <td>
    <input type="hidden" name="numQuestion" value="<?php echo$questionId?>" />
    </td>

    <td>
    <input type="hidden" class="hiddenincorrect" name="incorrect[]" value="<?php echo$inc_ans[$row_count];?>">
    </td>

    <td>
    <input  name="answerMarks[]" type="text" data-type="qmark" value='0'  />
    </td>

    </tr>
        <?php
            //remaining incorrect answers in separate row (if any) follows here
        if($row_count < $q_row_span - 1) 
        {
            for($i=($row_count + 1); $i<$q_row_span; $i++) { ?>     
                <tr>
                <td>
                <input type="hidden" class="hiddenincorrect" name="incorrect[]" value="<?php echo$inc_ans[$i];?>">
                </td>

                <td class="answermarkstd">
                <input  name="answerMarks[]" type="text" data-type="qmark" value='0'  />            
                </td>
                </tr>
        <?php
            }
        }
    }

    ?>
    </table>

    </form>
  • 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-17T12:49:31+00:00Added an answer on June 17, 2026 at 12:49 pm

    The problem is that parameters to bindParam actually have to be variables, not strings or arrays. This code should work:

    $incorrect = $_POST['incorrect'][$i];
    $answerMarks = $_POST['answerMarks'][$i];
    $numQuestion = $_POST['numQuestion'][$i];
    $insertanswer->bind_param('iii', $incorrect, $answerMarks, $numQuestion);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to insert some data into mysql database, but I get an error
I am trying to insert some data into a pysqlite database but even tho
I'm trying to insert data into the SQLite database using get EditText, but I
Getting a strange error when trying to insert data into an Access database using
I am trying to insert data from a database into a textarea. I can't
I'm trying to insert data into a database when there is no network, but
I'm trying to insert data into my SQlite3 database (this works via the command
I'm trying to insert non-latin data into sqlite database using bind variables using System.Data.SQLite.
I'm trying to insert some data into my SQLite database. But I keeo receiving
I am trying to insert data into a database but I have it seems

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.