Page 1 of 1

echo() versus print() syntax

Posted: Sun Aug 03, 2008 5:04 am
by okelly
hello all

my articles database referred below has php code snippets which I want to retrieve using the mysql_query string and append to my code to complete.
Can somebody correct my incorrect echo command (or printf) on line8 below to achieve this.

thanks very much
Conor

Code: Select all

 
<?php
  require_once("../rss/rsslib.php");
   include ('../admin/config.php');
// fetch the code from articles table in articles db based on the ID
    $result = mysql_query("SELECT article.ArticleID, articles.snippet FROM articles WHERE ArticleID='2' ", $dblink);
//now add the retrieved code snippets to my php string to complete the php code
    echo $result,"snippet");
?>
        
 
 
 

Re: echo() versus print() syntax

Posted: Sun Aug 03, 2008 5:36 am
by jaoudestudios

Code: Select all

 
// should be...
echo $result['snippet']";
 
How were you able to code the rest and not that line?

Re: echo() versus print() syntax

Posted: Sun Aug 03, 2008 5:41 am
by Eran
Only without the trailing double-quotes, and with mysql_fetch_assoc:

Code: Select all

 
// should be...
$row = mysql_fetch_assoc($result);
echo $row['snippet'];
 

Re: echo() versus print() syntax

Posted: Sun Aug 03, 2008 5:42 am
by jaoudestudios
oops, cheers, dont know where they came from :(

Re: echo() versus print() syntax

Posted: Sun Aug 03, 2008 6:42 am
by okelly
thanks both. enjoy your Sunday morning!

jaoudestdio- to answer your question..I downloaded and ran it on an old Apache1, Php4 instance and am re-using the code for a new app. - this time on Apache2, Php5