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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:46:52+00:00 2026-06-09T02:46:52+00:00

Now I have convert my query with PDO format. But I must implement the

  • 0

Now I have convert my query with PDO format. But I must implement the query with old format for little next time. The code is like this:

function mysql_Select($sql) {
    $data=array();
    $params=func_get_args();
    $s=PreparaSQL($sql, $params);
    $res = mysql_query($s);
    if ($res && mysql_num_rows($res)){
        while( $dt = mysql_fetch_object($res)){
            $data[]=$dt;
        }
        return $data;
    }
}

function PreparaSQL($sql, $array_param){
   unset($array_param[0]);
   foreach ($array_param as $k => $v){
      $array_param[$k]=mysql_real_escape_string($v);       }
  return vsprintf( str_replace("params","%s",$sql), $array_param );  
}

And execute the function is :

$data=mysql_Select('SELECT concat(id," | ",wh2) as label,Id as kode,wh2 as nama,wh2 as value FROM wh011 where wh2 like %s',$_GET['where']);
echo json_encode($data);
flush();

And output have error with null value. I think the trouble is in this code:

return vsprintf( str_replace("params","%s",$sql), $array_param ); 

I really don’t know where is the error point.
Thank’s for you answer.

  • 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-09T02:46:54+00:00Added an answer on June 9, 2026 at 2:46 am

    I think you have parameter 1 and 2 the wrong way around.

    Try:

    $sql = ” here is my string params did you find it?\n”;

    echo vsprintf(str_replace(“params”,”%s”,$sql), “BOO!”);

    Output

     here is my string BOO! did you find it?
    

    I’d suggest just not doing the str_replace… ?

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

Sidebar

Related Questions

Right now I have double numba = 5212.6312 String.Format({0:C}, Convert.ToInt32(numba) ) This will give
I have a function that convert ticks to time_t format long ticks = DateTime.Now.Ticks;
I have tif image in 16 bit format. Now I want to convert this
i need to convert this query to C# LINQ but i have no idea
I have a Android project for SDK1.5 and now I want to convert it
I have done a graphics project using OpenGL and now I want to convert
I have developed my app for tablet. Now I need to convert it to
I have taken char data into database into array. now i want to convert
I have a sample app using CoreData, and am now ready to convert my
I now have a file uploader that goes on like this This is the

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.