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 6 of 6

Thread: [HELP] PHP Code

  1. #1
    Join Date
    Oct 2007
    Location
    Noob Town.
    Posts
    91
    Tokens
    0

    Default [HELP] PHP Code

    Hey HxF users!

    I have this code, and it seems to be giving me an error.

    Here's the full code (it isn't mine, its off techtuts).

    PHP Code:
    <?php
        $base_host 
    "localhost";               # your sql host (usualy 'localhost')
        
    $base_name "your_database_name";      # your database name
        
    $base_user "your_database_user";      # your database username
        
    $base_pass "your_database_password";  # your database password
        
    $base_table"banners";                 # the table your going to use?
        
        # Connect to the database
        
    $db mysql_connect($base_host,$base_user,$base_pass); # connect to the database
        
    mysql_select_db ($base_name) or die ("Cannot connect to database"); # or die (if theres a problem it will echo, cannot connect to the database.
        
        
    $query mysql_query("select * from ".$base_table.""); # SQL query
        
    $total mysql_num_rows($query); # count up all the rows in the table
        
    $query mysql_query("select * from ".$base_table.""); # SQL query
        
    $total mysql_num_rows($query); # count up all the rows in the table
        
    $random = (rand()%$total); # Create a random number
        
    $query mysql_query("SELECT * FROM ".$db_table." LIMIT $random, 1"); # Retrieve the random banner from the database.
            
    # echo the query
            
    echo"<a href="$row->addr" target="_blank" title="$row->text"><img src="$row->ban_image" alt="$row->text" width="468" height="60"></a>";
            
    $view $row->views 1# update the times viewed
            
    mysql_query("update ".$base_table." set views = $view where id = $row->"id"); # another query
            } # close while()
    ?>
    I'm getting the error on this line:

    PHP Code:
          echo"<a href="$row->addr" target="_blank" title="$row->text"><img src="$row->ban_image" alt="$row->text" width="468" height="60"></a>"
    Any help would be appreciated, thanks.

    My first User Bar


    Sign Up at
    http://www.habtown.net/forum/

    THANKIES>




  2. #2
    Join Date
    Oct 2007
    Location
    Luton, England
    Posts
    1,548
    Tokens
    388
    Habbo
    DeejayMachoo

    Latest Awards:

    Default

    PHP Code:
           echo"<a href=\"$row->addr\" target=\"_blank\" title=\"$row->text\"><img src=\"$row->ban_image\" alt="\$row->text\" width=\"468\" height=\"60\"></a>"

  3. #3
    Join Date
    Oct 2007
    Location
    Noob Town.
    Posts
    91
    Tokens
    0

    Default

    Quote Originally Posted by Mattx.org View Post
    PHP Code:
           echo"<a href=\"$row->addr\" target=\"_blank\" title=\"$row->text\"><img src=\"$row->ban_image\" alt="\$row->text\" width=\"468\" height=\"60\"></a>"
    Nope, still errors.

    Any other ideas?

    This is the error code I get:

    Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in /home/habtownn/public_html/Banner/bannner.php on line 19
    Last edited by Kazco; 26-10-2007 at 08:52 PM. Reason: Adding error

    My first User Bar


    Sign Up at
    http://www.habtown.net/forum/

    THANKIES>




  4. #4
    Join Date
    Jun 2005
    Posts
    4,795
    Tokens
    0

    Latest Awards:

    Default

    PHP Code:
           echo"<a href=\"$row->addr\" target=\"_blank\" title=\"$row->text\"><img src=\"$row->ban_image\" alt=\"$row->text\" width=\"468\" height=\"60\"></a>"

  5. #5
    Join Date
    Oct 2007
    Location
    Noob Town.
    Posts
    91
    Tokens
    0

    Default

    Quote Originally Posted by Tomm View Post
    PHP Code:
           echo"<a href=\"$row->addr\" target=\"_blank\" title=\"$row->text\"><img src=\"$row->ban_image\" alt=\"$row->text\" width=\"468\" height=\"60\"></a>"
    Thanks..

    However now I'm getting this line error'd.

    PHP Code:
            mysql_query("update ".$base_table." set views = $view where id = $row->"id"); # another query 

    My first User Bar


    Sign Up at
    http://www.habtown.net/forum/

    THANKIES>




  6. #6
    Join Date
    Sep 2006
    Location
    Hobart, Australia
    Posts
    593
    Tokens
    0

    Default

    Urgh, can I suggest you use upper case for SQL functions? eg. SELECT, ALTER, UPDATE. Makes reading code a lot easier.

    PHP Code:
    mysql_query("UPDATE $base_table SET views='$view' WHERE id='{$row->"id"}'"); # another query 
    Should work.

Posting Permissions

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