PDA

View Full Version : PHP / MySQL HiScore problem


Valerij
11-06-2007, 08:58 PM
Hi guys
I cant the right forum so I think it goes here:

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 ?

Valerij
11-07-2007, 04:13 PM
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?

majicassassin
11-07-2007, 06:08 PM
It needs to be on a webhost... ripway looks like it just hosts files (ie, it just sends the file instead of compiling the PHP)

Valerij
11-07-2007, 08:47 PM
Sure, but since it doesnt work on Freehostia, which one do you suggest to use?

Valerij
11-08-2007, 06:41 PM
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>

Valerij
11-10-2007, 04:31 PM
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

Valerij
11-10-2007, 05:43 PM
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

majicassassin
11-10-2007, 06:05 PM
So again, the server is not compiling the page as a PHP page. Either
a) x10 doesn't have a php compiler installed
or b) your file does not end with the extension ".php"

Proof of this, here is your login stats for your database (publically accessible on your site):
$host = "http://mysql2.freehostia.com/"; //hostname is usually localhost by default
$user = "valerij"; //insert the name of the user here
$pass = "real92"; //insert the password here
$database = "valerij_Race"; //insert name of database wherein table was exported
$table = "HS"; //insert the name of the table

Valerij
11-10-2007, 07:09 PM
What host do you use then :S?

majicassassin
11-10-2007, 08:09 PM
Sorry, don't know of any free ones that do PHP.