Random Splash Scripts

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Sly
Forum Newbie
Posts: 14
Joined: Wed Apr 02, 2003 8:29 am
Contact:

Post by Sly »

i tried another webserver and i get this new error

Parse error: parse error, unexpected T_GLOBAL in /home3/loyalty/public_html/splash.php on line 8

my new line 8 is:
global $img_array;

following lines is:

$img_array[1] = "splashes/1/index.php";
$img_array[2] = "splashes/2/index.php";
$img_array[3] = "splashes/3/index.php";
 
  global $random;
  // if $random hasn't been defined by a prior call to this function
   if (!isset($random)) {
      // initialize the random-generator (obsolete for php 4.2+
      srand ((double) microtime() * 1000000);
      // get a random number that can be used as index for img_array
      $random = rand(1, count($img_array));
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

but a simpler script works?

Code: Select all

<?php phpinfo() ?>
for example?
what version do you use on what OS? phpinfo() will tell you.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

What are the lines before the line on which the error is reported (1-7).

The problem is generally found in the lines before the one stated in the error message.

Mac
Sly
Forum Newbie
Posts: 14
Joined: Wed Apr 02, 2003 8:29 am
Contact:

Post by Sly »

volka wrote:but a simpler script works?

Code: Select all

<?php phpinfo() ?>
for example?
what version do you use on what OS? phpinfo() will tell you.
yes this works
Sly
Forum Newbie
Posts: 14
Joined: Wed Apr 02, 2003 8:29 am
Contact:

Post by Sly »

twigletmac wrote:What are the lines before the line on which the error is reported (1-7).
line 1-8
<?php
/**
creates an array img_array in global scope containing
the paths to all available splash-documents
returns a random doc-path once a request (if called again within the same request returns the same doc)
*/
function random_background() {
  global $img_array;

it seems tat nothing was wrong...........
i can't get it running why?
i just add some comments
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

what version do you use on what OS? phpinfo() will tell you.

Code: Select all

<?php
/**
dummy comment
dummy function
*/
function dummy() {
  echo 'test';
}

dummy();
?>
does this work?
Sly
Forum Newbie
Posts: 14
Joined: Wed Apr 02, 2003 8:29 am
Contact:

Post by Sly »

volka wrote:what version do you use on what OS? phpinfo()
i am trying it on 2 webhost,
spaceports and tripod
tripod is using php 4.1
spaceport's php version is 4.2.2

both doesnot work........
does it means that the features only support version 4.3 and above?

this is from spaceports' error (version 4.2.2)

Parse error: parse error, unexpected T_ECHO in /home3/loyalty/public_html/dummy.php on line 7
Sly
Forum Newbie
Posts: 14
Joined: Wed Apr 02, 2003 8:29 am
Contact:

Post by Sly »

i downloaded php 4.3.1 and bad blue on my computer to try it
but it is still the same:

Parse error: parse error, unexpected T_STRING in D:\Program Files\BadBlue\PE\php\splash.php on line 2

line 1 and line 2 is:
<?php
function random_background() {

according to site admin, if i get a parse error means the above line got errors in it....
but
wat is the error in <?php
Sly
Forum Newbie
Posts: 14
Joined: Wed Apr 02, 2003 8:29 am
Contact:

Post by Sly »

twigletmac wrote:I copied and pasted your code but didn't get any parse errors, have you tried deleting the first two lines completely and retyping them?
er.....
can you do it again and post the url in here,
is it convenient for you to do it?
if yes,
i could save the source down
Post Reply