#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    14
    Rep Power
    0
    Hi, I'm working on a weather web site and using php/mysql to enter city forecasts into a table.

    Everything is fine except my comment line.
    For some reason it only enters the first word I type in for the comment line.
    The line looks something like this:

    INSERT INTO one (cityname, day1, max1, min1, sky1, comments) VALUES ('boston', 'Saturday', '32', '23', 'sun.gif',
    'this')

    where comments is TEXT, I also tried varchar, char. (I use a <textarea> to enter the comment line)

    for the comment line above I had typed "this is a comment line", but only the "this" part of it shows up?

    Make sense???

    Thanks

    Mike
  2. #2
  3. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,642
    Rep Power
    4476
    What does your actual php line look like where you are trying to do this insert? or are you trying to do this from the command line?

    something like this should work:

    $query = msyql_query("insert into one (cityname,day1,max1,min1,sky1,comments) values ('$cityname','$day','$max','$min','$sky','$comment')");

    is that what you are trying to do? did you remember the quotes around your variables?? if this isn't it or it's still not working, let us know...
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    14
    Rep Power
    0
    The php part works just fine, but for some reason when I view what is in the table (I telnet into my account and do a show table, then describe "tablename")+ I have a web page set to extract the data from the table.

    All of the data is fine but the comment line only shows the first word of my comment line, so if I type "this is a comment line", I only see the "this" part of the line in the table?

    Does that help?
    What data type should I be using? TEXT, BLOB, VARCHAR???

    Thanks
  6. #4
  7. No Profile Picture
    ads
    Guest
    Devshed Newbie (0 - 499 posts)
    Use functions urlencode for comments before inserting into database table and urldecode after extracting from databse. I think this will solve your problem.
  8. #5
  9. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15

    Use functions urlencode for comments before inserting into database table and urldecode after extracting from databse. I think this will solve your problem.

    Yea,That will solve your problem....This is a frequently asking question in this forum.

    before inserting to the table use urlencode() function..

    <?
    $comment=urlencode($comment);
    ///then insert this..
    ?>
    ------------------

    When you retreive value from the database..
    Use urldecode() function and stripslashes() also..


    ---

    <?
    $comment=urldecode($comment);
    //decode it
    $comment=stripslashes($comment);
    // remove slashes

    echo $comment;
    ?>

    Good Luck!!



    ------------------
    SR -
    webshiju.com

    "The fear of the LORD is the beginning of knowledge..."

Similar Threads

  1. PLEASE help!! - Compare a db field with a string
    By nyc7887 in forum ASP Programming
    Replies: 0
    Last Post: February 11th, 2004, 11:34 PM
  2. Codepupil
    By Adachic in forum C Programming
    Replies: 3
    Last Post: February 6th, 2004, 06:50 PM
  3. array explode ( string separator, string string [, int limit])
    By beemee_freeserv in forum HTML Programming
    Replies: 4
    Last Post: February 5th, 2004, 10:56 AM
  4. line break in field string
    By badjo in forum HTML Programming
    Replies: 1
    Last Post: February 4th, 2004, 01:57 AM
  5. Replies: 3
    Last Post: January 31st, 2004, 12:16 AM

IMN logo majestic logo threadwatch logo seochat tools logo