Raised This Month: $51 Target: $400
 12% 

Solved Problems with mysql table column


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
l00ka
Junior Member
Join Date: Sep 2012
Old 07-08-2020 , 12:58   Problems with mysql table column
Reply With Quote #1

Hello,

i got a small issue with a plugin.
The plugin works fine but it throws the following error all the time in the server console:

Quote:
07/08/2020 - 16:29:47: [deathrun_stats.amxx] SQL error: Incorrect datetime value: '' for column 'recorddate' at row 1
when I look into the specific table there is indeed in some rows a NULL value in the 'recorddate' column.

And when I look into the sql statements I see the following insert statment that made me suspicious:
HTML Code:
formatex(gszQuery, charsmax(gszQuery), "INSERT INTO `results` VALUES (%d, %d, 0, 1, 0, 0, NULL)", giPid[id], gMid);
as you might see the last parameter in the insert is the column with the datetime value NULL.

My question is, how do I get the current time in the datetime format and insert it here instead of NULL.

Hope someone can help me out. Thx.

UPDATE:
TLTR; I compiled with the old Init.inl file.
So the solution is to update the following line in the Init.inl insert statement and recompile with the updated Init.inl file.
Code:
formatex(gszQuery, charsmax(gszQuery), "INSERT INTO `results` VALUES (%d, %d, 0, 1, 0, 0, now())", giPid[id], gMid);
Attached Thumbnails
Click image for larger version

Name:	db.PNG
Views:	70
Size:	28.2 KB
ID:	182447  
Attached Files
File Type: txt db sql.txt (7.3 KB, 55 views)

Last edited by l00ka; 07-17-2020 at 16:25. Reason: added attachment
l00ka is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 07-08-2020 , 13:47   Re: Problems with mysql table column
Reply With Quote #2

Show the SQL. Query of creating the table.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Old 07-08-2020, 13:55
l00ka
This message has been deleted by l00ka.
l00ka
Junior Member
Join Date: Sep 2012
Old 07-08-2020 , 13:58   Re: Problems with mysql table column
Reply With Quote #3

Quote:
Originally Posted by Natsheh View Post
Show the SQL. Query of creating the table.
HTML Code:
query = SQL_PrepareQuery(link, 
		"CREATE TABLE IF NOT EXISTS `results`( \
			id		INT(11)		UNSIGNED, \
			mid 		INT(11) 	UNSIGNED, \
			besttime	INT(11) 	NOT NULL, \
			games		INT(11) 	NOT NULL, \
			playedtime	INT(11)		NOT NULL, 	\
			deaths		INT(11)		NOT NULL, 	\
			FOREIGN KEY(id) REFERENCES `runners`(id) ON DELETE CASCADE, \
			FOREIGN KEY(mid) REFERENCES `maps`(mid) ON DELETE CASCADE, \
			PRIMARY KEY(id, mid) \
		)");
	SQL_Execute(query);
	SQL_FreeHandle(query);
	
	query = SQL_PrepareQuery(link, 
		"ALTER TABLE `results` \
		ADD 	recorddate	DATETIME	NULL");
		
	SQL_Execute(query);
	SQL_FreeHandle(query);
l00ka is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 07-08-2020 , 18:53   Re: Problems with mysql table column
Reply With Quote #4

Try with 'now()' on the exact place where is 'null' inserted
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)
JocAnis is offline
l00ka
Junior Member
Join Date: Sep 2012
Old 07-09-2020 , 12:53   Re: Problems with mysql table column
Reply With Quote #5

Quote:
Originally Posted by JocAnis View Post
Try with 'now()' on the exact place where is 'null' inserted
This is not working.

I also tried setting directly the value with a timestring.

HTML Code:
formatex(gszQuery, charsmax(gszQuery), "INSERT INTO `results` VALUES (%d, %d, 0, 1, 0, 0,'2029-01-01 23:59:59')", giPid[id], gMid); 
SQL_ThreadQuery(gTuple, "handleStandard", gszQuery);
but this also doesn't work...
l00ka is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:57.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode