Results 1 to 2 of 2

Thread: SQL insert into with mysql_real_escape_string

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2006
    Posts
    366

    SQL insert into with mysql_real_escape_string

    I am trying to insert variables into a database, some of which potentially could hold apostrophes.
    I know about mysql_real_escape_string so I generate this sql statement:
    Code:
    $sql = ("INSERT INTO $fcbk_id (PredictedAt, HomeTeam, AwayTeam, HomePrediction, AwayPrediction, GameKey)
    VALUES ('".mysql_real_escape_string($date_now)."', '".mysql_real_escape_string($HomeTeam)."', 
    '".mysql_real_escape_string($AwayTeam)."', '".mysql_real_escape_string($HomeScore)."', 
    '".mysql_real_escape_string($AwayScore)."', '".mysql_real_escape_string($GameKey)."')");
    It dont get any errors, even with this:
    Code:
    if (!mysql_query($sql))
         {
           // SQL failed, print error message and abort
           print mysql_error();exit();
         }
    however it still doesnt insert anything after an apostrophe in the fields. I am running this from my localhost. I.e Nottingham is sometimes shortened to Nott'ham, but all that would be entered to the database is Nott

    Any ideas why?

  2. #2
    Addicted Member
    Join Date
    Feb 2010
    Location
    Damascus - Syria
    Posts
    145

    Re: SQL insert into with mysql_real_escape_string

    hi

    check the php.ini file, you may had disabled the "display_error" or something similar

    good luck,
    Feras Jobeir
    Last edited by fjober; Jan 28th, 2012 at 04:10 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width