Jump to content


Photo

PHP assistance needed!


  • Please log in to reply
3 replies to this topic

#1 ambershee

ambershee

    Nimbusfish Rawks

  • Hosted
  • 3,114 posts
  • Location:Derby, UK
  • Projects:Mutator Week & Unreal 3 Projects
  •  Mad Mod Boffin

Posted 03 October 2005 - 07:31 PM

Evening all. I'm having problems implementing my PHP includes for my updated website layout. I'm not exactly versed in PHP, so it'd be nice if someone can point out the dodgyness of my coding.
The code is simple, I'm trying to firstly, get includes to appear in my pages in a similar fashion, as well as a more adventurous random include piece. It should be quite simple, but it appears to not be working properly, and very tempramental.
The layout itself needs a little bit of work (just a bit of formatting, lol).

Anyway, there are a few files on the FTP that have been used as a test bed, but it's essentially my random includes that don't work, and example of which is below;

INDEX - All includes look like the one below...
<?php @include ("subnews.php"); ?>

DBLORE.PHP - One of the randoms that doesn't seem to work properly; selection only - it's quite long otherwise :sad:!

<?
//	include ('dblore.php');     //


$dblore = array();
$dblore[0] = "<font face="Verdana" size="1">The original David Hunter 2 concept was a psychic featuring, sword wielding stealth-em-up";
$dblore[1] = "<font face="Verdana" size="1">David Hunter 2's original psychics were either Biomancers, Telepaths, Pyromancers or Telekinetics";
$dblore[2] = "<font face="Verdana" size="1">Death of a Hero was originally a one man effort to mod Delta Force. It failed.";
$dblore[3] = "<font face="Verdana" size="1">Reactive Principle concepts originally features nearly 1000 different ship types";
$dblore[4] = "<font face="Verdana" size="1">At one point, a David Hunter style CCG was in the making. It might come back one day";
$dblore[5] = "<font face="Verdana" size="1">David Hunter features a customiseable CFG or Config file which allows players to customise more";

[i]...This keeps on going for sometime, and then this is banged on the end[/i]

$count = count($dblore) - 1;
$num = rand(32,$count);
echo $dblore[$num];
?>

So where's my mistake?

#2 Mastermind

Mastermind

    Server Technician

  • Undead
  • 7,014 posts
  • Location:Cambridge, MA
  • Projects:MasterNews 3
  •  The Man Behind the Curtain

Posted 03 October 2005 - 08:10 PM

Replace rand(32, $count) with rand(0, $count). The arguments for rand are rand($min, $max), so you wouldn't get what you want at all with 32 as the minimum.

To see the problem with your includes, use just include instead of @include, as the @ supresses any errors.
Posted Image

Well, when it comes to writing an expository essay about counter-insurgent tactics, I'm of the old school. First you tell them how you're going to kill them. Then you kill them. Then you tell them how you just killed them.

Too cute! | Server Status: If you can read this, it's up |

#3 ambershee

ambershee

    Nimbusfish Rawks

  • Hosted
  • 3,114 posts
  • Location:Derby, UK
  • Projects:Mutator Week & Unreal 3 Projects
  •  Mad Mod Boffin

Posted 03 October 2005 - 08:23 PM

Cheers, I'll give it a wiz when I get back from the pub :)

#4 Kravvitz

Kravvitz

    [X]HTML, CSS, & JS/DOM Adept

  • Members
  • 443 posts
  • Location:USA

Posted 04 October 2005 - 03:08 AM

You didn't escape the inner double quotes.
$dblore[0] = "<font face=[b]\"Verdana\" size=\"1\"[/b]>The original David Hunter 2 concept was a psychic featuring, sword wielding stealth-em-up";

This is a bit old, but much of what it says is relevant -- What's wrong with the FONT element?

You should use CSS instead of the <font> element.

Edited by Kravvitz, 04 October 2005 - 03:08 AM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users