Jump to content
  • 0

Problema INSERT INTO


Snz

Question

Problema intalnita (descriere): Nu se creeaza in baza de date aceste informatii: http://prntscr.com/7x6and , http://prntscr.com/7x6aqi
Ero(area / rile) / warning-(ul / urile):

[16:24:23] ====================================================
[16:24:23] Error ID: 1064
Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(Obj2) VALUES (1,0,0,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00) (Obj3) VALUES' at line 1
Callback: 
Query: INSERT INTO `Holds` (Obj1) VALUES (0,0,0,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00) (Obj2) VALUES (1,0,0,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00) (Obj3) VALUES (2,0,0,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00) (Obj4) VALUES (3,0,0,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00) (Obj5) VALUES (4,0,0,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00) (Obj6) VALUES (5,0,0,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00) (Obj7) VALUES (6,0,0,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00) (Obj8) VALUES (7,0,0,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00) (Obj9) VALUES (8,0,0,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00) (Obj10) VALUES (9,0,0,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00)
[16:24:23] ====================================================

Liniile de cod / sursa / script-ul(obligatoriu):

	if(PlayerInfo[playerid][p_HoldSaving] == 1)
	{
	    format(eQuery, sizeof(eQuery), "INSERT INTO `Holds`");
	    for(new i = 0; i < MAX_PLAYER_ATTACHED_OBJECTS; i++)
	    {
	        if ( i != MAX_PLAYER_ATTACHED_OBJECTS - 1 )
	        {
		    	format(eQuery, sizeof(eQuery), "%s (Obj%d) VALUES (%d,%d,%d,%.2f,%.2f,%.2f,%.2f", eQuery, i + 1, i, Attach_Info[ playerid ][ i ][ ao_model ], Attach_Info[ playerid ][ i ][ ao_bone ], Attach_Info[ playerid ][ i ][ ao_x ], Attach_Info[ playerid ][ i ][ ao_y ], Attach_Info[ playerid ][ i ][ ao_z ], Attach_Info[ playerid ][ i ][ ao_rx ]);
				format(eQuery, sizeof(eQuery), "%s,%.2f,%.2f,%.2f,%.2f,%.2f)", eQuery, Attach_Info[ playerid ][ i ][ ao_ry ], Attach_Info[ playerid ][ i ][ ao_rz ], Attach_Info[ playerid ][ i ][ ao_sx ], Attach_Info[ playerid ][ i ][ ao_sy ], Attach_Info[ playerid ][ i ][ ao_sz ] );
			}
			else
			{
				format(eQuery, sizeof(eQuery), "%s (Obj%d) VALUES (%d,%d,%d,%.2f,%.2f,%.2f,%.2f", eQuery, i+1, i, Attach_Info[ playerid ][ i ][ ao_model ], Attach_Info[ playerid ][ i ][ ao_bone ], Attach_Info[ playerid ][ i ][ ao_x ], Attach_Info[ playerid ][ i ][ ao_y ], Attach_Info[ playerid ][ i ][ ao_z ], Attach_Info[ playerid ][ i ][ ao_rx ]);
				format(eQuery, sizeof(eQuery), "%s,%.2f,%.2f,%.2f,%.2f,%.2f)", eQuery, Attach_Info[ playerid ][ i ][ ao_ry ], Attach_Info[ playerid ][ i ][ ao_rz ], Attach_Info[ playerid ][ i ][ ao_sx ], Attach_Info[ playerid ][ i ][ ao_sy ], Attach_Info[ playerid ][ i ][ ao_sz ] );
			}
		}
		mysql_tquery(Connect, eQuery, "", "");
	}

Imagini / Video (optional): -
Ati incercat sa rezolvati singur?: Aveam la callback-ul SavePlayer, liniile care dadeau update , atunci cand un player iesea de pe sv sa modifice ce holduri avea. Dar, eu nu aveam insert into, deci update-ul era de pomana. Asa ca l-am creeat. Dar am acele erori.. Ma ajutat si Wopss cu ce a putut, mi-a dat sfaturi, dar tot nu am reusit, si cu ajutorul la wiki..

Edited by Snz
Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Acolo trebuie sa faci interogarea de genul acesta
INSERT INTO `Holds` (`Obj1`, `Obj2`, etc.) VALUES ('0.0, 0.0, 0.0, 0.0', '0.0, 0.0, 0.0, 0.0', etc.);

Observa ca acele 0.0, 0.0, 0.0, sunt intre apostrof.

 

Link to comment
Share on other sites

  • 0

Primesc aceste erori(nu stiu cum sa rezolv..):

