Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Database? / Send Data

Nathan Babcock
Registered User
Join date: 5 May 2006
Posts: 47
06-15-2007 22:58
Hi,

I have objects (unlimited numbers) that will be rezzed inworld. What I need is a functionality for these objects to send their UUID and (the text in the description field) to a website database (SQL or php).

Is this possible? Could someone please help me out?

Thank you!
Nathan
AnnMarie Otoole
Addicted scripter
Join date: 6 Jan 2007
Posts: 162
06-15-2007 23:20
Here are some locations with helpful information.

http://rpgstats.com/wiki/index.php?title=ExamplellHTTPRequest

and how I inteface the php to MySQL on my website host - YMMV.

http://faq.1and1.com//scripting_languages_supported/php/4.html
Nathan Babcock
Registered User
Join date: 5 May 2006
Posts: 47
06-16-2007 00:02
Hi,

I keep on getting a parse error message in secondlife pointing to the .php file. Whats it doing wrong?

Nathan
Nathan Babcock
Registered User
Join date: 5 May 2006
Posts: 47
06-16-2007 00:47
Hello,

Thanks for the pointers. i finally fixed the parse error. I do have a question though. The examples above in the link basically pases on the agent key when touched. Is there a way to pass on the object key instead? Kinda like registering the objects UUID instead of tracking which agent touched the object.

Nathan
Nathan Babcock
Registered User
Join date: 5 May 2006
Posts: 47
06-16-2007 01:09
LOL - sorry. The more I goof the more I answer my own questions. But now I am done. I cant edit the script to actually build a table with a web interface to view the data sent to the PHP "secondcom.php" file.

Nate
Nathan Babcock
Registered User
Join date: 5 May 2006
Posts: 47
06-16-2007 01:31
What does this line mean?

MYSQL_QUERY( "INSERT INTO $table VALUES('1and1','info@1and1.com')";);

is 1and1 the field name? and the [email]info@1and1.com[/email] the value itself?
Roy Flanagan
Registered User
Join date: 10 Feb 2007
Posts: 8
06-16-2007 02:16
From: Nathan Babcock
What does this line mean?

MYSQL_QUERY( "INSERT INTO $table VALUES('1and1','info@1and1.com')";);

is 1and1 the field name? and the [email]info@1and1.com[/email] the value itself?


As you are online I hope you are checking. I think TBH that statement wont work as it's only saying values not the actual fields it has to insert in.
As '1and1' is a value and 'info@1and1.com' is too. I have replied to another post with a similair mysql statement. Take a look at it and I hope it clears up :)

/54/9e/191147/1.html#post1553225

Good luck.

PS. Mind sharing the info on SL interaction with PHP? As I need it very mucho and I've been trying to do it through email but for some reason I cant get PHP to read my email (Pffft security -.-)
EDIT: checked the links earlier in this topic... :D
Nathan Babcock
Registered User
Join date: 5 May 2006
Posts: 47
06-16-2007 06:37
Thanks for all the help I have received - totally appreciated. I am able to send valued from SL to PHP on my webserver and get it printed back in SL. I am also able to store the data on MqSQL tables now as well. What I am stuck on is actually listing the data on a webpage. Here is the code given from an example, but it only draws the table (actual row data is nonexsistent) what is wrong here???

<?php
/* Start of PHP3 Script */
/* Data of SQL-server */
$server= "216.247.255.141"; /* Address of 1&1 database server */
$user= "user"; /* Database username */
$password= ".........."; /* Database Password */
$database= "sk..........."; /* name of database */
$table= "o......."; /* Name of table, you can select that */

MYSQL_CONNECT($server, $user, $password) or die ( "<H3>Server unreachable</H3>";);
MYSQL_SELECT_DB($database) or die ( "<H3>Database non existent</H3>";);
$result=MYSQL_QUERY( "SELECT * FROM $table order by name";);

