SitePoint Sponsor

User Tag List

Results 1 to 1 of 1
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2001
    Location
    Belgium
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    addslashes ($xxx)

    Hi all,

    I cannot change php.ini on the server (I guess)
    It is a host (not one willing to do these things)

    When inserting a user with a ' in the name I get errors
    I tried like this:

    if ($submit):
    $sql = "INSERT INTO users SET " .
    "name='$name', " .
    "email='$email', " .
    "date=CURDATE()";

    $name = addslashes ($name);

    if (mysql_query($sql)) {
    echo("<p>New User added!</p>");
    }else{
    echo("<p>Error!</p>");
    echo mysql_error();
    }

    This is not working, I cannot insert a name like D'haese
    *************Edit***************************
    Seems I shouted to early:
    I tried to move the var addslashes above INSERT and it works:
    $name = addslashes ($name);
    $sql = "INSERT INTO users SET " .
    "name='$name', " .
    "email='$email', " .
    "date=CURDATE()";

    Bye Bye!
    Last edited by George Pauli; Jul 22, 2001 at 03:03.
    The only truth is that everything is a lie.


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
  •