The following warnings occurred:
Warning [2] Use of undefined constant SAPI_NAME - assumed 'SAPI_NAME' (this will throw an Error in a future version of PHP) - Line: 3388 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3388 errorHandler->error
/showthread.php 116 build_archive_link
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/inc/functions.php 3324 build_forum_breadcrumb
/showthread.php 195 build_forum_breadcrumb
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/showthread.php 195 build_forum_breadcrumb






Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SQL Problem...
Author Message
admin_teclis
Journeyman
*

Posts: 51
Likes Given: 0
Likes Received: 0 in 0 posts
Joined: Aug 2012
Reputation: 0

Age of Apocalypse

Post: #1
SQL Problem...
Good evening,
I have a problem with a SQL query.
Use the script to create the paperdoll Avatar.
Because there is a bug, that is, every time a client connects rewrites again his skill, I made a query that checks whether it already exists and performs an UPDATE instead of rewriting.
Here lies the problem ... The query works, but instead of cycling all skills I marked all as necromancy ... and of course with its value ..
The query is this:

// Character skills UPDATE
Db.query "SELECT * FROM WHERE myrunuo_characters_skills char_id = '<eval <uid >>'
    if (<DB.ROW.NUMROWS>> 0)
for x 1 <eval <DB.ROW.NUMROWS >>
Db.Execute "UPDATE myrunuo_characters_skills September skill_id = <dlocal.x>, skill_value = << def.player_skill_ <dlocal.x >>> WHERE char_id = <eval <uid >>"
endfor
endif

Db.query "SELECT * FROM WHERE myrunuo_characters_skills char_id = '<eval <uid >>'
    if (<DB.ROW.NUMROWS> == 0)
// Insert Character Skills
for 1 x 49
db.query insert into myrunuo_characters_skills (char_id, skill_id, skill_value) VALUES ('<eval <uid >>', '<dlocal.x>', '<< def.player_skill_ <dlocal.x >>>')
endfor
endif
09-12-2015 12:33 AM
Find all posts by this user Like Post Quote this message in a reply
azmanomer
Journeyman
*

Posts: 139
Likes Given: 4
Likes Received: 18 in 16 posts
Joined: Nov 2013
Reputation: 1



Post: #2
RE: SQL Problem...
Db.query "SELECT * FROM WHERE myrunuo_characters_skills char_id = '<eval <uid >>' ---> this one should be without eval just use <uid>
if (<DB.ROW.NUMROWS>> 0)
for x 1 <eval <DB.ROW.NUMROWS >> --> rows starts from 0 so you should start for loop from 0 and <eval <db.row.numrows>-1>
Db.Execute "UPDATE myrunuo_characters_skills September skill_id = <dlocal.x>, skill_value = << def.player_skill_ <dlocal.x >>> WHERE char_id = <eval <uid >>" why did you use "<>" just write <def.player_skill_<dlocal.x>> also same use <uid> without eval
endfor
endif

Db.query "SELECT * FROM WHERE myrunuo_characters_skills char_id = '<eval <uid >>' ---> this one should be without eval just use <uid>
if (<DB.ROW.NUMROWS> == 0)
// Insert Character Skills
for x 0 48 ---> also start from 0
db.query insert into myrunuo_characters_skills (char_id, skill_id, skill_value) VALUES ('<eval <uid >>', '<dlocal.x>', '<< def.player_skill_ <dlocal.x >>>') ---> why did you use "<>" just write '<def.player_skill_<dlocal.x>>' also same use <uid> without eval
endfor
endif

also you can use <serv.skill.<dlocal.x>.name> for example <serv.skill.0.name> is return Alchemy i dont understand what do you want exactly so i wish these could help Tongue
09-12-2015 12:54 AM
Find all posts by this user Like Post Quote this message in a reply
admin_teclis
Journeyman
*

Posts: 51
Likes Given: 0
Likes Received: 0 in 0 posts
Joined: Aug 2012
Reputation: 0

Age of Apocalypse

Post: #3
RE: SQL Problem...
Hello,
thanks for the reply .
I must just make sure that :

When the logs pg automatically checks whether the DB is already rpesente quell UID . If there takes skill which at that time and performs an UPDATE on the basis of ' UID .
If there is no must write them all .
09-12-2015 01:57 AM
Find all posts by this user Like Post Quote this message in a reply
Coruja
Sphere Developer
*****

Posts: 987
Likes Given: 5
Likes Received: 226 in 187 posts
Joined: Jul 2012
Reputation: 7

Dimension Shard

