Here's a simple challange...
Create an HTML file in which you have the following text:
#total#
Now save that as template.html.
Now, create a simple script that:
1) opens template.html and saves it as a string to a variable, ala:
$template = join('', file("./template.html"));
2) query a database (doesn't matter what; just as long as there are rows returned)
3) get the num of rows using mysql_num_rows() and save that to a variable (let's say $total_rows),
$total_rows = mysql_num_rows($result);
3) do ereg_replace on "#total#" in your $template with $total_rows.
$template = ereg_replace ('#total#', $total_rows, $template);
4) Now display that to the browser
echo($template);
Now, if I'm correct (as this is what is happening to me), you won't see the number of rows but rather an ASCII element.
I've tried different token wrappers like '$' and '%' but they all produce the same result: no number. If you echo($total_rows); this displays the correct value or rows returned. It's almost as if the number that is replaced becomes part of a ASCII code and it pulls the character that corresponds with the row number returned
Why is this happening?
TIA
Sean Shrum