jdubs Posted November 26, 2007 Share Posted November 26, 2007 Hello, I'm a bit of a php noob and I'm writing a script that accepts large chunks of notes and then displays them. I'm seeing some rather weird results after I've inserted the test data into phpmyadmin, and then displaying it via my script. It appears that the when I get the data from my select, ("SELECT * FROM notes where note_id = " . $note_id) It spits it out with out any carriage returns. This is quite annoying as I'm selecting 50-60 lines of data from the blob and then displays the data with out any carriage returns. And I'm curious on how I can keep the carriage returns in the data when I retrieve it. I'm not sure whats going on, as there are several different variables interacting with each other. First of all, I'm not sure if phpmyadmin is stripping out the carriage returns, when I insert the data into a file, then upload it via phpmyadmin or if my php code is not adaquet to display the carriage returns. I've also been wondering if I should be using a different table type to store the data, from what I've heard searching through blobs is expensive. :\ I hope this doesn't sound confusing but I have no idea of whats going on. http://xomar.com/haxor/getnote.php?note_id=4 don't laugh, my little script barely works. Should I even be using blobs for 1-2k worth of data? Thanks Quote Link to comment Share on other sites More sharing options...
subcool Posted November 26, 2007 Share Posted November 26, 2007 for text use any of these, depending on what you need: TINYTEXT: A character large object column with a maximum length of 255 (2^8 - 1) characters. TEXT: A character large object column with a maximum length of 65535 (2^16 - 1) characters. MEDIUMTEXT: A character large object column with a maximum length of 16777215 (2^24 - 1) characters. LONGTEXT: A character large object column with a maximum length of 4294967295 (2^32 - 1) characters. Quote Link to comment Share on other sites More sharing options...
jdubs Posted November 26, 2007 Author Share Posted November 26, 2007 I've changed the type of row that holds the information, and when I view the data via phpmyadmin, it displays with the proper carrige returns and everything. But when I view it via my php script its still missing the carriage returns... I've run the select via phpmyadmin and it also displays the correct spacing and what not. So, at this point I'm not sure how to fix my code. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted November 26, 2007 Share Posted November 26, 2007 Browsers don't display \r\n CRLF (those characters just format the source code.) To get a browser to display a newline use the php nl2br() function on the data before you output it (phpmyadmin probably does this internally) - http://php.net/nl2br Quote Link to comment Share on other sites More sharing options...
jdubs Posted November 26, 2007 Author Share Posted November 26, 2007 Sweet, This was exactly what I was looking for. Thanks so much! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.