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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:45:51+00:00 2026-06-06T11:45:51+00:00

I have been trying for several days to get the proper formatting for what

  • 0

I have been trying for several days to get the proper formatting for what I wish to execute.

The goal is to insert rows into a MYSQL table which is previously created. The table may be a mix of strings and integers, and as we know MYSQL requires quotes around strings for insertion while it does not for integers. So then, the proper way to insert something into a table of an integer and two strings would be:

insert into table values(number, "string", "string");

I wish the values to be php variables. However when I input the variables, the code will no longer produce the result when I check in MYSQL. The table will be created, but it will be empty. So it must be this statement that does not work.

This is my actual code for the function to insert it:

function insertRow($db, $new_table, $ID, $Partner, $Merchant)

    $insert = "INSERT INTO ".$new_table. " VALUES (1,'Partner','Merchant')";

    $q = mysqli_query($db, $insert);

It works like this, but fills the entire table with 1, partner and merchant for every row as many times as I choose.

I’ve also tried several variations like this

function insertRow($db, $new_table, $ID, $Partner, $Merchant)

    $insert = "INSERT INTO ".$new_table. " VALUES(" .$ID. "," ."'$Partner'". ","."'$Merchant'".")";

    $q = mysqli_query($db, $insert);

I’ve also tried these:

Passing PHP variables into MySQL

but none have worked to actually insert the tables into the rows.

Does anyone have an alternative way of doing this?

  • 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-06T11:45:53+00:00Added an answer on June 6, 2026 at 11:45 am

    You need to start your debugging very simply, and work from there. The first guess I would have is that you’re not setting your parameter values properly that are passed into the function.

    Try this:

    function insertRow($db, $new_table, $ID, $Partner, $Merchant) {
      $ID=1;
      $Partner = 'Partner';
      $Merchant = 'Merchant';
      $insert = "INSERT INTO $new_table " .
        " VALUES($ID,'$Partner','$Merchant')";
      $q = mysqli_query($db, $insert);
      if (!$q) die(mysqli_error($db));
    }
    

    Does that work? If so, then the problem is that your parameter values are not being properly set.

    Note that I’ve also added some error reporting in there 😉

    Note, though, that it’s not a good idea to create your SQL like this. It is wide open to SQL injection. Much better to look into using Prepared Statements:

      $prep = mysqli_prepare($db, "insert into " . $new_table . " values (?,?,?)");
      $prep->bind_param("iss", $ID, $Partner, $Merchant);
      $prep->execute();
    

    See the PHP documentation on mysqli_prepare for more details.

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

Sidebar

Related Questions

I have been trying to get QLabel.setText in PySide working for several days, but
I have been trying for several hours now to get sorl-thumbnail working, but it
I have been struggling for days trying to get a simple ActiveX DLL to
I have been trying several regular expressions in the substitution operator: $str =~ s/^0+(.)/$1/;
I have been trying to figure out a way to tag several methods from
I have been trying all afternoon to get the jQuery Sifr Plugin ( http://jquery.thewikies.com/sifr/
I have been trying since yesterday to get google like paging, but each time
I have been trying to set up OpenCV for the past few days with
I've been tearing my hair out for several days now trying to figure out
I've been trying for several days to: set the value of the variable w

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.