homepage Welcome to WebmasterWorld Guest from 54.205.241.107
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
How To Get Dollar Amounts to show in Posts
Dollar amounts show as ("") or (".00")
Senmar50

10+ Year Member



 
Msg#: 3052419 posted 3:48 am on Aug 19, 2006 (gmt 0)

Hi,

This is my "Articles Manager" php script. It works very well.
The problem is when visitors write posts with dollar amounts
($200.00), included, these amounts do not show up in the post.
They show up as "" or ".00" How do I correct this? I heard that you should use an escape backslash in front of the dollar amounts. Is there a line I can add to this script to correct this problem? Any help will be appreciated.

Thanks,
SenMar

<?
$summary_template = "t_summary.html";
$article_template = "t_article.html";
$max_summary = 5;

function summary_page ($subject, $date, $summary, $article_id)
{
global $summary_template;
$t = new Template();
$t->set_file("SummaryPage", $summary_template);
$article_url = "article_".$article_id.".html";
$date = nl2br($date);
$summary = nl2br($summary);
$t->set_var( array(
"subject" => $subject,
"date" => $date,
"summary" => $summary,
"article_url" => $article_url
));
$t->parse("Summary", "SummaryPage");
return $t->get_var("Summary");
}

function main_page ($subject, $date, $summary, $article_id, $body)
{
global $article_template;

$t = new Template();
$t->set_file("ArticlePage", $article_template);
$article_url = "article_".$article_id.".html";
$date = nl2br($date);
$summary = nl2br($summary);
$body = nl2br($body);
$t->set_var( array(
"subject" => $subject,
"date" => $date,
"summary" => $summary,
"body" => $body,
"article_url" => $article_url
));
$t->parse("Article", "ArticlePage");
return $t->get_var("Article");
}

function add_article($filename, $news)
{

if(file_exists($filename)){
$fh = fopen($filename, "r");
$old_news = fread($fh, filesize($filename));
fclose($fh);
}

/* TODO: Multipage articles
preg_match_all("<!--ARTICLE PAGE=(\d*)-->", $old_news, $matches;

if( count($matches[0]) >= $max_summary){
$oldfilename = $filename.($matches[0][0]+1);
}
*/

$fh = fopen($filename, "w");
$news = stripslashes($news);
fwrite($fh, "\n<!--ARTICLE-->\n$news $old_news");
fclose($fh);
}
?>

 

Senmar50

10+ Year Member



 
Msg#: 3052419 posted 12:09 am on Aug 21, 2006 (gmt 0)

I think I've solved the problem! I've asked members to
place an escapeslash in front of their dollar amount.

Ex: \$ 235.00

It worked for me.

SeMar

smatts9

5+ Year Member



 
Msg#: 3052419 posted 2:01 am on Aug 21, 2006 (gmt 0)

use this:

[php]
$stuff=addslahes($stuff);
[/php]

instead of asking members to do that.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved