Hi all, this is my first post on killtube, I frequented at cod1.eu
I used these 2 functions to exchange infos betweeen players and MySQL:
PHP Code:
set_db_field(fieldname, value) {
ret = "";
query = "SELECT * FROM `"+level.table+"` WHERE `user_name`= '"+ self.name +"' LIMIT 1";
mysql_query(level.mysql_connection, query);
r = mysql_store_result(level.mysql_connection);
num = mysql_num_fields(r);
if(num != 0) {
row = mysql_fetch_row(r);
if(isdefined(row)) {
mysql_query(level.mysql_connection, "UPDATE `"+ level.table +"` SET `"+fieldname+"`='"+value+"' WHERE `user_guid`='"+self getGuid()+"' LIMIT 1");
}
else
mysql_query(level.mysql_connection, "INSERT INTO `"+level.table+"`(`"+fieldname+"`) VALUES ('"+value+"')");
}
mysql_free_result(r);
}
and this:
PHP Code:
get_db_field(fieldname) {
//should be using JOIN etc eh...
ret = "";
//don't need to real_escape assumingly you wouldn't take raw input as argument
query = "SELECT * FROM "+level.table+" WHERE `user_name`='"+self.name+"' LIMIT 1";
mysql_query(level.mysql_connection, query);
r = mysql_store_result(level.mysql_connection);
num = mysql_num_fields(r);
if(num != 0) {
row = mysql_fetch_row(r);
if(isdefined(row)) {
mysql_query(level.mysql_connection, "SELECT `"+fieldname+"` FROM `"+level.table+"` WHERE `user_guid`='"+self getGuid()+"' LIMIT 1");
r2=mysql_store_result(level.mysql_connection);
ret = r2;
mysql_free_result(r2);
}
else
ret = 0;
}
mysql_free_result(r);
return ret;
}
And here is my SQL table used with XAMPP: https://mega.co.nz/#!doQR2LoA!89go0L...lCgvQvkTEz_Xq0
The problem is that when the map restart, the database is not saved, thus I believe that there is problem with the table/scripts.
Could you please help me out?
Thanks