SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: PHP in MySQL?

  1. #1
    SitePoint Evangelist AlexC's Avatar
    Join Date
    Oct 2000
    Location
    Sheffield, UK
    Posts
    437
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP in MySQL?

    Hi,

    i am templating a site, and have aproblem.

    in mysql, i have stored the way an article should be displayed, however instead of the name (for example "Hello World!")displays $title

    anyhelp appreciated
    Nearly 7 years old!

  2. #2
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Could you show us with some code?

    THanks

  3. #3
    SitePoint Evangelist AlexC's Avatar
    Join Date
    Oct 2000
    Location
    Sheffield, UK
    Posts
    437
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    function get_template($template_name) {
        
    $gettemplate mysql_query("SELECT * FROM templates WHERE template_name='$template_name'");
        while ( 
    $row mysql_fetch_array($gettemplate)) {
            
    $templatehtml $row["code"];
        echo(
    "$templatehtml");
        }

    next

    PHP Code:
    get_template("forumhome_usersonline"); 
    which then produces

    there are $usersonline online users right now

    (and in the database, the code is

    Code:
    there are $useronline online users right now
    Alex
    Nearly 7 years old!

  4. #4
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You'll have to do a str_replace on the variable as php code in a database is not parsed.

    So either str_replace or you must eval() the code.


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
  •