Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder
    Join Date
    May 2006
    Posts
    1,680
    Thanks
    28
    Thanked 4 Times in 4 Posts

    php variable not getting evaluated ??

    Hi

    I am using a variable in my mySQL database table record which I want
    to be used when the record is displayed by the browser.

    So my sql table, I have a record named summary which is
    a "text" type and contains this:

    North London $page_kw1 which has Free Wifi and Cable TV.
    Short Term Let from just £500 per week. All inclusive.

    Master bedroom has sizeable en-suite
    bathroom. Second bedroom also has a large bathroom opposite. This specific $page_kw2 is in North London and given on short term lease at 500 per
    Then in my display script I have:

    PHP Code:
    $sql "SELECT * FROM pages WHERE page_id = '$page_id' ";
    $result mysql_query($sql)    or die("could not find PAGE: $page_id"mysql_error());
    $row mysql_fetch_assoc($result); 
    extract($row);

    echo 
    "$summary"

    The table "pages" contains the records "summary" and "page_kw1"


    And the result is this:

    North London $page_kw1 which has Free Wifi and Cable TV.
    Short Term Let from just £500 per week. All inclusive.

    Master bedroom has sizeable en-suite
    bathroom. Second bedroom also has a large bathroom opposite. This specific $page_kw2 is in North London and given on short term lease at 500 per week. Amazon block
    So as you can see, the $page_kw1 is not getting evaluated.

    What am I doing wrong ?

    Thanks.


    .
    If you want to attract and keep more clients, then offer great customer support.

    Support-Focus.com. automates the process and gives you a trust seal to place on your website.
    I recommend that you at least take the 30 day free trial.

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,348
    Thanks
    23
    Thanked 618 Times in 617 Posts
    Don't know how to fix your DB, but this will (or should) fix the output:
    PHP Code:
    <?php
    $sql 
    "SELECT * FROM pages WHERE page_id = '$page_id' ";
    $result mysql_query($sql)    or die("could not find PAGE: $page_id"mysql_error());
    $row mysql_fetch_assoc($result); 
    extract($row);

    $new str_replace('$page_kw1'$page_kw1$summary);
    echo 
    $new;
    ?>
    Last edited by sunfighter; 10-05-2013 at 06:52 PM.
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."

  • #3
    Senior Coder
    Join Date
    May 2006
    Posts
    1,680
    Thanks
    28
    Thanked 4 Times in 4 Posts
    Of course !!!

    Thanks.


    .
    If you want to attract and keep more clients, then offer great customer support.

    Support-Focus.com. automates the process and gives you a trust seal to place on your website.
    I recommend that you at least take the 30 day free trial.


  •  

    Posting Permissions

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