Web Analytics Made Easy -
StatCounter Insert string problem - CodingForum

Announcement

Collapse
No announcement yet.

Insert string problem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Insert string problem

    Ok this is probably a very easy fix for this, but I cant find it and iv tried loads of different combinations of things.

    The problem is with this insert line

    Code:
    VALUES (".$board_config['delete_post_forum'].", '".sprintf($lang['Deleted_post_from_topic'], $topic_test)."', ".$post_data['poster_id'].", ".time().", 0, 0, ".TOPIC_UNLOCKED.", 0, ".POST_NORMAL.", $post_id, $post_id, 0, '$userna')";
    $topic_test contains a post title for instance "Hi im new" which works fine, but if that title contains a ' for instance "You're day today" then it messes up the string and i get an error when it tries to insert in the database, any ideas?

    im assuming i have to encapsulate $topic_test in some form of quote combination?

  • #2
    take a look at the mysql_real_escape_string function
    My thoughts on some things: http://codemeetsmusic.com
    And my scrapbook of cool things: http://gjones.tumblr.com

    Comment


    • #3
      hi thanks for the advice im not really much good at looking at theory behind things i tend to find examples to be more worthwhile, any tips on its usage?

      Comment


      • #4
        hi, no worres iv sorted it, thanks very much for your help, used addslahses in the end

        Comment


        • #5
          It is more safe to use mysql_real_escape_string function. It also take into account the current charset of the connection. So it is more safe.

          Comment

          Working...
          X