MYSQL Issue With ID Fetch
#1

Hi,

What did I do wrong here, this should work? But it returns value 0, when ID should be 64?

pawn Код:
new query[256], cquery[256], vid;
                    mysql_format(dbhandle, query, sizeof query, "SELECT `id` FROM `vehicles` ORDER BY `id` DESC LIMIT 1 ;", vid);
                    mysql_tquery(dbhandle, query, "", "");
                   
                    format(cquery, sizeof(cquery), "UPDATE users SET car='%d' WHERE name='%s'", vid, sendername);
                    mysql_tquery(dbhandle, cquery, "", "");
                   
                    printf("Vehicle DB-ID: %d Saved to playername %s.", vid, sendername);
Reply
#2

Not sure how many times I've said it the past few weeks, but if you're using R7 or higher then you MUST use callbacks. Though in your case you could probably solve it with a subquery;

PHP код:
UPDATE users SET car=(SELECT MAX(`id`) FROM `vehicles`) WHERE name='%s' 
Reply
#3

Quote:
Originally Posted by Vince
Посмотреть сообщение
Not sure how many times I've said it the past few weeks, but if you're using R7 or higher then you MUST use callbacks. Though in your case you could probably solve it with a subquery;

PHP код:
UPDATE users SET car=(SELECT MAX(`id`) FROM `vehicles`) WHERE name='%s' 
You are a life savior.

+REP

Thankyou Vince :')!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)