Post: #4
RE: SQL Problem...
you must use the arguments in correct order, you wrote SELECT [a] FROM WHERE [b] [c] but the correct is SELECT [a] FROM [b] WHERE [c]

Code:
DB.QUERY "SELECT * FROM myrunuo_characters_skills WHERE char_id='<UID>' LIMIT 1
IF (<DB.ROW.NUMROWS>)
  FOR 1 49
    DB.EXECUTE "UPDATE myrunuo_characters_skills SET skill_id=<dLOCAL._FOR>, skill_value=<I.<LOCAL._FOR>> WHERE char_id=<UID> LIMIT 1"
  ENDFOR
ELSE
  FOR 1 49
    DB.QUERY "INSERT INTO myrunuo_characters_skills (char_id, skill_id, skill_value) VALUES ('<UID>', '<dLOCAL._FOR>', '<I.<LOCAL._FOR>>')"
  ENDFOR
ENDIF
(This post was last modified: 09-12-2015 08:45 AM by Coruja.)
09-12-2015 03:29 AM
Find all posts by this user Like Post Quote this message in a reply
admin_teclis
Journeyman
*

Posts: 51
Likes Given: 0
Likes Received: 0 in 0 posts
Joined: Aug 2012
Reputation: 0

Age of Apocalypse

Post: #5
RE: SQL Problem...
(09-12-2015 03:29 AM)Coruja Wrote:  you must use the arguments in correct order, you wrote SELECT [a] FROM WHERE [b] [c] but the correct is SELECT [a] FROM [b] WHERE [c]

Code:
DB.QUERY "SELECT * FROM myrunuo_characters_skills WHERE char_id='<UID>' LIMIT 1
IF (<DB.ROW.NUMROWS>)
  FOR 1 49
    DB.EXECUTE "UPDATE myrunuo_characters_skills SET skill_id=<dLOCAL._FOR>, skill_value=<I.<LOCAL._FOR>> WHERE char_id=<UID> LIMIT 1"
  ENDFOR
ELSE
  FOR 1 49
    DB.QUERY "INSERT INTO myrunuo_characters_skills (char_id, skill_id, skill_value) VALUES ('<UID>', '<dLOCAL._FOR>', '<I.<LOCAL._FOR>>')"
  ENDFOR
ENDIF
Hello , I tried your correction but the problem remains ... If log in the first time makes the correct entry . If you change the skill and the skill log out saves only 49 with the exact value for 49 times .
09-17-2015 08:12 AM
Find all posts by this user Like Post Quote this message in a reply
Extreme
Grandmaster Poster
***

Posts: 1,141
Likes Given: 217
Likes Received: 90 in 77 posts
Joined: May 2012
Reputation: 20

SphereCommunity

Post: #6
RE: SQL Problem...
You forgot to specify from what table you are querying.
Select * from table_name where bla_bla

STEPS BEFORE CREATE A THREAD
- Check the revisions log;
- Use the search button and use the keywords of your problem;
- Check the WIKI;
- Create a thread.
09-17-2015 12:15 PM
Find all posts by this user Like Post Quote this message in a reply
Artyk
Journeyman
*

Posts: 75
Likes Given: 43
Likes Received: 9 in 9 posts
Joined: Sep 2014
Reputation: 0



Post: #7
RE: SQL Problem...
(09-12-2015 03:29 AM)Coruja Wrote:  you must use the arguments in correct order, you wrote SELECT [a] FROM WHERE [b] [c] but the correct is SELECT [a] FROM [b] WHERE [c]

Code:
DB.QUERY "SELECT * FROM myrunuo_characters_skills WHERE char_id='<UID>' LIMIT 1
IF (<DB.ROW.NUMROWS>)
  FOR 1 49
    DB.EXECUTE "UPDATE myrunuo_characters_skills SET skill_id=<dLOCAL._FOR>, skill_value=<I.<LOCAL._FOR>> WHERE char_id=<UID> LIMIT 1"
  ENDFOR
ELSE
  FOR 1 49
    DB.QUERY "INSERT INTO myrunuo_characters_skills (char_id, skill_id, skill_value) VALUES ('<UID>', '<dLOCAL._FOR>', '<I.<LOCAL._FOR>>')"
  ENDFOR
ENDIF

Coruja did correct your code in the right way, the problem is that there is a logical error: for each row you're updating skill_id and skill_value checking if char_id = <UID>. You should only set skill_value=<I.<LOCAL._FOR>>, checking if char_id=<UID> and skill_id=<dlocal._FOR>
09-17-2015 05:44 PM
Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 2 Guest(s)