Insert Into
#1

I am making dynamic organizations and I have problem. Any ideas why thi is not working
PHP Code:
new query[500];
    
mysql_format(g_SQLquerysizeof(query), "INSERT INTO `orgs` (`Name`, `Leader`, `ExitX`, `ExitY`, `ExitZ`, `IntX`, `IntY`, `IntZ`, `VW`, `Interior`) VALUES (%s, %s, %f, %f, %f, %f, %f, %f, %d, %d)"OrgInfo[org][oName], OrgInfo[org][oLeader], iXiYiZXYZvwinterior);
    
mysql_tquery(g_SQLquery); 
It won't write anything in DB..
Reply
#2

Anything on the log?
Reply
#3

This
Code:
[14:23:11] [ERROR] cache_insert_id: no active cache (C:\Users\Micko\Desktop\MySQL\gamemodes\Untitled.pwn:2435)
[14:23:11] [ERROR] error #1054 while executing query "INSERT INTO `orgs` (`Name`, `Leader`, `ExitX`, `ExitY`, `ExitZ`, `IntX`, `IntY`, `IntZ`, `VW`, `Interior`) VALUES (Micko, Noone, 1960.612549, 1342.059082, 15.374607, 0.000000, 0.000000, 0.000000, 0, 0)": Unknown column 'Micko' in 'field list' (C:\Users\Micko\Desktop\MySQL\gamemodes\Untitled.pwn:2454)
Reply
#4

strings should wrap in single quotes ' ' ('%s')
Reply
#5

Thank you But one more question I got this in log
Code:
[14:33:00] [ERROR] cache_insert_id: no active cache (C:\Users\Micko\Desktop\MySQL\gamemodes\Untitled.pwn:2436)
What is it??

This is cache_insert_id()
PHP Code:
OrgInfo[org][oID] = cache_insert_id(); 
That row is auto increment in db
Reply
#6

https://sampwiki.blast.hk/wiki/MySQL/R33#mysql_tquery
The function doesn't create a cache unless it's in a callback
Reply
#7

But watch this
PHP Code:
CMD:drugplace(playerid)
{
    if(
PlayerInfo[playerid][Admin] < 5)
    {
        
ERROR(playerid"You are not allowed to use that command");
        return 
1;
    }
    new 
Float:XFloat:YFloat:Zquery[128], id;
    
GetPlayerPos(playeridXYZ);
    
DrugsPickup[id] = CreateDynamicPickup(12791XYZ);
    
DrugsLabel[id] = CreateDynamic3DTextLabel(""SERVERBLUE"[ DRUGS ]\n"WHITE"To buy drugs type /buydrugs"0x1D9F00AAXYZ,  10.0INVALID_PLAYER_IDINVALID_VEHICLE_ID0, -1, -1, -120.0);
    
DrugsInfo[id][dPosX] = X;
    
DrugsInfo[id][dPosY] = Y;
    
DrugsInfo[id][dPosZ] = Z;
    
DrugsInfo[id][ID] = cache_insert_id();
    
id Iter_Free(i_Drugs);
    
Iter_Add(i_Drugsid);
     
mysql_format(g_SQLquerysizeof(query), "INSERT INTO `drugs` (`X`, `Y`, `Z`) VALUES (%f, %f, %f)"XYZ);
    
mysql_tquery(g_SQLquery);
    return 
1;

Here is the same and it is working normally and no errors in log..
Reply
#8

Anyone know fix for this??
Code:
[14:33:00] [ERROR] cache_insert_id: no active cache (C:\Users\Micko\Desktop\MySQL\gamemodes\Untitled.pwn:2436)
Reply
#9

simply use mysql_query instead of tquery
Reply
#10

I think Sreyas gave you the answer.The thing worked for you in some part is because you may forgot to delete cache i think.

Quote:
Originally Posted by iLearner
View Post
simply use mysql_query instead of tquery
Not a good idea.Try to use threaded queries in most case.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)