/* Output data into a HTMl table */
echo "<table border=\"1\" align=center width=\"50%\">";
echo "<tr>";
echo "<div color=\"#ffff00\">";
while ($field=@mysql_fetch_field($result)) {
echo "<th>$field->owner</A></th>";
}
echo "</font></tr>";
while ($row=@mysql_fetch_row($result)) {
echo "<tr>";
for($i=0; $i<@mysql_num_field($result); $i++) {
echo "<td align=center>$row[$i]</td>";
}//for
echo "</tr>\n";
}//while
echo "</div></table><BR><BR>";

/* Close SQL-connection */
MYSQL_CLOSE();
?>


Nathan
Nathan Babcock
Registered User
Join date: 5 May 2006
Posts: 47
06-16-2007 06:38
The problem seems to be coming from this while statement:

while ($row=@mysql_fetch_row($result)) {
echo "<tr>";
for($i=0; $i<@mysql_num_field($result); $i++) {
echo "<td align=center>$row[$i]</td>";

Nate
Roy Flanagan
Registered User
Join date: 10 Feb 2007
Posts: 8
06-16-2007 07:15
This is what I made of it
From: someone

<?php
/* Start of PHP3 Script */
/* Data of SQL-server */
$server= "216.247.255.141"; /* Address of 1&1 database server */
$user= "user"; /* Database username */
$password= ".........."; /* Database Password */
$database= "sk..........."; /* name of database */
$table= "o......."; /* Name of table, you can select that */

MYSQL_CONNECT($server, $user, $password) or die ( "<H3>Server unreachable</H3>";);
MYSQL_SELECT_DB($database) or die ( "<H3>Database non existent</H3>";);
$result=MYSQL_QUERY( "SELECT * FROM $table order by name";);

/* Output data into a HTML table */
echo "<table border=\"1\" align=center width=\"50%\">";
echo "<div color=\"#ffff00\">";
echo "<tr>";
while ($field=@mysql_fetch_field($result))
{
echo "<th>$field->owner</th>";
}
echo "</tr>";
while ($row=@mysql_fetch_row($result)) {
echo "<tr>";
for($i=0; $i< @mysql_num_fields($result); $i++) { //-----------missing an S behind fields-------------
echo "<td align=center>$row[$i]</td>";
}//for
echo "</tr>\n";
}//while
echo "</div></table><br /><br />";

/* Close SQL-connection */
MYSQL_CLOSE();
?>

You had mysql_num_field instead of mysql_num_fields... that might be the problem for the rest I changed your closing order for the Div's etc. as you opened one tage before the other but closed it before again as well wich should not work. Furthermore I removed a </font> tag and a </A> tag as you haven't opened those.

I made the <BR> tags XHTML valid by closing them too and I put everything to lower case (make lower case a habit plz)

EDIT:
Tip to you and/or other people of this forum. For codes like PHP use quote tags. Or even better use a pastebin (Google is your friend) that keeps indenting and makes code way easier to read :)

EDIT2:
Just occured to me. Why do you use PHP3? As PHP5 is out and most servers are running PHP4 or even PHP5 already. My dad's site used to work fine until they upgraded from PHP4 to PHP5. Now he has a fake PHP4 config wich won't last too long either. This might be a part of your problem ;)
Nathan Babcock
Registered User
Join date: 5 May 2006
Posts: 47
06-16-2007 07:36
Thanks a bunch! I know zero to nothing about coding! LOL. I am totally trial and erroring my way through this (the best way to learn I hope).

Here is where I am at. I updated the script that you posted but once again. No errors, just a table with no columns. I tried to echo "hello"; after each line to pinpoint the issue. One again it is at that while loop.

My mysql table right now has 3 fields (key, owner, title) and 1 row of data. These are just not populating. i am so mind boggled.... X|

Nate
Roy Flanagan
Registered User
Join date: 10 Feb 2007
Posts: 8
06-16-2007 07:47
I suggest trying www.w3schools.com as a guide for PHP (For learning the basics) and try HTML there as well so you know about tables. It'l help a bunch.

I might be able to help more later because I got homework to do :(