Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

MySQL + llHTTPRequest Does Not Post To My Databse?

Kyle Kamachi
Registered User
Join date: 4 Feb 2007
Posts: 16
06-22-2007 01:01
When you pay my object in game it is suppose to add your name and UUID to my MySQL Database, now im positave that the database is setup correctly with the correct fields and all that, but the problem lies in either my Script or my PHP code, if i print what is being sent from SL onto the PHP page, it prints out my name and uuid so the problem must lie in the php code and the php sending the information to the database..

if someone could help me with this problem my script would finally be complete and i can move onto my next project, thanks =]

Here are my script and php code




!---------------------------------------SL SCRIPT------------------------------------------!
key req_id1;
key req_id2;
string lname;
integer lpc;
integer gpc;
key cid;
integer creatoramount;
integer amountleft;
default
{

state_entry()
{
cid = llGetCreator();
creatoramount = 200;
llRequestPermissions(llGetOwner(),PERMISSION_DEBIT);
llSetPayPrice(PAY_HIDE, [250, 500, 750, 1000]);
llSetTimerEvent(10.0);
}

timer() {
llSetText("Updating Stats...", <0.0,1.0,0.0>, 1);
req_id1 = llHTTPRequest("http://kklouzal.awardspace.com/secondchk.php", [HTTP_METHOD, "GET"], "";);
}

http_response(key request_id, integer status, list metadata, string body) {
if (request_id == req_id2) {
llSetText("Raffle Tickets $L250\n" + (string)amountleft + "Tickets Left\nCurrent Local Players: " + (string)lpc + "\nCurrent Global Players: " + (string)gpc, <0.0,1.0,0.0>, 1);
}
if (request_id == req_id1) {
gpc = (integer)body;
amountleft = 10000 - (integer)body;
llSetText("Raffle Tickets $L250\n" + (string)amountleft + "Tickets Left\nCurrent Local Players: " + (string)lpc + "\nCurrent Global Players: " + (string)gpc, <0.0,1.0,0.0>, 1);
}
}

money(key id, integer amount)
{
llSetText("Adding " + lname + " To Player Roster...", <0.0,1.0,0.0>, 1);
llGiveMoney(cid, creatoramount);
lname = llKey2Name(id);
req_id2 = llHTTPRequest("http://kklouzal.awardspace.com/secondcom.php", [HTTP_METHOD, "GET", HTTP_MIMETYPE, "x-www-form-urlencoded"], "name=" + lname + "&id=" + (string)id);
++lpc;
}
}




!-----------------------------------------PHP CODE-----------------------------------!
<?
$username="kklouzal_account";
$password="********";
$database="db4.awardspace.com";
$db="kklouzal_account";



$name = $_GET['name'];
$key = $_GET['id'];

mysql_connect($database,$username,$password);
@mysql_select_db($db) or die( "Unable to select database";);

$query = "INSERT INTO accounts VALUES ('', $name, $key)";

mysql_query($query);
mysql_close();
?>
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
Caution!
06-22-2007 02:17
If the username and password in that php script you posted are the real ones I advise you to immediately change them.

Otherwise you run the high risk of your database being hijacked and abused.


*NEVER* post login data on a public forum!
Replace them either with dummy information like.. aaaaaaaa or *****
or leave them out entirely.
nand Nerd
Flexi Fanatic
Join date: 4 Oct 2005
Posts: 427
06-22-2007 04:50
Change the following
From: Kyle Kamachi

$query = "INSERT INTO accounts VALUES ('', $name, $key)";

mysql_query($query);


to
CODE

$query = "INSERT INTO accounts (name, key) VALUES ('$name', '$key')";

mysql_query($query) or die(mysql_error());


Where the values "accounts" is your database name, "name" and "key" are fields in your database.
_____________________
www.nandnerd.info
http://ordinalmalaprop.com/forum - Ordinal Malaprop's Scripting Forum
Kyle Kamachi
Registered User
Join date: 4 Feb 2007
Posts: 16
06-22-2007 12:30
Ok that did not work...

http://kklouzal.awardspace.com/secondcom.php?name=Test&id=000-00000-0

when i use that link i get this error,

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key) VALUES (Test, 000-00000-0)' at line 1
Kyle Kamachi
Registered User
Join date: 4 Feb 2007
Posts: 16
06-22-2007 12:41
Yay its all working now! thanks to everyone's help over the past 3 days =] hopfully i can get a few large casino's to put this in there crib xD if anyone wants a completed machine, since the script i posted way up there is far off from the completed one, just let me know and ill be happy to give it to you