SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast gullsinn's Avatar
    Join Date
    Apr 2009
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    php addslas function help needed

    PHP Code:
    <?php
    $lines 
    file('file.txt');
    foreach(
    $lines as $num => $line){
    $fullname "name";
    $email=addslashes($line);
    $password base64_encode(password);
    mysql_query("INSERT INTO table (fullname,email,password) VALUES('$fullname','$email','$password')") or die("Insert failed: " mysql_error());
    }
    ?>
    please see the above code i want to add addslashes for $email but this is not doing in the way i mentioned above where i mistaken

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,501
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    don't use addslashes() when you need the result for a query, use mysql_real_escape_string().

  3. #3
    SitePoint Enthusiast gullsinn's Avatar
    Join Date
    Apr 2009
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by guido2004 View Post
    don't use addslashes() when you need the result for a query, use mysql_real_escape_string().
    thanks but i am not verymuch expert please can you fix how mysql_real_escape_string() will go with my script thanks again
    Code:
    $email=mysql_real_escape_string($line);
    will be fine ?

  4. #4
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,501
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    yes, try that

  5. #5
    SitePoint Enthusiast gullsinn's Avatar
    Join Date
    Apr 2009
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by guido2004 View Post
    yes, try that
    nothing happened

  6. #6
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,087
    Mentioned
    153 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by gullsinn View Post
    nothing happened
    How do you mean "nothing happened"? What was supposed to happen?
    Rémon - Hosting Advisor

    SitePoint forums will switch to Discourse soon! Make sure you're ready for it!

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy


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
  •