PDA

View Full Version : Running php code in sql database



Cheaperholidays
10-11-2006, 07:50 AM
Hi all

I wonder if anyone can help?

We are trying to insert this code into a an sql description which will insert weather data into our holiday guides.

However what happens is the code is displayed instead of the data

Any ideas how we can over come this

<?php require_once '/weather.php';
('cborder','');
('iorder','url,title,desc');
('biurl','<a title="Agadir weather forecast" href="');
('aiurl','"target="_blank" rel="nofollow">');
('ailink',' Agadir weather</a> <br />');
('bi',' ');
('aidesc','< Click for 5 day Agadir forecast></font><br />');
('bidesc','<img src="http://www.cheaperholidays.com/arrow1.jpg"> <font color="purple"> ');

('maxitems',1);

// show up to 40 characters of the description
('maxidesc',70);
('poweredby','');

Show('http://www.blah.com/weather/world/115.xml');
?>

boxxertrumps
10-11-2006, 05:35 PM
Do You Have PHP installed on your server?

bdichiara
10-12-2006, 02:47 PM
PHP.NET uses this for an example of a way to store PHP values in a database:


function encodeText($_str) {
$_str = strip_tags($_str);
$_str = trim($_str);
$_str = htmlentities($_str);
$_str = str_replace("\r\n", "#BR#", $_str);
return($_str);
}

bdichiara
10-12-2006, 02:48 PM
and use this to decode it:

function decodeText($_str, $_form) {
$trans_tbl = get_html_translation_table (HTML_ENTITIES);
$trans_tbl = array_flip ($trans_tbl);
$_str = strtr($_str, $trans_tbl);
if ($_form) {
$_nl = "\r\n";
} else {
$_nl = "<br>";
}
$_str = str_replace("#BR#", "$_nl", $_str);
return($_str);
}