total noob Posted January 26, 2012 Share Posted January 26, 2012 Hello all I've been using implode function of php and suddenly i encounter a problem regarding it.. <?php $insertValues[] = "(default,'{$y}', '{$p}', '{$o}', '{$i}', '{$u}','AMM-40','test')"; $query_status = "INSERT INTO `mobile1_mn1`.`logs_inbound` (`log_id`, `originator`, `sender`, `date`, `time`, `message`, `company_id`, `keyword`) VALUES". implode(',',$insertValues); ?> When the information on $y,$p,$o,$i and $u does not have any single 'quotations' and commas it can save my information on database but when i have a string say for example the string is "he's good" and "Im, good" having a comma and quote it can't save my information anymore... can someone tell me why i have this problem? thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/255813-problem-with-implode-function/ Share on other sites More sharing options...
phpSensei Posted January 26, 2012 Share Posted January 26, 2012 You have to properly escape the string, use mysql_real_escape_string Quote Link to comment https://forums.phpfreaks.com/topic/255813-problem-with-implode-function/#findComment-1311360 Share on other sites More sharing options...
total noob Posted January 26, 2012 Author Share Posted January 26, 2012 Hello sir Im not very familiar with using mysql_real_escape_string can you give me an example on how can i implement it on my code? thanks Quote Link to comment https://forums.phpfreaks.com/topic/255813-problem-with-implode-function/#findComment-1311374 Share on other sites More sharing options...
ManiacDan Posted January 26, 2012 Share Posted January 26, 2012 As much as I hate the phrase RTFM, go do it. Quote Link to comment https://forums.phpfreaks.com/topic/255813-problem-with-implode-function/#findComment-1311391 Share on other sites More sharing options...
total noob Posted January 26, 2012 Author Share Posted January 26, 2012 So sorry for giving a nonsense reply.. Thanks for the info my problem is somehow fix.. Quote Link to comment https://forums.phpfreaks.com/topic/255813-problem-with-implode-function/#findComment-1311398 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.