[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now


need to close or escape the single quote in mysql

Posted on 2013-01-11
Medium Priority
Last Modified: 2013-01-11
     foreach($_POST['id'] as $id =>$v){
     //echo '<br>post foreach update';   
        $q = 'update '.$tablename.' set ';
        foreach ($cols as &$columnname) {
        $q = substr($q,'',-1);
        $q.=' where id='.$_POST['id'][$id].'';
        echo '<br>'.$q;
        mysql_query ($q); 

Open in new window

if the post contains

she said, 'this'

the query will not work
Question by:rgb192
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 84

Accepted Solution

Dave Baldwin earned 2000 total points
ID: 38769314
"mysql_real_escape_string" or the newer versions are used to 'escape' quotes and other problem characters before they are inserted into a MySQL database.

Author Closing Comment

ID: 38769475
this escaped '

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question