Tilted Forum Project Discussion Community  

Go Back   Tilted Forum Project Discussion Community > Interests > Tilted Technology


 
 
LinkBack Thread Tools
Old 07-30-2004, 11:08 AM   #1 (permalink)
Upright
 
PHP syntax error eludes me

I'm trying to see the error but I can't. Could someone take a look at this and tell me what is wrong.





PHP Code:
  function plot_cam() {
            global 
$filename,$img,$pause;
            
$k 0;
            
Header("Content-type: multipart/x-mixed-replace;boundary=ThisRandomString");
            while (
$img[$k]==$filename) {
                print(
"\n--ThisRandomString\n\n");
                
Header("Content-type: text/plain");
                
$cam fopen($filename,"r"); 
                
fpassthru($cam);
                 
fclose($cam);
                if (
$pause) { sleep($pause);} // time between reload, usefull for server usage
                
$k++;
                if (
$k==count($img)) {
                    echo(
"\n--ThisRandomString--\n");                    
                }
             }    
    }
    
/**************************************************************************************/
        
Broser Detection is provided by Leon Atkinson <leon@clearink.com>
    
/*------------------------------------------------------------------------------------*/
       /* Get the name the browser calls itself and what version */
        
$Browser_Name strtok($HTTP_USER_AGENT"/");
        
$Browser_Version strtok(" ");
        
/* MSIE lies about its name */
        
if(ereg("MSIE"$HTTP_USER_AGENT))    {
            
$Browser_Name "MSIE";
            
$Browser_Version strtok("MSIE");
            
$Browser_Version strtok(" ");
            
$Browser_Version strtok(";");
        }
        
/* Opera isn't completely honest, either ... */
        /* Modificaton by Chris Mospaw <mospaw@polk-county.com> */
        
if(ereg("Opera"$HTTP_USER_AGENT))    {
            
$Browser_Name "Opera";
            
$Browser_Version strtok("Opera");
            
$Browser_Version strtok("/");
            
$Browser_Version strtok(";");
        }
        
/* try to figure out what platform, windows or mac */
        
