Using a Left() result in PHP

From: Date: Mon, 11 Feb 2002 10:21:52 +0000
Subject: Using a Left() result in PHP
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-16781@lists.php.net to get a copy of this message
Hi there I'm just scraping the surface of MySQL and PHP and there's something I can't work out. I want to get the first 64 characters from a database row result and display only those 64 characters using PHP. The snipped code is here - I've deleted all the error trapping and comments: $result = @mysql_query("select ID, Writer, left(text,64) from Reports where writer like '%kim%';"); while ($row = mysql_fetch_array($result)) { $ID=$row["ID"]; $Writer=$row["Writer"]; $text= $row["Text"]; echo ("<p>" . $ID . " " . $Writer . " " . $Text . "</p>"); This returns a blank result for Text. If I remove the left() from the SQL it works but displays the entire report - hundreds of words. How can I display only those first 64 characters - am I missing something obvious? Many thanks, kim

« previous php.db (#16781) next »