SitePoint Sponsor

User Tag List

Results 1 to 12 of 12

Thread: $_post

  1. #1
    SitePoint Zealot
    Join Date
    Dec 2008
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    $_post

    hi there

    On my local serve i was using mysql_real_escape_string($_POST['my_variable_name']) and now this doesn;t work on a public server. The $_POST['my_variable_name'] works.

    Which is the cause?
    I was supposing is from the magic_quates, and for that i've added this in the .htaccess file, but still doesn't work.

    php_flag magic_quotes_gpc off

    what to do?

  2. #2
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Location
    Nottingham, UK
    Posts
    3,133
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Does the function exist? Have you installed the mysql extension?

  3. #3
    SitePoint Zealot
    Join Date
    Dec 2008
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes...the mysql extension is enabled and works

    The script works without mysql_real_escape_string()

  4. #4
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Location
    Nottingham, UK
    Posts
    3,133
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    What error are you getting?

  5. #5
    SitePoint Zealot
    Join Date
    Dec 2008
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no errors

  6. #6
    SitePoint Guru
    Join Date
    Feb 2008
    Posts
    655
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try printing out the raw output from $_POST, then applying the function and then printing out the result.

  7. #7
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,496
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Then what does "doesn't work" mean? Could you explain the actual result of your script, and what it should do instead?

  8. #8
    SitePoint Zealot
    Join Date
    Dec 2008
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
        include_once('connections.php');

        @
    $name $_POST['name'];
        @
    $obs mysql_real_escape_string($_POST['obs']);


            
    $sqlInsert "INSERT INTO `test_table` (`user_name`, `obs`)
                                VALUES ('
    $name', '$obs'); ";
            
            
    print_r$sqlInsert) ;
            
            
    $sqlResul mysql_query($sqlInsert) or die(mysql_error()); 
    and the output is:
    HTML Code:
    INSERT INTO `test_table` (`user_name`, `obs`) VALUES ('testname', ''); 
    even the obs variable from the form is not empty.

    when i use:
    @$obs = $_POST['obs'];
    the script works as espected

  9. #9
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Location
    Nottingham, UK
    Posts
    3,133
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Well remove the @ for a start, you shouldn't use that. If you suppress errors, you aren't going to find out about potential problems.

    You might get an error output when you do that, which will help us further.

  10. #10
    SitePoint Zealot
    Join Date
    Dec 2008
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Stormrider View Post
    Well remove the @ for a start, you shouldn't use that. If you suppress errors, you aren't going to find out about potential problems.

    You might get an error output when you do that, which will help us further.
    many thx

    that was....the connection to mysql wasn't good

  11. #11
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Location
    Nottingham, UK
    Posts
    3,133
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    A perfect example of why you should never suppress errors with @

  12. #12
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,496
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by Stormrider View Post
    A perfect example of why you should never suppress errors with @
    Yes. Errors must be resolved, or managed. Never suppressed (never say never?! ).


Bookmarks

Posting Permissions

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