Author Topic: GetURL...  (Read 1859 times)

0 Members and 1 Guest are viewing this topic.

Offline spkka

  • Camper
  • ***
  • Posts: 469
GetURL...
« on: May 05, 2007, 03:11:41 am »
if ((PLAYER_STATS_ON= 1) and ( Text = '!stats' )) then
   begin
      Response:= GetURL(PLAYER_STATS_URL+'?name='+HTTPEncode(Name));
      ResponseLines:= xsplit(Response,chr(13));
      for i:=0 to ArrayHigh(ResponseLines) do       SayToPlayer(NametoID(Name),ResponseLines);   
   end;



//
Should work?

this is in const:
PLAYER_STATS_URL = 'http://localhost/Zitrostats/PlayerStats.php';
PLAYER_STATS_ON = 1
« Last Edit: May 05, 2007, 03:14:58 am by spkka »

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: GetURL...
« Reply #1 on: May 05, 2007, 03:21:42 am »
It should, assuming you have a web server running on localhost with that same PHP script path.

Offline spkka

  • Camper
  • ***
  • Posts: 469
Re: GetURL...
« Reply #2 on: May 05, 2007, 03:42:14 am »
yes i have...  I changed something in the script  of zitrostats  so it updates the logs to the index.php now, which works....

Only this line of code doesn't return anything from me

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: GetURL...
« Reply #3 on: May 05, 2007, 10:38:31 pm »
Put in a WriteLn(Response); before you use xsplit and see if its returning stuff

Offline spkka

  • Camper
  • ***
  • Posts: 469
Re: GetURL...
« Reply #4 on: May 06, 2007, 07:30:44 pm »
returns this:
(02:29:08) Sorry could not find your stats :(

from this

<?php

define('INSTATS',true);
require('include/global.inc.php');

if (isset($_GET['name']) && trim($_GET['name']) != '')
{
   $name = $_GET['name'];
   if(!$player = $sql->fetcharray($sql->query("
      SELECT
         `points`,
         `kills`,
         `deaths`,
         `selfkills`,
         `last`
      FROM `$options[SQL_TABPREFIX]players`
      WHERE `player`='".addslashes($name)."'
      LIMIT 1
      "))) {
      die ('Sorry could not find your stats :(');

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: GetURL...
« Reply #5 on: May 06, 2007, 08:06:12 pm »
the first script seems ok

The php script is like a pain in the ass, is it yours? I would suggest not coding everything in a single call like it does there so it's much easier to develop it. To make sure what's wrong I would first execute the query from some sql console or something, I guess you should have. Of course you should set the player name to the name you are testing. That way you make sure the problem isn't somewhere else. If it works fine I would rewrite that php code like this:

Code: [Select]
define('INSTATS',true);
require('include/global.inc.php');

if (isset($_GET['name']) && trim($_GET['name']) != '')
{
   $name = $_GET['name'];
   $query = $sql->query("SELECT
         `points`,
         `kills`,
         `deaths`,
         `selfkills`,
         `last`
      FROM `$options[SQL_TABPREFIX]players`
      WHERE `player`='".addslashes($name)."'
      LIMIT 1");

   $player = $sql->fetcharray($query);

   if(!$player) {
      die ('Sorry could not find your stats ');

It seems like the same, but I'm not really sure with the "if (!$player = $sql->fet......" part. I don't know if it's right the way it was writen.
urraka

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: GetURL...
« Reply #6 on: May 06, 2007, 08:18:33 pm »
returns this:
(02:29:08) Sorry could not find your stats :(
Well then its not a problem with GetURL, its your script improperly coded.

Offline KeYDoN

  • Major
  • *
  • Posts: 60
Re: GetURL...
« Reply #7 on: May 07, 2007, 02:56:11 pm »
do
WriteLn('Name: ' + Name);

im quite sure its empty^^

Offline spkka

  • Camper
  • ***
  • Posts: 469
Re: GetURL...
« Reply #8 on: May 07, 2007, 03:29:25 pm »
indeed its empty

Offline KeYDoN

  • Major
  • *
  • Posts: 60
Re: GetURL...
« Reply #9 on: May 07, 2007, 03:55:40 pm »
well add the line at the begining of the function:
Name:=IdToName(ID);

and declare the var Name:string; if needed^^