K, Here is an example of the script I am running. The MySQL field LongStory is a BLOB. Basicly what I want to do is check to see if any info was input into LongStory, if LongStory is empty, then do not show a link, if LongStory hold info (such as letters) then show a link

$sql = mysql_query("SELECT * FROM news");
while ($row = mysql_fetch_array($sql)) {
 if ($row['LongStory']) {
  //Create a link if longstory has value
 }
 echo $row['ShortStory'];
}

If there is a way to check this let me know please. I tried a == null, I tried == ''. But I cannot get this to work at all. THanks for any help.

    Probably easier and quicker to change your sql - so it only returns rows where the BLOB is not NULL.

    i.e.

    SELECT *
    FROM news
    WHERE LongStory IS NOT NULL

    ===

    Also its inefficient to use SELECT * - you should only reference each field you need to return.

      thanks for that responce however I still need to get the rows where longstory is null. What I am trying to do is a new system where I show the title and the shortstory, and if there is a long story I want to show a link to ReadMore.

        Maybe

        if (strlen($row['LongStory']))

        would to the trick?

        This however, would work optimally if you stripped all the whitespace either before the insert into table (recommended) or before the strlen() evaluation.

          Ok cool,

          if ($row['LongStory']){}

          Should always return true as the array key exists, it should have a NULL value.

          So does this work:

          if (!is_null($row['LongStory'])){}

          That should do it as long as the datatype of $row['LongStory'] is explictly NULL.

            thanks for all that input guys, I will try it when I get home tonight

              Write a Reply...