Jump to content

Recommended Posts

Okay, i guess to start, i have a page and i'm trying to echo a variable that containes a some html and other variables, this data is stored in a database, so it starts like this

[code]$sql = "SELECT HeaderFormat FROM News_Format WHERE FormatID='$format'";
$result = mysql_query($sql)
or die("Failed to run query to get format data.");
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$HeaderFormat = $row['HeaderFormat'];
unset($result); //must be done for later in script[/code]

the variable $HeaderFormat in this case contains

[code]<table border='1' cellpadding='0' cellspacing='0' style='border-collapse: collapse' bordercolor='#111111' width='100%' id='AutoNumber1'>
  <tr>
    <td width='33%'>$postDate</td>
    <td width='33%'>$title</td>
    <td width='34%'>$user </td>
  </tr>
  <tr>
    <td width='100%' colspan='3'>
    <font color='#ffffff'> $header ...</font>
    <p align='center'>
    $views | $comments | $fullstory
    </td>
  </tr>
</table>[/code] - that was copied directly from the database

the next 100 or so lines jsut determines what the otehr variables like $views, $comments are.

we then call a function, this is the next time heaerFormat is tuched, all it is is

[code]function showdata()
{
global $PostDateTime, $HeaderFormat;
echo "$HeaderFormat";
[/code]
well tehre is a little more code, but nothing touches that variable, when this script is displayed, teh html takes affect but the browser will output:

$postDate $title $user
$header ...

$views | $comments | $fullstory

the variables still show up, i want the variables to show the data they obtained earlier, i can't figure this one out because if i take that exact same code from the database and put it into $header bypasses the whole database process it works perfect, is there some way the mysql dataabase works that interferring with this, please help

thanks in advance, john

p.s. if you need more code please ask the entire script is 115 lines, not to many but i didn't want to post all that if it's not necisary





Link to comment
https://forums.phpfreaks.com/topic/25459-variables-inside-of-variables/
Share on other sites

thanks for everyones help, it was the eval function, i jsut wasn't using it right, still don't get howcome it did what it did, but i guess i'll look into it more alter, it's 2am here....

btw code was

[quote]
eval("\$HeaderFormat = \"$HeaderFormat\";");[/quote]

i'll figure out why tommorrow, thanks again for all the help
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.