-
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 ?
-
-
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?
-
Hi,
if you see contents of the phpfile rather than results, the server does not support php
Musicman
-
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>
-
-
Official FK nice guy and MOD
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
-
-
Official FK nice guy and MOD
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?
-
Thats what it says in PHP file at least..
-
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
-
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
-
Official FK nice guy and MOD
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
-
Its Index file and Html/text
And I dont have any private messages :S
-
Official FK nice guy and MOD
Look again.
Is it an html file or a php file
-
Official FK nice guy and MOD
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|