
Untitled
By: a guest on
Aug 12th, 2012 | syntax:
None | size: 0.61 KB | hits: 9 | expires: Never
how to construct a mysql query that puts quotes around strings but not numbers?
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;
}
if($crud=='insert'){
$field= array( 'col1' => 'apel',
'c0l2' => 'box1',
'col3' => 200,//integer Quantity
);
$data=mysql_insert('wh',$field);}echo json_encode($data);