Okay added a new function and replaced an old one.
PHP Code:
RequestSQL(host, username, password, query);
is now
PHP Code:
RequestSQL2(host, username, password, db, query);
and the new RequestSQL is:
PHP Code:
RequestSQL(query);
Uses default SQL settings.
-------------------
Updated Class [sql_functions]:
PHP Code:
/*
CREATED BY RAPIDWOLVE
*/
function SQL_Update(table, field, newvalue, row)
{
temp.query = format("UPDATE `%s` SET `%s` = '%s' WHERE `ID` = %s", temp.table, temp.field, temp.newvalue, temp.row);
return temp.query;
}
function SQL_Delete(table, field, value)
{
temp.query = format("DELETE FROM `%s` WHERE `%s` = '%s';", temp.table, temp.field, temp.value);
return temp.query;
}
function SQL_Insert(table, field, value)
{
if ((temp.field.size() == temp.value.size()) && temp.field.size() > 1)
{
temp.query = format("INSERT INTO `%s` (", temp.table);
for (i = 0; i < temp.field.size(); i ++)
{
temp.query @= "`" @ temp.field[i] @ "`";
if (i < temp.field.size()-1)
temp.query @= " , ";
}
temp.query @= ") VALUES (";
for (j = 0; j < temp.value.size(); j++)
{
temp.query @= "'" @ temp.value[j] @ "'";
if (j < temp.value.size()-1)
temp.query @= " , ";
}
temp.query @= ");";
return temp.query;
} else {
temp.query = format("INSERT INTO `%s` (`%s`) VALUES ('%s')", temp.table, temp.field, temp.value);
return temp.query;
}
}
function RequestSQL(query)
{
temp.url = format("%s?host=%s&user=%s&pass=%s&db=%s&query=%s", this.sql.connectfile, this.sql.host, this.sql.username, this.sql.password, this.sql.db, temp.query);
temp.req = requesturl(temp.url);
this.catchevent(temp.req, "onReceiveData", "onSQLReceived");
}
function RequestSQL2(host, username, password, db, query)
{
temp.url = format("%s?host=%s&user=%s&pass=%s&db=%s&query=%s", this.sql.connectfile, temp.host, temp.username, temp.password, temp.db, temp.query);
temp.req = requesturl(temp.url);
this.catchevent(temp.req, "onReceiveData", "onSQLReceived");
}
function onSQLReceived(page)
{
temp.returnData = page.data[0];
for (p: allplayers)
{
if (p == "rapidwolve") // RC Player
p.sendpm(temp.returnData);
}
}
-----------------
Quote:
Originally Posted by JkWhoSaysNi
I suggest you put the SQL connection details in the PHP script though. That way you can safely use the script clientside without worrying about people getting your DB info.
|
Will probobly make it like that once im done with all the SQL format functions, thanks for the advice.