SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Something Weird

  1. #1
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,939
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I got something weird happening and I can't explain it....

    Code:
    	print("adding CHAPTER: $book_array[1] ID: $id NUM: $num");
    	$sql = "INSERT INTO Table SET Field1='$content', Field2 = '$book_array[1]', Field3 = '$id', Field4= '$num'";      
    		if (mysql_query($sql)) {   
        		 echo("<P>Chapter Added</P>");      
    		}
    Okay

    Now that prints out this:

    adding CHAPTER: Chapter 58 ID: life_mississippi NUM: 59
    Chapter Added
    adding CHAPTER: Chapter 59 ID: life_mississippi NUM: 60
    Chapter Added
    etc
    Yet here is the weird part.

    Even though I verify immediately before the query what the contents of the variables are. When I access them from my database the chapter names are chopped off

    The first 10 have the chapter name of "Cha" the last 51 have the chapter name of "Chap"

    Now this just happened for this one book. I can't explain it at all.
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  2. #2
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,939
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I found the culprit - whitespace.

    the field looked like this:

    " Chapter 54"

    And so it got truncated.

    And since HTML compresses whitespace I didn't see it in my printout.

    ltrim to the rescue.
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums


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
  •