In callback "LoadHoldDetails"
14:03:29	cache_get_field_content	OK	row: 0, field_name: "Obj1", connection: 1, max_len: 1024
14:03:29	CMySQLResult::GetRowDataByName()	ERROR	invalid row index ('0')
14:03:29	cache_get_field_content	OK	row: 0, field_name: "Obj2", connection: 1, max_len: 1024
14:03:29	CMySQLResult::GetRowDataByName()	ERROR	invalid row index ('0')
14:03:29	cache_get_field_content	OK	row: 0, field_name: "Obj3", connection: 1, max_len: 1024
14:03:29	CMySQLResult::GetRowDataByName()	ERROR	invalid row index ('0')
14:03:29	cache_get_field_content	OK	row: 0, field_name: "Obj4", connection: 1, max_len: 1024
14:03:29	CMySQLResult::GetRowDataByName()	ERROR	invalid row index ('0')
14:03:29	cache_get_field_content	OK	row: 0, field_name: "Obj5", connection: 1, max_len: 1024
14:03:29	CMySQLResult::GetRowDataByName()	ERROR	invalid row index ('0')
14:03:29	cache_get_field_content	OK	row: 0, field_name: "Obj6", connection: 1, max_len: 1024
14:03:29	CMySQLResult::GetRowDataByName()	ERROR	invalid row index ('0')
14:03:29	cache_get_field_content	OK	row: 0, field_name: "Obj7", connection: 1, max_len: 1024
14:03:29	CMySQLResult::GetRowDataByName()	ERROR	invalid row index ('0')
14:03:29	cache_get_field_content	OK	row: 0, field_name: "Obj8", connection: 1, max_len: 1024
14:03:29	CMySQLResult::GetRowDataByName()	ERROR	invalid row index ('0')
14:03:29	cache_get_field_content	OK	row: 0, field_name: "Obj9", connection: 1, max_len: 1024
14:03:29	CMySQLResult::GetRowDataByName()	ERROR	invalid row index ('0')
14:03:29	cache_get_field_content	OK	row: 0, field_name: "Obj10", connection: 1, max_len: 1024
14:03:29	CMySQLResult::GetRowDataByName()	ERROR	invalid row index ('0')

La LoadHoldDetails am in felul urmator:

function LoadHoldDetails(playerid)
{
	if ( !IsPlayerConnected( playerid ) )
	    return ( 1 );
	    
	new szField[1024], Z, count_attach[ MAX_PLAYERS ], gsString[4096];
	eString[0] = EOS; eQuery[0] = EOS;
	for ( new a = 0; a < MAX_PLAYER_ATTACHED_OBJECTS; a++ )
	{
	    format( gsString, 20, "Obj%d", a + 1 );
	    cache_get_field_content( 0, gsString, szField, DB_Connect );

	    sscanf( szField, "p<,>iiifffffffff", Z, Attach_Info[ playerid ][ a ][ ao_model ], Attach_Info[ playerid ][ a ][ ao_bone ],
	    Attach_Info[ playerid ][ a ][ ao_x ], Attach_Info[ playerid ][ a ][ ao_y ], Attach_Info[ playerid ][ a ][ ao_z ],
	    Attach_Info[ playerid ][ a ][ ao_rx ], Attach_Info[ playerid ][ a ][ ao_ry ], Attach_Info[ playerid ][ a ][ ao_rz ],
	    Attach_Info[ playerid ][ a ][ ao_sx ], Attach_Info[ playerid ][ a ][ ao_sy ], Attach_Info[ playerid ][ a ][ ao_sz ] );

		if ( Attach_Info[ playerid ][ Z ][ ao_model ] != 0 )
			count_attach[ playerid ]++;
	}
	if ( count_attach[ playerid ] > 0 )
		PlayerInfo[ playerid ][ Use_Attach ] = 1;

	for ( new v_obj = 0; v_obj < MAX_VEHICLE_ATTACHED_OBJECTS; v_obj++ )
	{
	    format( gsString, 10, "v_Obj%d", v_obj + 1 );
	    cache_get_field_content( 0, gsString, szField, DB_Connect );

	    sscanf( szField, "p<,>iffffff", V_Attach[ playerid ][ v_obj ][ liModel ],
		V_Attach[ playerid ][ v_obj ][ lfVO_X ], V_Attach[ playerid ][ v_obj ][ lfVO_Y ], V_Attach[ playerid ][ v_obj ][ lfVO_Z ],
		V_Attach[ playerid ][ v_obj ][ lfVO_RX ], V_Attach[ playerid ][ v_obj ][ lfVO_RY ], V_Attach[ playerid ][ v_obj ][ lfVO_RZ ] );

		if ( V_Attach[ playerid ][ v_obj ][ liModel ] != -1 )
        	p_Object[ playerid ][ v_obj ] = CreateDynamicObject( V_Attach[ playerid ][ v_obj ][ liModel ], 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, playerid );

		PlayerInfo[ playerid ][ TunedVehicle ] = cache_get_field_content_int( 0, "Vehicle_ID", DB_Connect );
	}
	if (PlayerInfo[playerid][p_HoldSaving] == 1)
	{
		for (new i = 0; i < MAX_PLAYER_ATTACHED_OBJECTS; i++)
		{
			if (i != MAX_PLAYER_ATTACHED_OBJECTS - 1)
			{
				format(eQuery, 1024, "INSERT INTO `Holds` (Obj%d) VALUES ('%d,%d,%d,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f')", i+1, i, Attach_Info[ playerid ][ i ][ ao_model ], Attach_Info[ playerid ][ i ][ ao_bone ], Attach_Info[ playerid ][ i ][ ao_x ], Attach_Info[ playerid ][ i ][ ao_y ], Attach_Info[ playerid ][ i ][ ao_z ], Attach_Info[ playerid ][ i ][ ao_rx ], Attach_Info[ playerid ][ i ][ ao_ry ], Attach_Info[ playerid ][ i ][ ao_rz ], Attach_Info[ playerid ][ i ][ ao_sx ], Attach_Info[ playerid ][ i ][ ao_sy ], Attach_Info[ playerid ][ i ][ ao_sz ] );
			}
		}
		format(eQuery, 1024, "%s WHERE `UserID` = %d", eQuery, PlayerInfo[playerid][AccID]);
		mysql_tquery(DB_Connect, eQuery, "", "");
    }
	return ( 1 );
}

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.