Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 4 of 4

Thread: PHP Error

  1. #1
    Join Date
    Nov 2006
    Location
    D?sseldorf
    Posts
    2,858
    Tokens
    2,256

    Latest Awards:

    Default PHP Error

    Ok i have this code (I know it is very unsecure i'm just unsure about the error)

    PHP Code:
    <?   
    ob_start
    (); # Allows Cookies  
    include("config.php"); 
    if(
    $logged[username] && $logged[level] == 2){
    switch(
    $_GET[action]){
    default:
    echo(
    "<b><u>Add Download</b></u><br>Here you can add downloads to 1409. Please only post important news, and make sure the image url is correct, and check it once you have posted it");
    echo(
    "<form method=\"post\" action=\"add_download.php?action=add_download\">   
    <p>Please fill out all of the following fields:</p>
    <table width='100%' border='0' cellpadding='0' cellspacing='0'>
    <tr>
    <td width='117'>Download Title*:</td>
    <td width='577'>
    <input type='text' name='title' size='50'>
    </td>
    </tr>
    <tr>
    <td width='117'>Avatar (40x40)*:</td>
    <td width='577'>
    <input type='text' name='avatar' size='50'>
    </td>
    </tr>
    <tr>
    <td width='117'>Download URL*:</td>
    <td width='577'>
    <input type='text' name='url' size='50'>
    </td>
    </tr>
    <tr>
    <td width='117'>Category*:</td>
    <td width='577'>
    <select name='categorie'>
    <option selected>Choose a Category</option>
    <option>Games</option>
    <option>Programs</option>
    <option>Scripts</option>
    <option>misc</option>
    </select>
    </td>
    </tr>
    <tr>
    <td width='117'>Description*:</td>
    <td width='577'>
    <textarea name='descrip' cols='50' rows='20'></textarea>
    </td>
    </tr>
    </table>
    <p>
    <input type='submit' name='Submit' value='Submit'>
    </p>
    </form>"
    );
    break;

    case 
    'add_download':
    $title $_POST[title];
    $avatar $_POST[avatar];
    $url $_POST[url];
    $categorie $_POST[categorie];
    $descrip $_POST[descrip];
    $author $logged[username];
    $date date("F j, Y");//set up the date format
    $date2 mktime();
    if(
    $title==NULL||$avatar==NULL||$url==NULL||$categorie==NULL||$descrip==NULL){
    echo(
    "<meta http-equiv=\"Refresh\" content=\"2; URL=add_download.php\"/>You have left a field blank<br><br><b>Please Wait...</b>");
    }else{
    $sql "INSERT INTO downloads (title, avatar, url, categorie, descrip, date, author) VALUES ('$title','$avatar','$url', '$categorie', '$descrip', '$date', '$author')";
    $result mysql_query($sql) or die ('Error during the execution of the MySQL query : ' mysql_error());
    echo(
    "<meta http-equiv=\"Refresh\" content=\"2; URL=add_download.php\"/>Your download has successfuly been submitted!<br><br><b>Please Wait...</b>");
    }
    break;
    }else{
    echo(
    "You need to be an Administrator to view this!");
    }
    ?>
    And i get the error
    "Parse error: syntax error, unexpected T_ELSE in add_download.php on line 134"

    +rep to help

    Thanks
    Luke

    Moved by Invent (Forum Moderator) from Designing & Development: Please post in the correct forum next time, thanks .
    Last edited by Invent; 24-08-2008 at 01:36 AM.

  2. #2
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    Try:
    PHP Code:
    <?php

    ob_start
    (  );
    include( 
    "config.php" ); 

    if( 
    $logged'username' ] && $logged'level' ] == )
    {

        switch( 
    $_GET'action' ] )
        {
        
            default:
            
            echo( 
    "<b><u>Add Download</b></u><br>Here you can add downloads to 1409. Please only post important news, and make sure the image url is correct, and check it once you have posted it" );
            
            echo( 
    "<form method=\"post\" action=\"add_download.php?action=add_download\">   
            <p>Please fill out all of the following fields:</p>
            <table width='100%' border='0' cellpadding='0' cellspacing='0'>
            <tr>
            <td width='117'>Download Title*:</td>
            <td width='577'>
            <input type='text' name='title' size='50'>
            </td>
            </tr>
            <tr>
            <td width='117'>Avatar (40x40)*:</td>
            <td width='577'>
            <input type='text' name='avatar' size='50'>
            </td>
            </tr>
            <tr>
            <td width='117'>Download URL*:</td>
            <td width='577'>
            <input type='text' name='url' size='50'>
            </td>
            </tr>
            <tr>
            <td width='117'>Category*:</td>
            <td width='577'>
            <select name='categorie'>
            <option selected>Choose a Category</option>
            <option>Games</option>
            <option>Programs</option>
            <option>Scripts</option>
            <option>misc</option>
            </select>
            </td>
            </tr>
            <tr>
            <td width='117'>Description*:</td>
            <td width='577'>
            <textarea name='descrip' cols='50' rows='20'></textarea>
            </td>
            </tr>
            </table>
            <p>
            <input type='submit' name='Submit' value='Submit'>
            </p>
            </form>"
    );

            break;

            case 
    'add_download':
            
            
    $title $_POST'title' ];
            
    $avatar $_POST'avatar' ];
            
    $url $_POST'url' ];
            
    $categorie $_POST'categorie' ];
            
    $descrip $_POST'descrip' ];
            
    $author $logged'username' ];
            
            
    $date date"F j, Y" );
            
    $date2 mktime(  );
            
            if( 
    $title == NULL || $avatar == NULL || $url == NULL || $categorie == NULL || $descrip == NULL )
            {
            
                echo( 
    "<meta http-equiv=\"Refresh\" content=\"2; URL=add_download.php\"/>You have left a field blank<br><br><b>Please Wait...</b>" );
            
            }
            else
            {
            
                
    $sql "INSERT INTO `downloads` ( `title`, `avatar`, `url`, `categorie`, `descrip`, `date`, `author` ) VALUES ( '"$title ."', '"$avatar ."', '"$url ."', '" $categorie ."', '"$descrip ."', '"$date ."', '"$author ."' )";
                
                
    $result mysql_query$sql ) or die ( 'Error during the execution of the MySQL query : ' mysql_error( ) );
                
                echo( 
    "<meta http-equiv=\"Refresh\" content=\"2; URL=add_download.php\"/>Your download has successfuly been submitted!<br><br><b>Please Wait...</b>" );
            
            }

            break;
            
        }
    }
    else
    {

        echo( 
    "You need to be an Administrator to view this!" );
        
    }

    ?>
    Last edited by Invent; 18-08-2008 at 09:51 PM.

  3. #3
    Join Date
    Nov 2006
    Location
    D?sseldorf
    Posts
    2,858
    Tokens
    2,256

    Latest Awards:

    Default

    the exact minute you posted i realised my mistake.

    Thanks anyway
    +rep

    EDIT: gotta spread, sorry

  4. #4
    Join Date
    May 2008
    Posts
    605
    Tokens
    0

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •