MySQL unexpected result -
BiosMarcel - 21.12.2016
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(sqlHandle, query, sizeof(query), "SELECT ID FROM users WHERE Email = '%e'", inputtext);
mysql_tquery(sqlHandle, query);
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] [ERROR] cache_get_value_index_int: invalid row ('0') or field ('0') index
[18:11:55] [ERROR] cache_get_value_name_int: no active cache
it's not passing anything into the cache, am i using the wrong function or what?
Re: MySQL unexpected result -
Konstantinos - 21.12.2016
Threaded queries require a callback. Using cache functions to retrieve directly will result in no active cache warnings/errors.
Re: MySQL unexpected result -
BiosMarcel - 21.12.2016
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
Re: MySQL unexpected result -
Konstantinos - 21.12.2016
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.
Re: MySQL unexpected result -
BiosMarcel - 21.12.2016
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??
Re: MySQL unexpected result -
Konstantinos - 21.12.2016
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.
Re: MySQL unexpected result -
BiosMarcel - 21.12.2016
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