Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Code Bounty: SL <-> PHP/SQL Data Storage System

Burke Prefect
Cafe Owner, Superhero
Join date: 29 Oct 2004
Posts: 2,785
11-03-2006 07:47
I have to admit. I'm a noob when it comes to things like php/sql. I learn by example. While I'm tinkering with php, I have some large-scale projects that are being held back by a lack of a working db system. So I'm asking for help.

My host has php/mysql. I run my own blogs, boards, and only do minor tinkering, and some direct db editing.

I need to be able to store various types of data from SL, namely...
- People who bought items from my vendors. So that later I can send them updates.
(I'm not trusting on-rez version checking in the event of another permissions bug)
- People's scores for a combat system I'm developing, along with other associated data.
- Active UUID keys for static emplacements throughout the grid so they can talk to eachother.
- Access Control List with varying access rights per member for authentication.
With help I can do this. With example code I can piece this together.
For this I'm willing to pay some actual cash. I don't have much, and I don't charge a limb for my products. Any examples or semi-completed systems for passing this kind of data back and forth would be greatly appreciated. :D

Needed: This Weekish, I can't move forward on some projects without this. Thanks.
_____________________
Ayrn Wake
Registered User
Join date: 7 Jan 2006
Posts: 39
11-03-2006 08:11
Easy enough to do, I managed to throw a database accessible by SL in a little less than 3 hours a few weeks back, what sort of bounty are you offering? I doubt I'd actually work on it for you (working on a combat system myself, and busy with a lot of things, but your other thing mentioned what the bounty was and this doesn't, but L$ can sway me over to working for you, lol).
Llauren Mandelbrot
Twenty-Four Weeks Old.
Join date: 26 Apr 2006
Posts: 665
11-03-2006 08:13
This has already been posted here, complete with source.:) Alas, I forget exactly where.:o
Burke Prefect
Cafe Owner, Superhero
Join date: 29 Oct 2004
Posts: 2,785
11-03-2006 08:26
I've seen a couple such examples coded in python, but i'd need php 4. I can't afford to switch hosting.

The bounty would be L$8k or some paypal amount under $30 on completion and testing.
_____________________
Llauren Mandelbrot
Twenty-Four Weeks Old.
Join date: 26 Apr 2006
Posts: 665
11-03-2006 09:35
Interesting. I`ve seen a few coded in php, but none in Python.
Dimentox Travanti
DCS Coder
Join date: 10 Sep 2006
Posts: 228
11-03-2006 09:55
the php side of things is easy. Just do a wrapper for sql
would be
http://yourdomain.com/sql.php?key=yourpasskey&q=your_sql_query
CODE

<?php
///take in the global passed var of
//key = your key to use some sort of security
//query
//start vars
$mysql_host ="localhost";
$mysql_user="root";
$mysql_pass = "somepass";
$mysql_dbname = "somedb";

//check for the key
if ($key != "yourpasskey"){
die("bad key");
}

if (!q) {
die("no Query");
}

if (!$link = mysql_connect('$mysql_host', '$mysql_user', '$mysql_password')) {
echo 'Could not connect to mysql';
exit;
}

if (!mysql_select_db('$mysql_dbname', $link)) {
echo 'Could not select database';
exit;
}

$sql = $q;
$result = mysql_query($sql, $link);

if (!$result) {
echo "DB Error, could not query the database\n";
echo 'MySQL Error: ' . mysql_error();
exit;
}

while ($row = mysql_fetch_assoc($result)) {
echo $row['foo'];
}

mysql_free_result($result);

?>



Theres ya Backend
simple and you can controll everything ingameside.
just send a httprequest and pasrse the return.


Not exactly how id do it, i dont like open sql in http post. But its the simplest and most flexable way.
_____________________
LSL Scripting Database - http://lsl.dimentox.com
Dimentox Travanti
DCS Coder
Join date: 10 Sep 2006
Posts: 228
11-03-2006 09:57
You could modify the sample code here for in game
http://www.lslwiki.com/lslwiki/wakka.php?wakka=llHTTPRequest
_____________________
LSL Scripting Database - http://lsl.dimentox.com
Burke Prefect
Cafe Owner, Superhero
Join date: 29 Oct 2004
Posts: 2,785
11-03-2006 10:06
I've seen those. I'll have to look at other php/sql stuff and see how to handle db stuff.
I was hoping for constructed examples with sql databases in the mix already.
_____________________
Dimentox Travanti
DCS Coder
Join date: 10 Sep 2006
Posts: 228
11-03-2006 10:19
The main thing about db is you need to figure out what you wanna store and what to name it.

A sql db is a table
DB:foo

TABLE:bar
___ID___|__NAME____|_LNAME______| __PRODUCT
___1____|FRED______|_FREDLY_____|__prod1


So to retrive it it would be

Select * from bar where product='prod1';

woudl give you all users and all data from the table who have prod 1
Its relitively simple to query. or if you just wanted first name replace * with name.
_____________________
LSL Scripting Database - http://lsl.dimentox.com
Burke Prefect
Cafe Owner, Superhero
Join date: 29 Oct 2004
Posts: 2,785
11-03-2006 10:23
Okay. And what would be a sane way to pass this table, or in this case just the UUIDs back to the product server?
_____________________
Dimentox Travanti
DCS Coder
Join date: 10 Sep 2006
Posts: 228
11-03-2006 10:42
one table
and make it UUID and Prodname
that should do it.

all youd do is pass a INSERT command to add them

insert into bar set uuid='uuid', prodname='prodname';


or to check if they have the product

select prodname from bar where uuid='uuid';

that will give back their valid products.
_____________________
LSL Scripting Database - http://lsl.dimentox.com
Dimentox Travanti
DCS Coder
Join date: 10 Sep 2006
Posts: 228
11-03-2006 10:45
http://dev.mysql.com/doc/refman/5.0/en/insert.html
_____________________
LSL Scripting Database - http://lsl.dimentox.com
BamBam Sachertorte
floral engineer
Join date: 12 Jul 2005
Posts: 228
11-03-2006 20:37
Zarf Vantongerloo did a file-based PHP storage system. He posted about it here .