hi, im having a spot of trouble..
ive made a mysql database with a field in a table to show all data for that page.
thing is i have a peice of code in it <?=$email?> to display an email address. but it wont work. when i put the code straight on the page without the use of the database it works fine. so im guessing this is probably sum sort of security thing?
well can anybody help me around this? maybe i could use different tags like [?$email?] and get it to translate the new brackets to the originals? if so how would i go about doing this?
any help will be muchly appreciated as im kinda stuck now!
thanks in advance..
khuti
code from database not working...
Moderator: General Moderators
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
This will probably not work the way you want because you are using a string output from the database. PHP isn't go to parse this through the engine because it is coming out of the database as a string, not as code.
There are a few things you can do about this. I would like at using something like sprintf or str_replace. Of course, this would mean that you would have to set vars first and use those vars as replacements within your database content. But I think you get the picture.
There are a few things you can do about this. I would like at using something like sprintf or str_replace. Of course, this would mean that you would have to set vars first and use those vars as replacements within your database content. But I think you get the picture.
hi, thanks for fast response..
only thing is i dont quite understand sprintf thingy, i clicked them from ur msg but im a little lost to tell u the truth!
my page has this on it..
<?
$result = mysql_query("SELECT * FROM page");
if($row = mysql_fetch_array($result)){
echo($row['data']);
}
?>
and the <?=$email?> is inside the $row['data'] the email var is set up at top of the top so it should know what to fill it in as. basically the whole page of info is inside the $row['data'].
i cant see how i would use the sprintf into that.. sorry to be a pain!
only thing is i dont quite understand sprintf thingy, i clicked them from ur msg but im a little lost to tell u the truth!
my page has this on it..
<?
$result = mysql_query("SELECT * FROM page");
if($row = mysql_fetch_array($result)){
echo($row['data']);
}
?>
and the <?=$email?> is inside the $row['data'] the email var is set up at top of the top so it should know what to fill it in as. basically the whole page of info is inside the $row['data'].
i cant see how i would use the sprintf into that.. sorry to be a pain!
how comes?
i couldnt think of any other way to do it.. its for a basic cms, to allow them to change the info on their contact page but as they dont know much about html ive made it so they can update their email address in another table, then then the <?=$email?> should display the email address as a link for them. is there a better way to do this then?
also eval hasnt worked.. im getting
Parse error: parse error, unexpected '<' in /home/adrianbr/public_html/falconhotel/contact.php(85) : eval()'d code on line 1
i couldnt think of any other way to do it.. its for a basic cms, to allow them to change the info on their contact page but as they dont know much about html ive made it so they can update their email address in another table, then then the <?=$email?> should display the email address as a link for them. is there a better way to do this then?
also eval hasnt worked.. im getting
Parse error: parse error, unexpected '<' in /home/adrianbr/public_html/falconhotel/contact.php(85) : eval()'d code on line 1