Jump to content

Replacement string that comes from database


Lisa23

Recommended Posts

Hi i have a query that retrives fields from the database now i have a query now on the form teh user has to put sign (£) i am trying to grab that row and evrytime it finds the (£) on that particular field replace when it echo the row film_price replace any (£) signs with (&pound)

 

Example on the databse the user typed £45 to £55 when echo that row on html replace the (£) signs with html (£) which is (&pound) i have tried

 

but didnt echo the row what i am doing wrong?

 

<?php

  $vOriginalString = $film_price;

  $vSomeSpecialChars = array("£", "$");

  $vReplacementChars = array("&pound POA", "&pound POA");

  $vReplacedString = str_replace($vOriginalString);

 

  echo $vReplacedString;

?>

that film is value is coming from the database i have a query with the fetch function that pick up the

film price from the database like so i dnt know the value has it coming from the database

$film_price= $row['film_price'];

can i put it like

<?
$film_price = .$row['film_price'].;
echo str_replace('£', '£', $film_price);
//prints £1000
?>

i'm a lil confused now my code is something like this not (full fetch query) but i then try echo the film price, doesnt echo on the fetch query i have this line

$viewing_price=($film_price);

i'm presuming that is saying $viewing_price now has the value of film_price

so to echo film price instead of echo $film_price ? it is echo $viewing_price correct  ?

at the botton of the code is my try on the replacemen  i'm confused on what should echo and replace string be

 

$connection = @mysql_connect($db_address,$db_username,$db_password) or die("Couldn't CONNECT.");
$db = @mysql_select_db($db_name, $connection) or die("Couldn't select DATABASE.");	//SELECT All based on current cookie Information	
$query="SELECT * FROM films WHERE (film_filename = '$id')";
$result = mysql_query($query) or die("Couldn't execute QUERY.");
if($jrpmerrorstatus=="1")
{
$film_qty = mysql_num_rows($result );
	print("FOUND: $film_qty<BR>");
}
  while ($row = mysql_fetch_array($result))
  	{
	  $film_price					= $row['film_location_price'];

if($film_addr01=="" || $film_addr01=="X")
$viewing_price=($film_price);

mysql_close($connection);
<?php

<?php
$viewing_price = $row['film_price'];
str_replace('£', '£', $film_price);
?>

<?php print $film_price; ?>

Thank you all for the help @darkfreaks link fixed the problem by just having the metatag like this the above code worked fine

Thank you all for the help :D

 

<meta content="text/html; charset=iso-8859-15" http-equiv="Content-Type">
<?php
$userInputEntities = htmlentities($viewing_price);

//Now we can display it
echo $viewing_price;
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.