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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:28:46+00:00 2026-06-08T07:28:46+00:00

I am trying do multi-driver support for my Framework, which basically means I can

  • 0

I am trying do multi-driver support for my Framework, which basically means I can use MySQL, MySQLi or PDO(MySQL) with ease.

So, let’s say I have an array of values I want to insert.

array('Manuel', 'StackOverflow');

and I have this query..

mysql_query("INSERT INTO users(name, fav_site) VALUES(?, ?)");

So, I’d like to replace the question marks with those values in order, so Manuel goes first and then goes StackOverflow. Remembering that I need to add -> ‘ <- at the sides of these values so MySQL doesn’t throw an error.

I have tried searching if someone has asked this and had no luck.

Any help is appreciated!

NOTE: I know I shouldn’t even bother with MySQL, but hey! A feature is a feature.

  • 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-08T07:28:48+00:00Added an answer on June 8, 2026 at 7:28 am
    <?php
    $query = "INSERT INTO users(name, fav_site) VALUES(?, ?)";
    $args = array('joe', 'google goggles');
    while(strpos($query, '?') !== FALSE)
    {
      $query = preg_replace('/\?/', your_quoting_func(array_shift($args)), $query, 1);
    }
    echo $query;
    

    Basically, this says…while there is still a ? remaining in the string, delete the first question mark and replace it with a quoted (use your own function or mysql_real_escape_string and surround with single quotes) string, and shift that item off the array. You should probably substr_count the ? marks versus the number of arguments for error checking.

    I used preg_replace because it accepts an argument specifying how many values to replace, whereas str_replace does not.

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

Sidebar

Related Questions

I'm trying to use multi-touch in an Android 2.0 app. How can I simulate
I am currently trying to use the multi Get method proposed by Enyim C#
I am trying understand how multi queries work in mysqli. But I confess that
I am trying to do one multi map(4 variables) using boost- multi index. Can
I'm trying to make a multi-countdown on a page, which looks like : <table>
I'm trying to add multi-language support to an OpenSocial application. I see that I
Im trying to implement multi-language support in my system, the other systems at work
i'm trying to get multi tenancy working in my app - using nhibernate integration
I am trying to debug a multi-threaded Android app on a 2.3.6 device using
I am trying my hardest to learn Cross/Multi Threading, but I am very confused

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.