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

  • Home
  • SEARCH
  • 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 8786983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:46:15+00:00 2026-06-13T21:46:15+00:00

Possible Duplicate: apostrophes are breaking my mysql query in PHP My Android App is

  • 0

Possible Duplicate:
apostrophes are breaking my mysql query in PHP

My Android App is sending a message to my server (PHP script)
The PHP script is writing the message into MySQL.

It works fine, but all messages containing an apostrophe ‘ (e.g. he’s going to school) are not written into the database.

Here the php script:

function deq($s)
{
    if($s == null)
        return null;
    return
        get_magic_quotes_gpc() ?
        stripslashes($s) : $s;
}

  if(md5(deq($_REQUEST['blub']).deq($_REQUEST['blub'])."blabla") == $_REQUEST['hash']){
    mysql_connect("localhost", "blub", "blub") or die(mysql_error());
    mysql_select_db("blub") or die(mysql_error());

   // mysql_set_charset('UTF8');  // does not work as too old php
   mysql_query("SET NAMES 'utf8'");
mysql_query("SET CHARACTER SET utf8");
mysql_query("SET COLLATION_CONNECTION = 'utf8_unicode_ci'");

    $mysqldate = gmdate( 'Y-m-d H:i:s');

    $language = (int) $_REQUEST['language'];

    $device = $_REQUEST['device'];

    $ipaddress = $_SERVER['REMOTE_ADDR'];


    mysql_query("INSERT INTO test(username, text, language, rating, checked, date)
    VALUES('".$_REQUEST['username']."', '".$_REQUEST['text']."', '".$language."', '0' , 'false', '".$mysqldate."') ")
    or die(mysql_error());

    mysql_close();
  • 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-13T21:46:16+00:00Added an answer on June 13, 2026 at 9:46 pm

    All you need to escape ' like below

    $_REQUEST['text'] = mysql_real_escape_string($_REQUEST['text']);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: apostrophes are breaking my mysql query in PHP I asked a friend
Possible Duplicate: How to successfully rewrite old mysql-php code with deprecated mysql_* functions? I
Possible Duplicate: regex for URL including query string I have a text or message.
Possible Duplicate: Convert numeral date(03-11-1991) into arabic no(۱۹۹۱/۱۱/۰۳) php This is my client's requirement.
Possible Duplicate: How do I make a request using HTTP basic authentication with PHP
Possible Duplicate: How can I understand nested ?: operators in PHP? Why does this:
Possible Duplicate: How to convert text to unicode code point like \u0054\u0068\u0069\u0073 using php?
Possible Duplicate: Turning on camera flash LED in Android? I need to turn on
Possible Duplicate: Can a Bash script tell what directory it's stored in? Is there
Possible Duplicate: What is the fastest XML parser in PHP? I still need to

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.