Quote:
Originally Posted by devilsknite1
PHP Code:
function onPlayerLogin( p )
{
p = findPlayer( player.account );
requestsql("CREATE TABLE IF NOT EXISTS test (account varchar not null default '' primary key, id int not null default 1)", false);
requestsql("INSERT INTO test VALUES (" @ p.account @ "," @ p.id @ ")", false);
temp.req = requestsql("SELECT * FROM test", true);
if (!temp.req.completed)
waitfor(temp.req,"onReceiveData",60);
echo("Accounts in database: " @ temp.req.rows.size());
for (temp.row: temp.req.rows)
echo(" Account: " @ temp.row.account @ ", ID: " @ temp.row.id);
}
|
It looks like there's an error in one of your queries (you forgot the single quotes). Try this:
PHP Code:
requestsql("INSERT INTO test VALUES ('" @ p.account @ "'," @ p.id @ ")", false);
Let me know the result, as I don't have a means to test it right now

.
Also, you don't really need the first sql query if you have already created the table (but I guess it doesn't really hurt to include it). And, you don't need to do the findplayer(), since the 'p' passed in is a player object (so you could use temp.p.account and temp.p.id right off the bat).