+ Reply to Thread
Results 1 to 9 of 9

Thread: 100 credits to the one who fix this php

  1. #1
    galaxyAbstractor's Avatar
    galaxyAbstractor is offline Community Advocate galaxyAbstractor is on a distinguished road
    Join Date
    Oct 2007
    Location
    Land of Null and Insanity
    Posts
    5,495

    100 credits to the one who fix this php

    Soooo something is wrong again...

    PHP Code:
    // Connect to server and select database.
    mysql_connect("$host""$username""$password")or die("cannot connect to server ");
    mysql_select_db("$db_name")or die("cannot select DB")

    $sql="SELECT * FROM $tbl_name";
    $result=mysql_query($sql);

    $rows=mysql_fetch_array($result);
    $counter=$rows['counter'];

    // if have no counter value set counter = 1
    if(empty($counter)){
    $counter=1;
    $sql1="INSERT INTO $tbl_name(counter) VALUES('$counter')";
    $result1=mysql_query($sql1);
    }

    echo 
    $counter;
    echo 
    "people has played our games. ";


    mysql_close();
    ?> 
    I get this error: Parse error: syntax error, unexpected T_VARIABLE in /home/viggeswe/public_html/flash/counterh.php on line 12

    Line 12 is
    PHP Code:
    $sql="SELECT * FROM $tbl_name"
    It isn't line 12 here because I deleted the password and username thing at the top.

    And yes. Everything I had input in the code is correct. And I have deleted the add hit on this one because I want to count the game plays and not the main page hits.
    Edit:
    Ok I give 100 credits for the one who fix it
    Last edited by galaxyAbstractor; 11-30-2007 at 10:58 AM.

  2. #2
    supajason's Avatar
    supajason is offline x10 Lieutenant supajason is an unknown quantity at this point
    Join Date
    Oct 2007
    Location
    England........:-)
    Posts
    288

    Re: 100 credits to the one who fix this php

    you need a table name?

    line 11

    PHP Code:
    $tbl_name "table name"
    supajason was here

  3. #3
    galaxyAbstractor's Avatar
    galaxyAbstractor is offline Community Advocate galaxyAbstractor is on a distinguished road
    Join Date
    Oct 2007
    Location
    Land of Null and Insanity
    Posts
    5,495

    Re: 100 credits to the one who fix this php

    I sad I already had done that but I don't want to post all my database password etc. The table name is there. Btw, this is what I use:
    PHP Code:
    $tbl_name="counter"// Table name 
    And I have created the table.
    Last edited by galaxyAbstractor; 11-30-2007 at 11:31 AM.

  4. #4
    supajason's Avatar
    supajason is offline x10 Lieutenant supajason is an unknown quantity at this point
    Join Date
    Oct 2007
    Location
    England........:-)
    Posts
    288

    Re: 100 credits to the one who fix this php

    post the whole file please?
    supajason was here

  5. #5
    galaxyAbstractor's Avatar
    galaxyAbstractor is offline Community Advocate galaxyAbstractor is on a distinguished road
    Join Date
    Oct 2007
    Location
    Land of Null and Insanity
    Posts
    5,495

    Re: 100 credits to the one who fix this php

    PHP Code:
    <title>Untitled Document</title><?php
    $host
    ="localhost"// Host name
    $username="*deleted*"// Mysql username
    $password="*deleted*"// Mysql password
    $db_name="viggeswe_phpbb"// Database name
    $tbl_name="counter"// Table name

    // Connect to server and select database.
    mysql_connect("$host""$username""$password")or die("cannot connect to server ");
    mysql_select_db("$db_name")or die("cannot select DB")

    $sql="SELECT * FROM $tbl_name";
    $result=mysql_query($sql);

    $rows=mysql_fetch_array($result);
    $counter=$rows['counter'];

    // if have no counter value set counter = 1
    if(empty($counter)){
    $counter=1;
    $sql1="INSERT INTO $tbl_name(counter) VALUES('$counter')";
    $result1=mysql_query($sql1);
    }

    echo 
    $counter;
    echo 
    "people has played our games. ";

    mysql_close();
    ?>

  6. #6
    supajason's Avatar
    supajason is offline x10 Lieutenant supajason is an unknown quantity at this point
    Join Date
    Oct 2007
    Location
    England........:-)
    Posts
    288

    Re: 100 credits to the one who fix this php

    change
    PHP Code:
    mysql_select_db("$db_name")or die("cannot select DB"
    to

    PHP Code:
    mysql_select_db("$db_name")or die("cannot select DB"); 
    supajason was here

  7. #7
    galaxyAbstractor's Avatar
    galaxyAbstractor is offline Community Advocate galaxyAbstractor is on a distinguished road
    Join Date
    Oct 2007
    Location
    Land of Null and Insanity
    Posts
    5,495

    Re: 100 credits to the one who fix this php

    Ok, It worked now. I give you the credits if you fix this too:

    PHP Code:
    <title>Untitled Document</title><?php
    $host
    ="localhost"// Host name
    $username="************"// Mysql username
    $password="************"// Mysql password
    $db_name="viggeswe_phpbb"// Database name
    $tbl_name="counter"// Table name

    // Connect to server and select database.
    mysql_connect("$host""$username""$password")or die("cannot connect to server ");
    mysql_select_db("$db_name")or die("cannot select DB");

    $sql="SELECT * FROM $tbl_name";
    $result=mysql_query($sql);

    $rows=mysql_fetch_array($result);
    $counter=$rows['counter'];

    // if have no counter value set counter = 1
    if(empty($counter)){
    $counter=1;
    $sql1="INSERT INTO $tbl_name(counter) VALUES('$counter')";
    $result1=mysql_query($sql1);
    }

    // count more value
    $addcounter=$counter+1;
    $sql2="update $tbl_name set counter='$addcounter'";
    $result2=mysql_query($sql2);

    mysql_close();
    ?>
    It adds 2 instead of 1 when I visit the page once.

  8. #8
    supajason's Avatar
    supajason is offline x10 Lieutenant supajason is an unknown quantity at this point
    Join Date
    Oct 2007
    Location
    England........:-)
    Posts
    288

    Re: 100 credits to the one who fix this php

    try

    PHP Code:
    $addcounter $counter "1"
    or

    PHP Code:
    $counter++;
    $sql2="update $tbl_name set counter='$counter'"
    Last edited by supajason; 11-30-2007 at 05:00 PM. Reason: new idea
    supajason was here

  9. #9
    galaxyAbstractor's Avatar
    galaxyAbstractor is offline Community Advocate galaxyAbstractor is on a distinguished road
    Join Date
    Oct 2007
    Location
    Land of Null and Insanity
    Posts
    5,495

    Re: 100 credits to the one who fix this php

    Yey!!! Thank you very much!

+ Reply to Thread

Similar Threads

  1. tons of PHP Resources
    By Chris S in forum Scripts & 3rd Party Apps
    Replies: 10
    Last Post: 01-16-2009, 10:07 AM
  2. Unstand PHP?
    By o0slowpaul0o in forum Tutorials
    Replies: 8
    Last Post: 01-07-2008, 09:16 PM
  3. Sigo con problemas con phpbb2
    By reciecho in forum Soporte
    Replies: 7
    Last Post: 10-20-2007, 06:28 PM
  4. "PHP Startup: Invalid Library" - Interesting error
    By javaguy78 in forum Free Hosting
    Replies: 5
    Last Post: 03-27-2007, 02:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers