koen500Join Date: 2011-02-23 Post Count: 2277 |
Can someone give me an example of a script in PHP/HTML that handles a HttpRequest coming from Roblox, and makes use of a MySQL database? |
|
koen500Join Date: 2011-02-23 Post Count: 2277 |
Bump. |
|
Dr01d3k4Join Date: 2007-10-11 Post Count: 17916 |
"script in ...HTML"
What?
HTML has nothing to do with this. |
|
As8DJoin Date: 2009-12-24 Post Count: 2907 |
Do PHP - though people who wuv othr stuff might nawt liek eet; here's exampleh:
Your website server, running PHP & MySQL database (> and < replaced with gt and lt):
_____________________________________________________________
lt?php
$yourVariable = addslashes($_GET["yourParam"]);
$db = mysql_connect("localhost", "yourusername", "yourpwarzwurd");
mysql_select_db("nameOfDatabase", $db);
if (is_numeric($yourVariable)) {
$exist = mysql_query("SELECT Name, Content, ID FROM YourCollection WHERE ID = $yourVariable");
if ($exist) {
$exist = mysql_fetch_array($exist);
}
if ($exist) {
echo "{name = '" . addslashes($exist["Name"]) . "', Content = '" . addslashes($exist["Content"]) . "', ID = $exist[ID]}";
} else {
echo "Error: Could not fetch information.";
}
} else {
echo "Error: Invalid parameter.";
}
mysql_close($db);
?gt
_____________________________________________________________
Your roblox server, Lua:
_____________________________________________________________
local http = game:service("HttpService")
function getContent(id)
local content = http:GetAsync("http://yourdomain.dot/yourfile.php?yourParam=" .. (tonumber(id) or 1))
if loadstring("return " .. content) then
return loadstring("return " .. content)()
else
return content
end
end
print(getContent(1))
_____________________________________________________________
Since this is just an example - untested, no idea if it works - I will let you figure out what happens where. Read up on dez PHP and MySQL.
- As, yo dun mess wit databases. dem databases mess wit u, doed. |
|
|
I can put a script in HTML!
Replace [] with , because ROBLOX thinks I'm trying to XSS.
[script]alert("Amg, script in HTML!!!1");[/script]
~LuaWeaver; Programmer, gamer, developer. |
|
koen500Join Date: 2011-02-23 Post Count: 2277 |
Thank you for the example, it will be very useful when managing my database! |
|
|
Apart from the fact that the mysql_* family of functions are depreciated and are due to be removed from future versions of PHP. You should use the mysqli* functions or PDO instead.
I highly doubt you need such a system anyway. |
|
jode6543Join Date: 2009-06-16 Post Count: 5363 |
Also, addslashes should be replaced with mysql[i]_real_escape_string, since addslashes is not designed to be used for security or sanitization purposes.
~Jode |
|
koen500Join Date: 2011-02-23 Post Count: 2277 |
What do I do wrong when it returns the code of the .php file? |
|
jode6543Join Date: 2009-06-16 Post Count: 5363 |
That means you either don't have PHP installed or haven't configured Apache (or whatever you're using) to use it.
~Jode |
|
xtomtom75Join Date: 2011-12-19 Post Count: 5082 |
I'm a scripter helper, helping you by telling you... GO SEE THAT WIKI :3 joke lol |
|
koen500Join Date: 2011-02-23 Post Count: 2277 |
Maybe there's some easyer hosting site than heliohost, any suggestions? Because I do not know what to do with it anymore. |
|
AlyteJoin Date: 2011-10-24 Post Count: 10090 |
Google AppEngine |
|
koen500Join Date: 2011-02-23 Post Count: 2277 |
It is not free. |
|
devTreeJoin Date: 2012-12-26 Post Count: 2596 |
In AS8D's script, I thought he was saying sexist without getting the post blocked by the filter or something.
Sorry, don't know much JavaScript and stuff like that. |
|
koen500Join Date: 2011-02-23 Post Count: 2277 |
Is there anyone willing to make a very full tutuorial on how to do such things? |
|
|
What is it you're wanting to do? |
|
koen500Join Date: 2011-02-23 Post Count: 2277 |
I want to make a ban system, cross place. |
|
cntkillmeJoin Date: 2008-04-07 Post Count: 49450 |
Why does everyone use MySQL extension on PHP but not MySQLi or PDO?
Apparently most hosts are upgrading and MySQL is going to be removed. |
|
koen500Join Date: 2011-02-23 Post Count: 2277 |
Well, I only know MySQL, that is why. But I know of none of them how they work. |
|
cntkillmeJoin Date: 2008-04-07 Post Count: 49450 |
I learned PDO and MySQLi in a day (not on the same day, of course)
I mean I'm not great at it but I can do what I need to do, anytime I need help I would search something like: "mysqli equivalent of mysql_whatever" |
|
koen500Join Date: 2011-02-23 Post Count: 2277 |
What hosting site do you use? |
|
Dr01d3k4Join Date: 2007-10-11 Post Count: 17916 |
Using Django, a cross place ban system is easy. This is a very simple one I made in 10 minutes (though it's not complete - need django specific code like project settings, etc and doesn't support unbanning of users, having timed bans, and any user can submit a post). Also because it's Django, you get a very nice admin interface you can manage all the bans from.
pastebin/RUm2TzbM |
|
AlyteJoin Date: 2011-10-24 Post Count: 10090 |
>It is not free.
Yes it is
*facenuke* |
|
koen500Join Date: 2011-02-23 Post Count: 2277 |
The storage is not free. |
|