A Flash Developer Resource Site

Results 1 to 16 of 16

Thread: PHP / MySQL HiScore problem

  1. #1
    Member
    Join Date
    Oct 2007
    Posts
    81

    PHP / MySQL HiScore problem

    Hi guys

    So im totaly new to this and the problem might just be some simple mistake or anything

    I got a database at freehostia.com (if you use another whats FREE and its good; tell me.) So I created a database and a table for it, then I uploaded the PHP code, and after that I have NO IDEA what to do, the plan was that i find that file there and can link it together with the game:
    getURL("http://www.somepage.com/game/round_score.php", "round_score", "POST");

    But since I cant find the file there I dont know what to do I hope you guys can help me out ?

  2. #2
    Member
    Join Date
    Oct 2007
    Posts
    81
    bump

  3. #3
    Member
    Join Date
    Oct 2007
    Posts
    81
    ok, so I uploaded the PHP code on ripway.com and all what happens when it suppose to get this in the table is just that it opens the document?

  4. #4
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi,

    if you see contents of the phpfile rather than results, the server does not support php

    Musicman

  5. #5
    Member
    Join Date
    Oct 2007
    Posts
    81
    I made some progress now, im actually connecting to DB (I think..) But i got the error message up:
    Warning: mysql_query(): Can't connect to MySQL server on 'localhost' (10061) in \\192.168.1.16\webfiles\files\2007-9\1650361\round_score.php on line 26

    Warning: mysql_query(): A link to the server could not be established in \\192.168.1.16\webfiles\files\2007-9\1650361\round_score.php on line 26
    select * from high_round order by htime asc



    My PHP:

    <?php


    $host = "mysql2.freehostia.com"; //hostname is usually localhost by default
    $user = "valsom8"; //insert the name of the user here
    $pass = "*****"; //insert the password here
    $database = " valsom8_Race"; //insert name of database wherein table was exported
    $table = "high_round"; //insert the name of the table

    // Connects to the database server
    // outputs an error message is it was unsuccessful
    $dbcnx = @mysql_connect($host,$user, $pass);


    if(($_POST['player_name'])and($_POST['running_time'])){

    $sql = "insert into high_round(name,htime) values ('".$_POST['player_name']."','".$_POST['running_time']."')";

    $result = mysql_query($sql) or die($sql);

    }

    $sql = "select * from high_round order by htime asc";

    $result = mysql_query($sql) or die($sql);

    $number = mysql_num_rows($result);

    for($x=1;$x<=$number;$x++){

    $row = mysql_fetch_array($result);

    $html .="<tr bgcolor = \"#005eff\"><td>$x</td><td>$row[name]</td><td>$row[htime]</td></tr>";

    }



    ?>

    <html>



    <head>

    <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">

    <title>100 ROUNDS:: dicactic flash game by Valerij</title>

    <style>

    body{margin:0px;background-color:#0001ff}

    td{font-size:11px;font-family:verdana;color:white;line-height:20px}

    </style>

    </head>



    <body>

    <table border = "0" cellspacing = "1" cellpadding = "3" bgcolor = "white"><tr bgcolor = "#971500"><td align = "center" colspan = "3"><strong>HALL OF FAME</strong></td></tr><tr bgcolor = "#0067ff"><td width = "30"><strong>#</strong></td><td width = "150"><strong>Name</strong></td><td><strong>Time</strong></td></tr><?php echo $html; ?></table>



    </body>



    </html>

  6. #6
    Member
    Join Date
    Oct 2007
    Posts
    81
    Bump

  7. #7
    Official FK nice guy and MOD 3PRIMATES's Avatar
    Join Date
    Apr 2002
    Location
    Portland Oregon
    Posts
    1,645
    Hi,
    php is working but you are not connecting to the database.
    Make sure you have the correct information in the connection string on the server. Looks to be connecting to localhost where you show here that you are connecting to mysql2.freehostia.com

    Look at the host site for a faqs section and see if they have some sample connection strings you can look at.

    Also, if that does not work, try using http://mysql2.freehostia.com, but I doubt that would work.

    If that doesnt work try localhost instead of mysql2.freehostia.com

  8. #8
    Member
    Join Date
    Oct 2007
    Posts
    81




  9. #9
    Official FK nice guy and MOD 3PRIMATES's Avatar
    Join Date
    Apr 2002
    Location
    Portland Oregon
    Posts
    1,645
    I made some progress now, im actually connecting to DB (I think..) But i got the error message up:
    Warning: mysql_query(): Can't connect to MySQL server on 'localhost' (10061) in \\192.168.1.16\webfiles\files\2007-9\1650361\round_score.php on line 26
    says localhost, shouldnt it say mysql2.freehostia.com if that is what you were connecting with?

  10. #10
    Member
    Join Date
    Oct 2007
    Posts
    81
    Thats what it says in PHP file at least..

  11. #11
    Member
    Join Date
    Oct 2007
    Posts
    81
    Somehow I made it work, I uploaded it again, And i see the file.. but I cant find the link to it.. Because when I open it i get the link that works only when your logged in:S

  12. #12
    Member
    Join Date
    Oct 2007
    Posts
    81
    http://www.valerij.x10hosting.com/

    Thats the HiScores.. But when im done with the game I just go to that site and nothing happends :S

  13. #13
    Official FK nice guy and MOD 3PRIMATES's Avatar
    Join Date
    Apr 2002
    Location
    Portland Oregon
    Posts
    1,645
    Hi, ok, I see a big problem.
    First, what is the name of the file that is showing at this address:
    http://www.valerij.x10hosting.com
    is that your index file?
    If so what is its extension? html or php.

    Also, check your private messages

  14. #14
    Member
    Join Date
    Oct 2007
    Posts
    81
    Its Index file and Html/text
    And I dont have any private messages :S

  15. #15
    Official FK nice guy and MOD 3PRIMATES's Avatar
    Join Date
    Apr 2002
    Location
    Portland Oregon
    Posts
    1,645
    Look again.

    Is it an html file or a php file

  16. #16
    Official FK nice guy and MOD 3PRIMATES's Avatar
    Join Date
    Apr 2002
    Location
    Portland Oregon
    Posts
    1,645
    here, try this code instead. remeber to add your username and password to it again:
    PHP Code:
    <?php

      $host 
    "mysql2.freehostia.com"//hostname is usually localhost by default
      
    $user "***"//insert the name of the user here
      
    $pass "***";  //insert the password here
      
    $database "valerij_Race";  //insert name of database wherein table was exported
      
    $table "HS";  //insert the name of the table

      // Connects to the database server
      // outputs an error message is it was unsuccessful
      
    $dbcnx mysql_connect($host,$user$pass) or die (mysql_error());
      
      
    // !!! You didnt select the database
      
    $db_selected mysql_select_db($database$dbcnx) or die (mysql_error());

    // !!! ALWAYS CLEAN/ESCAPE USER INPUT BEFORE USING IN A QUERY
    $player_name mysql_real_escape_string($_POST['player_name']);
    $running_time mysql_real_escape_string($_POST['running_time']);

    // dont use "and" use "&&"
          
    if($player_name && $running_time)
          {
              
    $sql "insert into HS(name,htime) values ('".$player_name."','".$running_time."')";
              
    $result mysql_query($sql) or die(mysql_error());
          }


          
    $sql "select from HS order by htime asc";

          
    $result mysql_query($sql) or die(mysql_error());
          
    $number mysql_num_rows($result);

          for(
    $x=1;$x<=$number;$x++){

              
    $row mysql_fetch_array($result);
              
    $html .="<tr  bgcolor = \"#005eff\"><td>$x</td><td>".$row['name']."</td><td>".$row['htime']."</td></tr>";
     
          }

    ?>
    Do you have SKYPE?? If so, skpe me at ALIENPRIMATE

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center