Go Back   SL Forums > Resident Forums > Content Creation > Scripting Tips
Welcome, Al Supercharge.
You last visited: Yesterday at 11:53 PM
User CP GUIDELINES - please read before posting New Posts Quick Links Log Out


Reply
Thread Tools Search this Thread Display Modes
Old 06-22-2007, 08:01 AM   #1
Kyle Kamachi
Registered User

Join Date: Feb 2007
Posts: 16
Send a message via AIM to Kyle Kamachi Send a message via MSN to Kyle Kamachi Send a message via Yahoo to Kyle Kamachi
Exclamation MySQL + llHTTPRequest Does Not Post To My Databse?

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();
?>

Last edited by Kyle Kamachi : 06-22-2007 at 07:22 PM.
Kyle Kamachi is offline Report Bad Post   Reply With Quote
Old 06-22-2007, 09:17 AM   #2
Squirrel Wood
Nuteater. Beware!

Join Date: Jun 2006
Location: Bigga tree over there.
Posts: 409
Exclamation Caution!

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.
Squirrel Wood is offline Report Bad Post   Reply With Quote
Old 06-22-2007, 11:50 AM   #3
nand Nerd
Flexi Fanatic

Join Date: Oct 2005
Location: UK
Posts: 422
Change the following
Quote:
Originally Posted by Kyle Kamachi
$query = "INSERT INTO accounts VALUES ('', $name, $key)";

mysql_query($query);


to
[PHP]
$query = "INSERT INTO accounts (name, key) VALUES ('$name', '$key')";

mysql_query($query) or die(mysql_error());
[/PHP]

Where the values "accounts" is your database name, "name" and "key" are fields in your database.
nand Nerd is offline Report Bad Post   Reply With Quote
Old 06-22-2007, 07:30 PM   #4
Kyle Kamachi
Registered User

Join Date: Feb 2007
Posts: 16
Send a message via AIM to Kyle Kamachi Send a message via MSN to Kyle Kamachi Send a message via Yahoo to Kyle Kamachi
Ok that did not work...

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

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 is offline Report Bad Post   Reply With Quote
Old 06-22-2007, 07:41 PM   #5
Kyle Kamachi
Registered User

Join Date: Feb 2007
Posts: 16
Send a message via AIM to Kyle Kamachi Send a message via MSN to Kyle Kamachi Send a message via Yahoo to Kyle Kamachi
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

Last edited by Kyle Kamachi : 06-22-2007 at 08:05 PM.
Kyle Kamachi is offline Report Bad Post   Reply With Quote
Reply



Posting Rules
You may post new threads
You may post replies
You may post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump



All times are GMT. The time now is 03:15 AM.


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright 2002-2007 Linden Lab