Results 1 to 4 of 4

Thread: Running php code in sql database

  1. #1
    Join Date
    Oct 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Running php code in sql database

    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');
    ?>

  2. #2
    Join Date
    Jun 2006
    Location
    Acton Ontario Canada.
    Posts
    677
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    Do You Have PHP installed on your server?
    - Ryan "Boxxertrumps" Trumpa
    Come back once it validates: HTML, CSS, JS.

  3. #3
    Join Date
    Oct 2006
    Location
    AL
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    PHP.NET uses this for an example of a way to store PHP values in a database:
    Code:
    function encodeText($_str) {
      $_str = strip_tags($_str);
      $_str = trim($_str);
      $_str = htmlentities($_str);
      $_str = str_replace("\r\n", "#BR#", $_str);
      return($_str);
    }

  4. #4
    Join Date
    Oct 2006
    Location
    AL
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    and use this to decode it:
    Code:
    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);
    }

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •