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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:43:29+00:00 2026-05-19T09:43:29+00:00

i apologize if the question is wrong. i am a still a newbie and

  • 0

i apologize if the question is wrong. i am a still a newbie and a learner however i would appreciate if someone correct me if i am somewhere wrong.

here in the Class method i am using for Inserting the data into the database

public function insert($table,$col,$value)
{
    if(is_array($col) && is_array($value))
    {
        $query = "INSERT INTO ".$table."(" . implode(",",$col) . ") VALUES(" . implode(",",$value) . ")";
    }
    else
    {
        $query = "INSERT INTO " . $table . "(" . $col . ") VALUES(". $value . ")";
    }
}

now here i am determining if the $col and $value is an array if yes then process it.

however i have a problem here since the VALUES in the Insert statement needs to be represnted in the single or double quote format it will not process the query and hence print the error

for example the below code would print the error

$query = "INSERT INTO users(username,email) VALUES(test,test@test.com)";

and the correct format will be

$query = "INSERT INTO users(username,email) VALUES('test','test@test.com')";

now in the col value i would like to add the single quotes to every value in the array for example the $value array which is like this.

$value = array(‘test’,’test@test.com’);

should give back the value

‘test’,’test@test.com’

instead of

test,test@test.com

how do i achieve 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-05-19T09:43:30+00:00Added an answer on May 19, 2026 at 9:43 am
     $query = "INSERT INTO $table ('" . implode("','",$col) . "')
               VALUES ('" . implode("','",$value) . "')";
    

    Make sure that neither $col nor $value is empty.

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

Sidebar

Related Questions

I might be asking the wrong question here, so I apologize if the answer
I do apologize if the answer to my question would be very obvious. I
(I apologize that previous versions of this question displayed the wrong function that I
First of all I would like to apologize for the question itself. I simply
I apologize if the question is trivial, but some googling is not leading me
first of all I apologize if my question is difficult to understand. I'm having
I'm new to web development, so I apologize if this question is noobish. I
I apologize for the novice question but I'm trying to get oriented with OpenJDK.
I apologize for the subjectiveness of this question, but I am a little stuck
I apologize in advance if this question seems confused. The behaviour I am seeing

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.