MySQL unexpected result
#1

Hello,

I am making a registration system where you can enter your email address, if your address is already in use it's supposed to not let you register.

Well, this is my code:

PHP код:
new query[130];
mysql_format(sqlHandlequerysizeof(query), "SELECT ID FROM users WHERE Email = '%e'"inputtext);
mysql_tquery(sqlHandlequery);
new 
emailID;
cache_get_value_name_int(0"ID"emailID);
printf("%d"emailID); 
The query is correct, i checked that already, when i enter it in mysql console it returns '6' which is my user id.

PHP код:
[18:11:49] [ERRORcache_get_value_index_intinvalid row ('0') or field ('0'index
[18:11:55] [ERRORcache_get_value_name_intno active cache 
it's not passing anything into the cache, am i using the wrong function or what?
Reply
#2

Threaded queries require a callback. Using cache functions to retrieve directly will result in no active cache warnings/errors.
Reply
#3

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Threaded queries require a callback. Using cache functions to retrieve directly will result in no active cache warnings/errors.
Well, it says that you should use threaded queries if u don't know what you are doing, i guess thats the case.

But i don't want a callback
Reply
#4

Quote:
Originally Posted by [Bios]Marcel
Посмотреть сообщение
Well, it says that you should use threaded queries if u don't know what you are doing, i guess thats the case.

But i don't want a callback
No callback = non-threaded queries.

If that's what you want, you need to store what mysql_query returns in a variable with Cache: tag and after retrieving the ID, use cache_delete with the variable as parameter to remove the cache from the memory.
Reply
#5

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
No callback = non-threaded queries.

If that's what you want, you need to store what mysql_query returns in a variable with Cache: tag and after retrieving the ID, use cache_delete with the variable as parameter to remove the cache from the memory.
Well then ill use unthreaded queries, but does it have any negative impact, does it block the main thread or such??

if i don't read the result into a Cache tagged variable will i still have to call cache_delete??
Reply
#6

Quote:
Originally Posted by [Bios]Marcel
Посмотреть сообщение
Well then ill use unthreaded queries, but does it have any negative impact, does it block the main thread or such??
The longer the query takes to get executed, the longer the server will have to wait.

Quote:
Originally Posted by [Bios]Marcel
Посмотреть сообщение
if i don't read the result into a Cache tagged variable will i still have to call cache_delete??
http://forum.sa-mp.com/showpost.php?...46&postcount=5

---

Threaded queries are superior for almost all the cases. Set Email to UNIQUE key and execute your insert query:
Код:
INSERT IGNORE INTO ...
In the callback, check if cache_affected_rows returns 0 and return an error that the email is in use already. You most likely have all necessary data stored in variables so it shouldn't be problem at all to force them repeat the process.
Reply
#7

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
The longer the query takes to get executed, the longer the server will have to wait.



http://forum.sa-mp.com/showpost.php?...46&postcount=5

---

Threaded queries are superior for almost all the cases. Set Email to UNIQUE key and execute your insert query:
Код:
INSERT IGNORE INTO ...
In the callback, check if cache_affected_rows returns 0 and return an error that the email is in use already. You most likely have all necessary data stored in variables so it shouldn't be problem at all to force them repeat the process.
The repeating of the registration and such is done already , just needed to fix that

Thanks man, ill use a callback haha
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)