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-nmm6 (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-nmm6 (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-nmm6 (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
Strange MySQL Behavior
Author Message
n1ghtwish
Apprentice
*

Posts: 40
Likes Given: 0
Likes Received: 28 in 8 posts
Joined: Jan 2016
Reputation: 0



Post: #1
Strange MySQL Behavior
First and foremost:
Windows 7 - .56c-Nightly Build 2681 2/6/2016

Okay, so I have TWO functions, whose names have been changed for simplicity... also, it is assumed that I have a working and established MySQL database connection with the following tables:

"testing" and "accounts"

The "accounts" table was created (last week) to mirror the accounts from Sphere and also keep an updated web-accessible record of last used IPs, last connect time, passwords, etc... it's also used as a web-based account registration system. PHP form --> MySQL table --> Sphere, via various scripts. This table currently has two rows, both containing data for the two accounts that I have in Sphere.

The "testing" table was created later (today) to debug the issue at hand. This table contains 9 rows of data, some empty entries included just to see if Sphere will handle it. The columns are named "data1" "data2" etc... and the rows have basic strings like "hello" and "fdhsjfa478343".

On to the functions:
Code:
[function function2]
db.query "select * from testing"

[function function1]
db.query "select * from accounts"

function2 gives me no console activity, so I did this:

Code:
[function function2]
db.query "select * from testing"
for x 0 <eval <db.row.numrows> -1>
    serv.log @TEST: Row # <dlocal.x> - data = <db.row.<dlocal.x>.2>
endfor

Running the above command gives me a nice clean loop through the data in column 2, including some empties. No console errors.

Back to function1, still looking like this:

Code:
[function function1]
db.query "select * from accounts"

and this is what I get....

Code:
23:01:DEBUG:__ thread (3772) __ |  # | _____ function _____________ | ticks passed from previous function start ______
23:01:DEBUG:>>         3772     |  0 |              CServer::OnTick | +0
23:01:DEBUG:>>         3772     |  1 |        CServer::OnConsoleCmd | +0
23:01:DEBUG:>>         3772     |  2 |              CServer::r_Verb | +0
23:01:DEBUG:>>         3772     |  3 |           CScriptObj::r_Call | +0
23:01:DEBUG:>>         3772     |  4 |     CScriptObj::OnTriggerRun | +0
23:01:DEBUG:>>         3772     |  5 |              CServer::r_Verb | +0
23:01:DEBUG:>>         3772     |  6 |           CScriptObj::r_Verb | +0 <-- exception catch point (below is guessed and could be incorrect!)
23:01:DEBUG:>>         3772     |  7 |                CGFile::Close | +0
23:01:CRITICAL:(sphere_sql_functions.scp,47)"Access Violation" (0x16cf44), in CScriptObj::Verb()
23:01:DEBUG:command 'db.query' args '"select * from accounts' [0297B680]

If I run the FOR loop on "accounts" table, I get a return on the FIRST row only, the above error still happens, and then my FOR loop is broken... even tried adding more rows to the mix, and the loop breaks after the first row is returned.

BOTH tables were created using PHPMyAdmin... I have renamed columns, tables, rows, even renamed data to take out all special characters and try to get the two similar in the sense that they both contain simple columns and rows of data... each and EVERY time I run these tests, each and every WAY I can possibly think of, I get the same results... Sphere hates the table I need to use, and likes the table that I don't.

Edit: I also forgot to mention that this does not happen with the pre-release executable.

Confused

-NW
(This post was last modified: 02-08-2016 05:20 PM by n1ghtwish.)
02-08-2016 05:19 PM
Find all posts by this user Like Post Quote this message in a reply
darksun84
Sir Spamalot
****

Posts: 1,687
Likes Given: 245
Likes Received: 162 in 151 posts
Joined: Mar 2012
Reputation: 35



Post: #2
RE: Strange MySQL Behavior
Did you rename the accounts table as well ? Is possible that ACCOUNTS keyword is reserved ( i think that sphere parse everything)
02-09-2016 07:20 AM
Find all posts by this user Like Post Quote this message in a reply
n1ghtwish
Apprentice
*

Posts: 40
Likes Given: 0
Likes Received: 28 in 8 posts
Joined: Jan 2016
Reputation: 0



Post: #3
RE: Strange MySQL Behavior
(02-09-2016 07:20 AM)darksun84 Wrote:  Did you rename the accounts table as well ? Is possible that ACCOUNTS keyword is reserved ( i think that sphere parse everything)

I thought of that too, and yep, renamed the table to "accts" "testing2" and even "blah" and still no dice.

I am going to wipe the DB and recreate it and see if that does the trick. Just find it odd that the pre-release didn't have any issues for me, yet no one has reported it as a bug and as far as I know, MySQL integration is pretty popular so you'd think someone would have caught it if it's an issue with the executable.
02-09-2016 02:25 PM
Find all posts by this user Like Post Quote this message in a reply
Ben
Sphere Developer
*****

Posts: 612
Likes Given: 2
Likes Received: 123 in 70 posts
Joined: Mar 2010
Reputation: 18

SphereCommunity

Post: #4
RE: Strange MySQL Behavior
Since the error happens after the first row... It's possible the there is some data in the next row that sphere can't handle.

AxisII's current version: 2.0.4j
AxisII SourceCode on Github
AxisII up to date changelog
02-12-2016 03:24 AM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
n1ghtwish
Apprentice
*

Posts: 40
Likes Given: 0
Likes Received: 28 in 8 posts
Joined: Jan 2016
Reputation: 0



Post: #5
RE: Strange MySQL Behavior
(02-12-2016 03:24 AM)Ben Wrote:  Since the error happens after the first row... It's possible the there is some data in the next row that sphere can't handle.

Ben, thanks for the reply and that's a valid assumption. However, answer the following question regarding that...

why would the same debug message show up when I query the table with only 1 row, without the loop? simply a "db.query etc...." single line of code.

At this time, I have narrowed down the issue to ONLY MySQL queries (does not happen with execute). Also, the error only seems to appear while using the * operator inside the query... if I rewrite the function as follows, I do not get the debug errors at all and the command executes properly:

Code:
local.col = acctname
local.table = accounts
db.query "select <local.col> from <local.table>"
serv.log @Test: Querying column "<local.col>"
serv.log @Test: <eval <db.row.numrows>> rows returned.

for X 0 <eval <db.row.numrows> -1>
    serv.log @Test: Row # <eval <dlocal.x> + 1> account name is <db.row.<dlocal.x>.acctname>
endfor�
02-15-2016 04:23 AM
Find all posts by this user Like Post Quote this message in a reply
n1ghtwish
Apprentice
*

Posts: 40
Likes Given: 0
Likes Received: 28 in 8 posts
Joined: Jan 2016
Reputation: 0



Post: #6
RE: Strange MySQL Behavior
So, I've circumvented the error by specifying the columns I need to query, rather than using the * operator, which is probably better anyway, less unused data being parsed.

Code:
local.col = column1, column2, etc....
local.table = table
db.query "select <local.col> from <local.table> where blah = whatever"
02-15-2016 04:01 PM
Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Forum Jump:


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