Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Apr 2007
    Thanked 0 Times in 0 Posts

    My friend recomended putting an escape_data function in this...

    So here is my register.php, and as you can guess, registered users for my site. My friend suggested I put this little bit of code saying it would take care of any input that was put in and it would take care of any problems with the characters input by the user such as backslashes, etc. Here is this code he said to include.

    function escape_data ($data) { 
    global $dbc //declares by mysql_connect global
    if (ini_get('magic_quotes_gpc')) { 
    $data = stripslashes($data); 
    return mysql_real_escape_string(trim($data), $dbc); 

    Now he said I would now be able to call escape_data anywhere throughout my website to fun the string through this function. Any input on this technique is greatly appreciated.
    I am on my way. :)

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Saskatoon, Saskatchewan
    Thanked 2,662 Times in 2,631 Posts
    Personally I disable the magic quotes and run my code normally through escaping techniques. The only real problem I see with it is that its only really portable for use with a mysql database, though the escaping is common for most databases (except like, access I guess :P). Otherwise, yeah, that will work.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #3
    New Coder
    Join Date
    May 2006
    Thanked 0 Times in 0 Posts
    Looks fine except mysql_real_escape_string() requires PHP4.3+.
    maybe check if mysql_real_escape_string() exists with function_exists('mysql_real_escape_string')..

    I have that check in my database class but not sure if it ever goes on a server with PHP4 < 4.3.. but just to be safe I do include it..
    Fiji Web Design - where i do Joomla Web Design
    Bucabay.com - My blog


    Posting Permissions

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