$Browser_Platform "unknown";
        if(
ereg("Windows",$HTTP_USER_AGENT
            || 
ereg("WinNT",$HTTP_USER_AGENT
            || 
ereg("Win95",$HTTP_USER_AGENT)) {
                
$Browser_Platform "Windows";
        }
        if(
ereg("Mac"$HTTP_USER_AGENT)) {
            
$Browser_Platform "Macintosh";
        }
        if(
ereg("X11"$HTTP_USER_AGENT)) { 
            
$Browser_Platform "Unix"
        } 
        if((
$Browser_Platform == "Windows")){
            if(
$Browser_Name == "Mozilla")    {
                if(
$Browser_Version >= 3.0)    {
                }        
                
// SERVER PUSH WORK'S ONLY HERE :)
                
if($Browser_Version >= 4.0)    { plot_cam(); }
            }
        }
        elseif(
$Browser_Platform == "Macintosh") {
            if(
$Browser_Name == "Mozilla") {
                if(
$Browser_Version >= 3.0)    {
                }        
                
// SERVER PUSH WORK'S ONLY HERE :)
                
if($Browser_Version >= 4.0)    {plot_cam();}
            }
        }
        elseif(
$Browser_Platform == "Unix") { 
            if(
$Browser_Name == "Mozilla") { 
                if(
$Browser_Version >= 3.0) { 
                } 
                
// SERVER PUSH WORK'S ONLY HERE :)
                
if($Browser_Version >= 4.0) { plot_cam();} 
            } 
        }
    exit;    
    
?> 
Chaffed is offline  
Old 07-30-2004, 03:40 PM   #2 (permalink)
Fluxing wildly...
 
MrFlux's Avatar
 
Location: Auckland, New Zealand
Um... if you're getting an error, can you please tell us what it is? Thats an awful lot of code to look through to spot an error, so a specific error and line number would be useful.
__________________
flux (n.)
Medicine. The discharge of large quantities of fluid material from the body, especially the discharge of watery feces from the intestines.
MrFlux is offline  
Old 07-30-2004, 03:45 PM   #3 (permalink)
Please touch this.
 
Halx's Avatar
 
Owner/Admin
Location: Manhattan
Without knowing what the error is, I'll start by suggesting that you put quotation marks around each version number in the IF statements.
__________________
You have found this post informative.
-The Administrator
[Don't Feed The Animals]
Halx is offline  
Old 08-01-2004, 04:34 AM   #4 (permalink)
Follower of Ner'Zhul
 
RelaX's Avatar
 
Location: Netherlands
Zend Studio rocks.

It works like this:
PHP Code:
/**************************************************************************************

        Browser Detection is provided by Leon Atkinson <leon@clearink.com>

/*------------------------------------------------------------------------------------*/ 
Notice that I removed the slash after the line of stars, which was closing the comment and causing the string to be parsed by PHP.

I would suggest you change it into:
PHP Code:
/**********************************************************************
 *                                                                    *
 * Browser Detection is provided by Leon Atkinson <leon@clearink.com> *
 *                                                                    *
 **********************************************************************/ 
Or if you want to be tha bomb and make it phpdoc compatible (phpdoc rules!) and generally more compact and human readable you could rewrite your code as follows:

PHP Code:
<?php

getBrowserInfo
();

/**
 * The plot cam function
 */
function plot_cam()
{
    global 
$filename,$img,$pause;
    
$k 0;

    
Header("Content-type: multipart/x-mixed-replace;boundary=ThisRandomString");

    while (
$img[$k]==$filename
    {
        print(
"\n--ThisRandomString\n\n");
        
Header("Content-type: text/plain");
        
        
$cam fopen($filename,"r");
        
fpassthru($cam);
        
fclose($cam);

        if (
$pause) { sleep($pause);} // time between reload, usefull for server usage

        
$k++;

        if (
$k==count($img)) echo("\n--ThisRandomString--\n");
    }
}

/**
 * Browser Detection is provided by Leon Atkinson <leon@clearink.com>
 */
function getBrowserinfo()
{
    
/* Get the name the browser calls itself and what version */

    
$Browser_Name strtok($HTTP_USER_AGENT"/");
    
$Browser_Version strtok(" ");

    
/* MSIE lies about its name */
    
if(ereg("MSIE"$HTTP_USER_AGENT))    
    {
        
$Browser_Name "MSIE";
        
$Browser_Version strtok("MSIE");
        
$Browser_Version strtok(" ");
        
$Browser_Version strtok(";");
    }

    
/* Opera isn't completely honest, either ... */
    /* Modificaton by Chris Mospaw <mospaw@polk-county.com> */
    
if(ereg("Opera"$HTTP_USER_AGENT))    
    {
        
$Browser_Name "Opera";
        
$Browser_Version strtok("Opera");
        
$Browser_Version strtok("/");
        
$Browser_Version strtok(";");
    }

    
/* try to figure out what platform, windows or mac */
    
$Browser_Platform "unknown";

    if(
ereg("Windows",$HTTP_USER_AGENT)
    || 
ereg("WinNT",$HTTP_USER_AGENT)
    || 
ereg("Win95",$HTTP_USER_AGENT)) 
        
$Browser_Platform "Windows";

    if(
ereg("Mac"$HTTP_USER_AGENT)) 
            
$Browser_Platform "Macintosh";

    if(
ereg("X11"$HTTP_USER_AGENT))
        
$Browser_Platform "Unix";

    if((
$Browser_Platform == "Windows"))
    {
        if(
$Browser_Name == "Mozilla")    
        {
            
// SERVER PUSH WORK'S ONLY HERE <img src="images/smilies/smile.gif" border="0" alt="">
            
if($Browser_Version >= 4.0plot_cam();
        }
    }
    elseif(
$Browser_Platform == "Macintosh"
    {
        if(
$Browser_Name == "Mozilla"
        {
            
// SERVER PUSH WORK'S ONLY HERE <img src="images/smilies/smile.gif" border="0" alt="">
            
if($Browser_Version >= 4.0)  plot_cam();
        }
    }

    elseif(
$Browser_Platform == "Unix"
    {
        if(
$Browser_Name == "Mozilla"
        {
            
// SERVER PUSH WORK'S ONLY HERE <img src="images/smilies/smile.gif" border="0" alt="">
            
if($Browser_Version >= 4.0) { plot_cam();}
        }
    }
}
?>
But that is just my style, doesn't have to be yours.
__________________
The most likely way for the world to be destroyed, most experts agree, is by accident. That's where we come in; we're computer professionals. We cause accidents.
- Nathaniel Borenstein

Last edited by RelaX; 08-01-2004 at 05:00 AM..
RelaX is offline  
Old 08-01-2004, 09:22 AM   #5 (permalink)
Upright
 
Whollly crap! Above and beyond my friend. I am not worthy. Thank you so very much.
Chaffed is offline  
 

Tags
eludes, error, php, syntax

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 02:38 AM.

Tilted Forum Project

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73