FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Including Rank





DanielXP
I have a database with ranks in it set as numbers i have and a page called ranks.php what displays the correct rank for the number but i can get it to include into a table in a different page.

Code:
  <tr>
    <td width=104>Rank:</td>
    <td width=272><?php include(\"rank.php\"); ?></td>
  </tr>


Can any body help

Ps. This is in an echo
BlackSkad
When you echo something like your code, the php-parser won't recognize the php within and will just treat it as a normal string (bunch of text). Assuming rank.php echo's the rank, this should do the trick.

Code:
<?php
echo '  <tr>
    <td width=104>Rank:</td>
    <td width=272>';
include('rank.php');
echo '    </td>
  </tr>';
DanielXP
i can't put that inside an echo
Simulator
DanielXP wrote:
i can't put that inside an echo



Why would you want to put it in one, I think your problem is the \ in the code, it changes the " so they are not read as a statment so just put in

Code:
<?php include("rank.php"); ?>
DanielXP
Nope

Parse error: syntax error, unexpected T_STRING in /home/leos4h/public_html/members/members.php on line 54
ganbate
DanielXP wrote:
Nope

Parse error: syntax error, unexpected T_STRING in /home/leos4h/public_html/members/members.php on line 54


i don't get it..
can you post the code on members.php so that all the people here can fix the code?
BlackSkad
It's fairly simple, you can't put <?php include("rank.php"); ?> inside a echo-function and expect that rank.php will be included.
That's why you need to break the echo, include the file, and then echo the final part as I have said before.
What you're trying to do is, imho, this, and you want rank.php to output the name of a rank:
Code:
<?php
echo "
   ... a lot of html-code here
  <tr>
    <td width=104>Rank:</td>
    <td width=272><?php include(\"rank.php\"); ?></td>
  </tr>
  ... more html-code here";
?>


However, <?php include(\"rank.php\"); ?> is within a string now and the parser only parses variables inside a string, not anything else. So the include will not be executed. That's why you need to break the echo, include the file, and then echo the rest, like this:
Code:
<?php
echo '  <tr>
    <td width=104>Rank:</td>
    <td width=272>';
include('rank.php');
echo '    </td>
  </tr>';
?>
DanielXP
Cheers works.

Code:
echo ("
<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse\" bordercolor=\"#111111\" width=304 id=\"AutoNumber1\">
  <tr>
    <td width=104>User ID:</td>
    <td width=272>$profile[id]</td>
  </tr>
  <tr>
    <td width=104>Username:</td>
    <td width=272>$profile[username]</td>
  </tr>
  <tr>
    <td width=104>Points:</td>
    <td width=272>$profile[points]</td>
  </tr>");



echo '  <tr>
    <td width=104>Rank:</td>
    <td width=272>';
include('rank.php');
echo '    </td>
  </tr>';


echo ("
  <tr>
    <td width=104>Real Name:</td>
    <td width=272>$profile[realname]</td>
  </tr>
  <tr>
    <td width=104>Age:</td>
    <td width=272>$profile[age]</td>
  </tr>
  <tr>
    <td width=104>Sex:</td>
    <td width=272>$profile[sex]</td>
  </tr>
  <tr>
    <td width=104>Email:</td>
    <td width=272>$profile[email]</td>
  </tr>
  <tr>
    <td width=104>Website:</td>
    <td width=272><a target=\"_blank\" href=\"$profile[website]\">
    <font color=\"#000000\">$profile[website]</font></a></td>
  </tr>
</table>");


Thanks again BlankSkad
jabapyth
do you need parenthesis?
Related topics
Rank High For MULTIPLE phrases
Forum rank images; a lot of images, a lot of frih$
RANK SHOP 3 frih$ per rank
Does Frihost Directory will pass Page Rank?
How to increase your Page Rank?
Linking from a high page rank site
The Best Way to Get Page Rank 10 in GOOGLE
Rank images contest
Dems: these are merely the facts
Kingdom Hearts... The Original, CoM, and 2
Free Forums?
Justification for War in Iraq
India Won : Dravid Man of Match
25 things you *DON"T* want to know (Trust Me!)
This topic is locked: you cannot edit posts or make replies.    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.