How to make pawn to ignore % character in string?
#1

I have a little problem. I'm trying to insert mysql function DATE_FORMAT but it doesn't work because pawno won't ignore the % character.

This is the string:

pawn Code:
format(query, sizeof(query), "INSERT INTO `"TABLE_BANS"` (`player`, `admin`, `reason`, `expireDate`, `expireTime`) VALUES ('%s', '%s', '%s', DATE_FORMAT(DATE_ADD(curdate(), INTERVAL %d DAY), '%d/%m/%Y'), curtime())",
  player,
  admin,
  reason,
  days);
But this part DATE_FORMAT(DATE_ADD(curdate(), INTERVAL %d DAY), '%d/%m/%Y') gets messed up and I have MySQL results like

Code:
37/m/Y
I tryed to add escape charater \ but it doesn't help... Does anyone has any idea how to solve this?

Reply
#2

%d = Number.

Just put %d/%d/%d

What does curtime return? A string? If so use %s.

Read the wiki in future.
Reply
#3

https://sampwiki.blast.hk/wiki/Format
Reply
#4

Try with another % so it looks like '%%d' etc.
Reply
#5

Quote:
Originally Posted by ►Peter Corneile◄
lol tnx

Quote:
Originally Posted by 0rb
Try with another % so it looks like '%%d' etc.
Yea that was the solution.

Tnx guys.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)