if(!empty($_GET['action']) && !empty($_GET['user']) && !empty($_GET['key']) && !empty($_GET['email']) && !empty($_GET['password'])): // if key data exists
switch($_GET['action']):
//athenticate game developer return and high score
case 'authenticate':
$db = new PDO('mysql:host=localhost;dbname=xxxx', 'xxxx', 'xxxx');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
$st = $db->prepare("SELECT * FROM `game_developers_games` WHERE `id` = :gameid AND `developer_id`=:user AND `key`= :key AND `developer_active` = '1'"); // need to filter for next auction
$st->bindParam(':user', $_GET['user']); // filter
$st->bindParam(':key', $_GET['key']); // filter
$st->execute();
$r = $st->fetch(PDO::FETCH_ASSOC);
Here's the script the game developer will have to add to their game to get the data when the game loads. Found this on another stackoverflow question but it's not working.
<script>
$.getJSON("https://www.gamerholic.com/gamerholic_api/db_api_v1.php? user=1&key=6054abe3517a4da6db255e7fa27f4ba001083311&gameid=1&action=authenticate", function () {
alert("aaa");
Can you be more specific by "not working"?
This here looks like it'll be a problem:
PHP Code:
$st = $db->prepare("SELECT * FROM `game_developers_games` WHERE `id` = :gameid AND `developer_id`=:user AND `key`= :key AND `developer_active` = '1'"); // need to filter for next auction $st->bindParam(':user', $_GET['user']); // filter $st->bindParam(':key', $_GET['key']); // filter $st->execute();
You have specified 3x bound fields, but only given it 2x parameters to bind. It is missing the :gameid.
I'd assume that the PDO execute will be. . . unhappy about that.
Also, if that developer_active is an integer, don't wrap it in apostrophes. Weak datatype handling is pretty much a MySQL exclusive "feature" (if you can call it that), which can be disabled at any time.
I assumed as well that the code is incomplete since you are missing the endswitch and endif calls.
<script>
$.getJSON("https://www.gamerholic.com/gamerholic_api/db_api_v1.php? user=1&key=6054abe3517a4da6db255e7fa27f4ba001083311&gameid=1&action=authenticate", function () {
alert("aaa");
});
</script>
The above code is jQuery and so requires the jQuery library to be attached to the page. The space before the word user also needs to be removed.
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
Can you be more specific by "not working"?
This here looks like it'll be a problem:
PHP Code:
$st = $db->prepare("SELECT * FROM `game_developers_games` WHERE `id` = :gameid AND `developer_id`=:user AND `key`= :key AND `developer_active` = '1'"); // need to filter for next auction
$st->bindParam(':user', $_GET['user']); // filter
$st->bindParam(':key', $_GET['key']); // filter
$st->execute();
You have specified 3x bound fields, but only given it 2x parameters to bind. It is missing the :gameid.
I'd assume that the PDO execute will be. . . unhappy about that.
Also, if that developer_active is an integer, don't wrap it in apostrophes. Weak datatype handling is pretty much a MySQL exclusive "feature" (if you can call it that), which can be disabled at any time.
I assumed as well that the code is incomplete since you are missing the endswitch and endif calls.
Thanks for catching that error, I made the fix but I'm still not able to get the json results.
if(!empty($_GET['action']) && !empty($_GET['user']) && !empty($_GET['key']) && !empty($_GET['gameid'])): // if key data exists
switch($_GET['action']):
//athenticate game developer return play fee and high score
case 'authenticate':
$db = new PDO('mysql:host=localhost;dbname=xxxx', 'xxxx', 'xxxx');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
$st = $db->prepare("SELECT * FROM `game_developers_games` WHERE `id` = :gameid AND `developer_id`=:user AND `API_KEY`= :key AND `developer_active`= 1"); // need to filter for next auction
$st->bindParam(':user', $_GET['user']); // filter
$st->bindParam(':key', $_GET['key']); // filter
$st->bindParam(':gameid', $_GET['gameid']); // filter
case 'athenticate_user':
$db = new PDO('mysql:host=localhost;dbname=xxxx', 'xxxx', 'xxxx');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
$st = $db->prepare("SELECT * FROM `ttourmember` WHERE `email` = :email AND `password` = :password AND `isactive`='Y'");
$st->bindParam(':email', $_GET['email']); // filter
$st->bindParam(':password', $_GET['password']); // filter
$st->execute();
$r = $st->fetch(PDO::FETCH_ASSOC);
if(empty($_GET['token']) || $_GET['token'] == '0000' || $st->rowCount() == 0 ): // Return Error if Token Doesn't exist or no db result
$return = array('DBA_id'=>'0000');
echo json_encode($return);
else:
Does it work properly without the Javascript? I will always assume the problem is with the JS until its been checked out as being a PHP issue. Put that full url directly into the browser to see what it replies with.
Does it work properly without the Javascript? I will always assume the problem is with the JS until its been checked out as being a PHP issue. Put that full url directly into the browser to see what it replies with.
Thank you sir you solved my problem. Not directly, I still doesn't work in javascript even though I get the results on the direct link.
I'll just have the game developers use their preferred method to get it from that page.