SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Zealot vodica's Avatar
    Join Date
    Jul 2001
    Location
    SLovenia
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Mysql Help! Please!!!!!!!!!

    Please somebody help!
    I cannot insert anything into my database that include ' char. Does anyone know why?

    How can I repair this?

    I am using MySQL and PHP for doing this!?

    PLEasE HELP!!!

    I am really geting sick from this!
    while(true) sheep++;

  2. #2
    SitePoint Zealot vodica's Avatar
    Join Date
    Jul 2001
    Location
    SLovenia
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    My code!

    Ups, forgot to write what code i have been using!

    Code:
    <?php
    
    $sql = "INSERT INTO book SET " .
    "NAME='$name', " .
    "AUTHOR='$author', ".
    "ISBN='$isbn', ".
    "STARS='$stars', ".
    "DESCRIPTION='$desc', ".
    "PRICE='$price', ".
    "CATEGORY='$name2', ".
    "URL='$link', ".
    "IMAGEs='$images', ".
    "IMAGEl='$imagel'";
    if (mysql_query($sql)) {
    echo("<P><b>Vnos je bil uspešno dodan!.</b></P>");
    } else {
    echo("<P><b>Vnosa ni bilo mogoče oddati, MySQL pravi: " .
    mysql_error() . "</b></P>");
    }
    ?>
    while(true) sheep++;

  3. #3
    SitePoint Enthusiast Stallion's Avatar
    Join Date
    Jan 2001
    Location
    Cumberland, RI, US
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <?php

    $sql = "INSERT INTO book SET " .
    "NAME='".addslashes($name)."', " .
    "AUTHOR='".addslashes($author)."', ".
    "ISBN='".addslashes($isbn)."', ".
    "STARS='".addslashes($stars)."', ".
    "DESCRIPTION='".addslashes($desc)."', ".
    "PRICE='".addslashes($price)."', ".
    "CATEGORY='".addslashes($name2)."', ".
    "URL='".addslashes($link)."', ".
    "IMAGEs='".addslashes($images)."', ".
    "IMAGEl='".addslashes($imagel)."'";
    if (mysql_query($sql)) {
    echo("<P><b>Vnos je bil uspešno dodan!.</b></P>");
    } else {
    echo("<P><b>Vnosa ni bilo mogoče oddati, MySQL pravi: " .
    mysql_error() . "</b></P>");
    }
    ?>

  4. #4
    SitePoint Zealot vodica's Avatar
    Join Date
    Jul 2001
    Location
    SLovenia
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    thank you!

    THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU


    P.S.: Do you know why MySQL did this?
    while(true) sheep++;

  5. #5
    SitePoint Enthusiast Stallion's Avatar
    Join Date
    Jan 2001
    Location
    Cumberland, RI, US
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hehe...

    The reason behind it is that MySQL needs to know when the data for each column is seperated, and you're using quotes to do that. However, when you have quotes in the data, MySQL thinks that the column has ended, when in fact its just data inside the column that shares the same value as the terminating entity. Or something.

  6. #6
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, this is probably the first time I have posted something in the eCommerce forum.

    When you retrieve the data from the database, you will want to use stripslashes() to reverse the process and get your data back to how it was (without the escape chars)

    http://php.net/manual/en/function.stripslashes.php

  7. #7
    SitePoint Enthusiast Stallion's Avatar
    Join Date
    Jan 2001
    Location
    Cumberland, RI, US
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The default configuration on 99% of servers doesn't require you to stripslashes() from data being extracted from a database.
    PHP Code:
    magic_quotes_gpc    =    On        magic quotes for incoming GET/POST/Cookie data
    magic_quotes_runtime
    =    Off        magic quotes for runtime-generated datae.gdata from SQLfrom exec(), etc
    These are the default settings in php.ini, meaning that slashes are only added for data pushed from the user's end.

  8. #8
    SitePoint Zealot vodica's Avatar
    Join Date
    Jul 2001
    Location
    SLovenia
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Me again :)

    Cool! Thank you!

    But now...
    I am still having some trouble!

    you are saying that I have to get the data with the stripslashes right?

    Do I use it like .stripslashes($data) or not?

    And also, If I don't use it to call data then my delete script doesn't work? It works fine when there are numbers but one letter and nothing?

    Is it becouse I didn't use stripslashes?

    thank you again
    while(true) sheep++;


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
  •