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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:18:40+00:00 2026-06-07T18:18:40+00:00

i have use function for inserting data to my sql. the data is function

  • 0

i have use function for inserting data to my sql.
the data is

function mysql_insert($table, $arr){
if($arr!=''){
    $values = array_map('mysql_real_escape_string', array_values($arr));
    $keys = array_keys($arr);
    $q=('INSERT INTO `'.$table.'` (`'.implode('`,`', $keys).'`) VALUES (\''.implode('\',\'', $values).'\')');
    //$res = mysql_query($q)OR die(mysql_error());
    return $q;
}else{
    return false;
}

data and query is came from :

if($crud=='insert'){
$field= array(  'col1' => 'apel',
        'c0l2' => 'box1',
        'col3' => 200,//integer Quantity
    );
$data=mysql_insert('wh',$field);}echo json_encode($data);

and result is
= “INSERT INTO wh (col1,c0l2,col3) VALUES (‘apel’,’box1′,’200′)”
that col3 have value as string. i need that col3 as integer.
what wrong with this code?

  • 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-07T18:18:43+00:00Added an answer on June 7, 2026 at 6:18 pm

    This is happening because the command implode('\',\'', $values) is telling it to turn the array $values into a string, with single quotes and commas between each element. If you want to not put quotes around numbers, you’ll need to iterate over $values with a more specific function.

    However, it doesn’t actually matter. If you give MySQL a string containing a number for a numeric field, it will just convert it to a number of the appropriate type. You can leave it as-is and everything should work.

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

Sidebar

Related Questions

I'm having trouble inserting data into my table. I have a list of stocks
i have to use the following function, to change the input's type <input class=input
I have use semantic-analyze-proto-impl-toggle to switch between the function's proto and impl, but when
I have question regarding the use of function parameters. In the past I have
i want to use .animate function but i have some problems i want to
I have installed Matlab r2010a on my computer I need use the function xlsread
I have a MFC dialog based application in which I use ::system() function to
I have nested iframes and I would like to use onload function for the
I have got two pages. example.com/php.com and example.com. I use this function to set
I have a function that use setInterval() method to watch css propertie change('cause in

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.