#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2001
    Posts
    4
    Rep Power
    0
    Hi everybody,
    I'm new in this forum..
    I got a problem can u guys help me??

    I'm trying to make a control panel for my guestbook. Therefore I wanna modify the font and css, I insert the font face and css into the datebase...

    and the font face and css were linked, which was like this ".text {text-decoration: none; color: $fontcolor; font-family: $font; font-size: 9pt}"

    but when I called it out, the css didn't work, so I read the source code from ie.....I can only see ".text {text-decoration: none; color: $fontcolor; font-family: $font; font-size: 9pt}"....can somebody tell how to do it??
  2. #2
  3. <insert title here>
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2001
    Location
    at home
    Posts
    405
    Rep Power
    14
    I am guessing you are trying to add an inline style declaration inside your html. I could see how that would make changes easier but I really suggest using external style sheets over db. There might be a reason for your idea, so i will leave it alone. I also have two suggestions.
    My first which is my personal preference is to create one external sheet that is applied to all pages. All you have to do is add a link tag in the head of your html like so:
    <link rel="stylesheet" href="styles.css">
    then you have one style sheet that is applied to all pages. Then theres the other way.
    And there is nothing wrong with your css. It's your PHP, database. If you don't see your variables inside the source window the code didn't execute correctly. Try posting the actual PHP if you can't figure it out. Sometimes it is easier for someone who is not frustrated about it to find the problem. If your code is working than you will see:

    .text {text-decoration: none; color: #660; font-family: #360; font-size: 9pt}
    instead of
    text {text-decoration: none; color: $fontcolor; font-family: $font; font-size: 9pt}"
    in your source window. And if you didn't add the quotes here for the post they need to be escaped inside <? ?>tags like so \" or the PHP engine try to parse what's inside.
    --the key to life is avoiding death--
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2001
    Posts
    4
    Rep Power
    0
    Hi,
    thx for replying...^^
    let me write more detail...

    I wrote this in the php code...

    $getdata = "SELECT * FROM modify";
    $getdata_result = mysql_query($getdata) or die("WRONG");
    $row = mysql_fetch_array($getdata_result);
    $font = $row["font"];
    $fontcolor = $row["fontcolor"];
    $css = $row["css"];

    the above data were selected from the data base...
    and then in the index.php
    I wrote....

    <style type="text/css">
    <?echo $css ?>
    </style>

    But when I checked the source code from IE.....
    I only saw

    <style type="text/css">
    .text {text-decoration: none; color: $fontcolor; font-family: $font; font-size: 9pt}
    </style>

    it seems like the php code hasn't been processed..>.<
    Last edited by Smoking Joe; April 15th, 2001 at 11:54 PM.
  6. #4
  7. <insert title here>
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2001
    Location
    at home
    Posts
    405
    Rep Power
    14
    I just tried this out:

    <html><?php
    $font = "tahoma";
    $fontcolor = "red";
    $css = ".text {text-decoration: none; color: $fontcolor; font-family: $font; font-size: 9pt}";

    ?>

    <style type="text/css">
    <?echo $css ?>
    </style>


    </html>
    ---------------and it resulted in:

    <html>
    <style type="text/css">
    .text {text-decoration: none; color: red; font-family: tahoma; font-size: 9pt}
    </style>


    </html>
    I am just guessing but I would say from the looks of all this your script is working fine. I might be overlooking something but I think the problem is in your db. Manually check to make sure the values didn't get input as font and fontcolor instead of hex numbers. I think your input script might be the culprit not this one. Let me know if i am wrong.
    --the key to life is avoiding death--
  8. #5
  9. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    If the css field in your db references the PHP variables $font and $fontcolor (which from what you are trying to do it appears it does) you'll need to tell PHP to look for them as it won't replace them automatically. Instead of:

    $css = $row["css"];

    use:

    $css= eval($row[css]);
  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2001
    Posts
    4
    Rep Power
    0
    thank you..!!
    I tried "$css= eval($row[css]);"
    but it showed "
    Parse error: parse error in ../data.php(26) : eval()'d code on line 1"
    can u tell wut the problem is??
    sorry....I'm not really good at PHP..
  12. #7
  13. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    That means you have an error in the PHP of the css field.
  14. #8
  15. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2001
    Posts
    4
    Rep Power
    0
    Strange...
    I add this in the php code
    "$css = eval($row["css"]);"

    and the css code in the database is "BODY {text-decoration: none; color: <?echo $fontcolor ?>; font-family: <?echo $font ?>; font-size: 9pt}"...

    it doesn't seems wrong...^^"
  16. #9
  17. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    You can't use ECHO in it if you want to assign it to a variable. You also don't want the <? ?> tags. Change it to:

    BODY {text-decoration: none; color: $fontcolor; font-family: $font ; font-size: 9pt}

    Now when the line

    $css=eval($row[css]);

    is executed, $css will have the value $row[css] EXCEPT that the variables will be replaced with their values at the time the eval() is done, then you can echo $css

IMN logo majestic logo threadwatch logo seochat tools logo