Help on Highscore Table

Discussion and feedback on Construct 2

Post » Sun Mar 04, 2012 9:13 pm

How to create high score table,
With Construct 2 AJAX / PHP WITH MYSQL OR PHP WITH TXT FILE
B
44
S
11
G
9
Posts: 154
Reputation: 20,888

Post » Sun Mar 04, 2012 10:11 pm

English is not my native language. Sorry for any mistakes and feel free to correct me if needed.
B
14
S
5
G
3
Posts: 110
Reputation: 3,225

Post » Mon Mar 05, 2012 10:10 pm

Not working..
-------------------------------
i create this php mysql database to post data but writes as invisible records..
------------------------------------------

<?php

$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="demo"; // Database name
$tbl_name="demo"; // Table name

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


$name = $HTTP_GET_VARS[name];
$hiscore = $HTTP_GET_VARS[hiscore];

// Insert data into mysql
$sql="INSERT INTO $tbl_name(name, hiscore)VALUES('$name', '$hiscore')";
$result=mysql_query($sql);

// if successfully insert data into database, displays message "Successful".
if($result){
echo "Successful";

}
else {
echo "ERROR";
}

// close connection
mysql_close();
?>
-----------------------------------------------------
and constuct 2 create 2 fields text box

and submit button with code...

AJAX | Request "http://localhost/score/score.php" (tag"")
-------------------------------------------------------

work but in mysql writes as invisible recordsSlice2012-03-05 22:13:39
B
44
S
11
G
9
Posts: 154
Reputation: 20,888

Post » Mon Mar 05, 2012 10:22 pm

But you're not passing the texts trough the URL!

Request this:

"http://localhost/score/score.php?name="&TextBoxObjectForName.Text&"&hiscore="&TextObjectForScore.Text

Attention on " and &, just change the bold text. ;)


Also i suggest you change

$name = $HTTP_GET_VARS[name];
$hiscore = $HTTP_GET_VARS[hiscore];

To

$name = $_GET['name'];
$hiscore = $_GET['hiscore'];

The var $HTTP_GET_VARS is deprecated in PHP (i know it's that wy on tuto, but believe me :) )
English is not my native language. Sorry for any mistakes and feel free to correct me if needed.
B
14
S
5
G
3
Posts: 110
Reputation: 3,225

Post » Mon Mar 05, 2012 10:59 pm

worked, Thank you very much
B
44
S
11
G
9
Posts: 154
Reputation: 20,888

Post » Mon Mar 05, 2012 11:37 pm

Why scores table are not automatized?? i mean we put a "score table" in a game we are working on and the score table do all the rest you know, nothig to code or start thinking to all thoses complicates stuffs...
B
32
S
9
G
6
Posts: 1,469
Reputation: 7,955

Post » Mon Mar 05, 2012 11:43 pm

because, all the scores from all users, should be stored in a server ... We can not be automatically ....
B
44
S
11
G
9
Posts: 154
Reputation: 20,888

Post » Tue Mar 06, 2012 4:00 am

@imothep85 we're going to soon start working on an Arcade plugin that will allow you to log high scores without any programming!

In the mean time if you want a high score system you will have to write some simple server side code like PHP to achieve it.
Image Image
Scirra Founder
B
125
S
37
G
25
Posts: 3,945
Reputation: 44,922

Post » Tue Mar 06, 2012 9:37 am

OUAAH great, thanks Tom
B
32
S
9
G
6
Posts: 1,469
Reputation: 7,955

Post » Tue Mar 06, 2012 8:18 pm

Scirra Developers is the best...
Once again, the Construct 2 is the best game engine.
The plugin will help all members to have their hiscore for games. NO PHP programming...
BRAVO, CONGRATULATIONS Slice2012-03-06 20:20:01
B
44
S
11
G
9
Posts: 154
Reputation: 20,888

Next

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 8 guests