I mean this topic sorry.. So i will follow to not fill up this topic with a lot of unuseful messages.. if you dont think it belongs here feel free to move it
i have an extension that they passed me, and i would like in that extension.. after a room is created to put that room into the database.. this is what i have:
Code: Select all
/*
* SmartFoxServer PRO
* Simple Extension Example
* v 1.0.0
*
* (c) 2005 gotoAndPlay()
*
*
* Extensions Overview:
* -----------------------------------------------------------------
* Every extension must implement four basic methods:
*
* init(), destroy(), handleRequest(), handleInternalEvent()
*
* init() It's the initialization point of the extension
* This method is invoked by the server on the extension as soon as it is loaded
* You can put here all your initialization code.
*
* destroy() This method is called by the server when the extension is going to be destroyed
* You should always put in this method the necessary code to release the resources
* you were using like setInterval(s), database connections etc...
*
* handleRequest() This method receives the client requests
*
* handleInternalEvent() Handles internal server events. Events are:
*
* userJoin when a user joins the room / zone
* userExit when a user exits a room
* userLost when a user disconnects
* newRoom a new room was created in the zone
* roomLost a room was destroyed in the zone
* loginRequest a custom login request arrived
*
*/
/*
* Initializion point:
*
* this function is called as soon as the extension
* is loaded in the server.
*
* You can add here all the initialization code
*
*/
function init() {
trace("Hello from the Simple Extension Example!");
}
/*
* This method is called by the server when an extension
* is being removed / destroyed.
*
* Always make sure to release resources like setInterval(s)
* open files etc in this method.
*
* In this case we delete the reference to the databaseManager
*/
function destroy() {
trace("Bye bye!");
}
/*
*
* Handle Client Requests
*
* cmd = a string with the client command to execute
* params = list of parameters expected from the client
* user = the User object representing the sender
* fromRoom = the id of the room where the request was generated
*
*/
function handleRequest(cmd, params, user, fromRoom, roomObj) {
if (cmd == "double") {
var response = {};
response.nombre = [];
for (var i = 0; i<params.nombre.length; i++) {
var n = params.nombre[i];
response.nombre[i] = n;
}
function salvar() {
insca = new LoadVars();
insca.cNombre = n
insca.sendAndLoad("insertarcasa.php", insca,"POST");
insca.onLoad = function() {
if(this.statuss == "ok") {
trace("Insertada");
} else if(this.statuss == "ko") {
trace("Error");
}
}
}
response.creo = [];
response.iderom = [];
var k = params.dueno[0];
var describeRoom = params.desc[0];
var cantu = params.cantu[0];
response.pwd = [];
for (var w = 0; w<params.pwd.length; w++) {
var t = params.pwd[w];
response.pwd[w] = t;
var rObj = {};
rObj.name = n;
rObj.pwd = t;
rObj.maxU = cantu;
rObj.maxS = 0;
rObj.isGame = false;
var newRoom = _server.createRoom(rObj, null);
if (newRoom != null) {
trace("Great the room was created -> add your vars here");
vars = new Array();
vars.push({name:"duenoactu", val:k, setOwnership:false});
_server.setRoomVariables(newRoom, null, vars, false, true);
response.iderom[0] = newRoom.getId();
salvar();
hd = n.split(" ");
hz = hd.join("%20");
response.creo[0] = "si";
newRoom.properties.put("descripcion", describeRoom)
newRoom.properties.put("voto", "0_0")
} else {
response.creo[0] = "no";
trace("A problem occurred, better check the server logs");
}
}
/*
*
* Send response back to client
*
* sendResponse(response, fromRoom, sender, recipients, type)
*
* response = an object with the _cmd property specifying the name of the response command
* fromRoom = the id of the room where the response comes from (-1 if not needed)
* sender = the user sending the response (null if not needed)
* recipients = a list of user that should receive the reponse
* type = can be "xml" or "str". It represent the message format
*
*/
_server.sendResponse(response, -1, null, [user]);
}
}
/*
* This method handles internal events
* Internal events are dispactched by the Zone or Room where the extension is attached to
*
* the (evt) object
*/
function handleInternalEvent(evt) {
// Simply print the name of the event that was received
trace("Event received: "+evt.name);
}
In the
salvar() function, I try to send some objects to a insertarcasa.php file.. and from there it inserts the value into the database.. but the first time i tried this it inserted only in the "owner" column the value "hola" and nothing in the value for the room name which would be the "nombre" column.. then i tried it again and again.. and nothing would be inserted in the db.. here is the insertarcasa.php:
Code: Select all
<?php
include('conectar.php');
mysql_query("INSERT into salas(id,owner,nombre) VALUES ('NULL','hola','".$_POST['cNombre']."')") or die(mysql_error());
echo"&statuss=ok";
?>