[ANET] HTTP Send Score

Posted By: Rasch

[ANET] HTTP Send Score - 10/24/09 17:32

Hi iīve tried to send scores to my mysql server. Everything works and it also says that itīs sended. But nothing get written in the database what did i wrong?

I took the template code. The sql server runs on my own machine and i can see the php pages. but they just give me back -1

I created the database like in the manual and also created the needed rows and so on. And how i said it says that itīs "Gesendet" but nothing changes in the database.

Code:
function send()
{
	
	player_points ī+= random(49)+5;

	STRING* http_url = "#100";
	STRING* http_data = "#250";
	STRING* http_result = "#10";
	var httpID;

	//URL:
	str_cpy(http_url,"http://localhost/php_scripts/game_to_onlinelist.php");
	//Data:
	inkey_playername.flags = VISIBLE;
	inkey(http_playername);
	inkey_playername.flags &= ~VISIBLE;

	str_cpy(http_data,"svn=");
	str_cat(http_data,http_playername);
	str_cat(http_data,"&pw=");
	str_cat(http_data,player_points);

	httpID = http_post(http_url,http_data);
	while(http_get_status(httpID) == 0) {wait(1);}
	if(http_get_status(httpID) == 1)
	{
		http_get_result(httpID,http_result);
		error("Gesendet!");
	}
	else 
	{
		error("Nicht gesendet!");
	}

	http_free(httpID);
}


Posted By: Anonymous

Re: [ANET] HTTP Send Score - 10/24/09 19:27

maybe there is an error in your php file.
Posted By: Rasch

Re: [ANET] HTTP Send Score - 10/24/09 19:46

This php file is from the creator of anet. I cant believe it depends on the .php file. Do you know php?

What would be the best way to write the playername and the score in a mysql database? Do you have some example code?
Posted By: Anonymous

Re: [ANET] HTTP Send Score - 10/24/09 21:04

I will post an example tomorrow, cause i am not at the pc now. Whats inside the php file, if you are allowed to post it?
Posted By: Rasch

Re: [ANET] HTTP Send Score - 10/24/09 21:41

Omg i found out what the problem was.

In the php script there was:

$change = "UPDATE gamelist Set servername = '$servername', password = '$pw',
gametyp = '$gametyp', map = '$map', serverip = '$serverip',
lastupdate= '$timestamp', players='$players', ping='$ping',
id = '$id' WHERE row = '$entry_row'";
mysql_query($change);

and i changed to

mysql_query("INSERT INTO gamelist (row, servername, password, id) VALUES ('$entry_row', '$servername', '$pw', '$id')");

the update function didnt work it had to be inputed
Posted By: Dark_samurai

Re: [ANET] HTTP Send Score - 10/25/09 10:01

Why do you use the internet-serverlist php code for an online highscore?

Btw. if you want to create an internet-serverlist, use the template and read through the howto. Then there should be no problem.
Posted By: Rasch

Re: [ANET] HTTP Send Score - 10/25/09 20:21

What else shall i use? I need to save the score anywhere.

I tried the template but why ever it says that i cant use this template with my anet version. Itīs the same termplate file whcih was sended with the professional edition.
Posted By: Dark_samurai

Re: [ANET] HTTP Send Score - 10/26/09 09:55

You should write such a snippet yourselfe. Creating a online highscore in php is really easy. If you need help, you can ask on a php forum or here.

The template tells you that you are not allowed to use it? That's strange, can you post a screenshot?
Posted By: MichaelGale

Re: [ANET] HTTP Send Score - 10/27/09 13:03

And while you are at it, read a good article about SQL injection attacks.
Posted By: Rasch

Re: [ANET] HTTP Send Score - 10/28/09 20:00

i got it but have no defend against sql injections at the moment but i will see what i can do laugh

Thanks
Posted By: MTD

Re: [ANET] HTTP Send Score - 12/27/09 20:26

Hi everyone. Trying to create a high-score table from game varible.
Maybe there is a tutorial how to do it? (3DGS + ANET + PHP + SQL = RESULT IN WEB-PAGE)
Posted By: Dark_samurai

Re: [ANET] HTTP Send Score - 12/28/09 10:35

The best would be to read through the http section of the ANet manual. Then you will now how you can call a php script with ANet.
After that you should read a small php+sql tutorial (there are thousands on the internet).

One thing I should mention: To return data from the php script to the Lite-C code, you only have to print the data with the echo ""; function (in the php script). All that was printed by your php script is then returned by http_get_result().

Please notice that this won't parse a html code!
Posted By: MTD

Re: [ANET] HTTP Send Score - 12/28/09 14:03

Thank You for the information.
Will try to make something (Online High score table) crazy
Posted By: Tai

Re: [ANET] HTTP Send Score - 01/05/10 23:32

Does the demo of ANet allow you to use the HTTP functions? It would be nice to test those...
Posted By: Dark_samurai

Re: [ANET] HTTP Send Score - 01/06/10 09:12

Currently not. The new Demo (in development) will offer you that.
© 2024 lite-C Forums