Radicore Forum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » RADICORE development » Bug Reports » Unexpected "Cannot extract token from" Error Due to Tabs / Newlines
Unexpected "Cannot extract token from" Error Due to Tabs / Newlines [message #4605] Sun, 26 October 2014 09:20 Go to next message
kong is currently offline  kong
Messages: 90
Registered: December 2011
Member
When the library function where2indexedArray($where) is called with $where containing tabs and/or newlines, it sometimes generates error:
"Cannot extract token from ..."

Such error could be avoided by being careful not to use tabs and newlines in the $where string. However, this results in reduced readability of source code, especially with complex $where conditions. So, would like to propose to add one line in function where2indexedArray($where), as follows:
...
$input = $where;

// Add this line to solve "Cannot extract token from" error:
$where = preg_replace("/\s\s+/", " ", $where);

$output = array();
while (!empty($where)) {
...

[Updated on: Sun, 26 October 2014 09:35]

Report message to a moderator

Re: Unexpected "Cannot extract token from" Error Due to Tabs / Newlines [message #4607 is a reply to message #4605] Sun, 26 October 2014 11:08 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2347
Registered: April 2006
Location: Surrey, UK
Senior Member
I have tried this function on string containing both tabs and newlines, and I cannot get it to fail. Can you send me a copy of one of your strings which does fail?

Re: Unexpected "Cannot extract token from" Error Due to Tabs / Newlines [message #4609 is a reply to message #4607] Sun, 26 October 2014 14:26 Go to previous messageGo to next message
kong is currently offline  kong
Messages: 90
Registered: December 2011
Member
Here are just a few examples:

Example 1
    $where	= "test_id 	< 3 ";
(With tabs between 'test_id' and '<' )

Example 2
    $where	= "test_id < 
    		3 ";

Example 3
    $where	= "		test_id < 3";
(With tabs before 'test_id')

Example 4
    $where	= "
    		test_id < 3";

Example 5
    $where	= "test_id < 3";

Examples 1 and 2 both result in
Fatal Error: Cannot extract token from: '< 3' (# 256)
Error in line 6994 of file 'D:\Pet\UwAmp\www\rad186\includes\include.library.inc'.

Example 3 and 4 both result in
Fatal Error: Cannot extract token from: ' test_id < 3' (# 256)
Error in line 6994 of file 'D:\Pet\UwAmp\www\rad186\includes\include.library.inc'.

Example 5 functions normally without errors.
Re: Unexpected "Cannot extract token from" Error Due to Tabs / Newlines / Spaces [message #4611 is a reply to message #4609] Sun, 26 October 2014 15:47 Go to previous messageGo to next message
kong is currently offline  kong
Messages: 90
Registered: December 2011
Member
Just discovered another case that my original proposal did not solve.
    $where	= " test_id < 3";
(With a space before 'test_id')

This results in
Fatal Error: Cannot extract token from: ' test_id < 3' (# 256)
Error in line 6993 of file 'D:\Pet\UwAmp\www\rad186\includes\include.library.inc'.

To take care of such cases, I would like to modify my original proposal to
...
$input = $where;

// Add this line to solve "Cannot extract token from" error:
$where = trim(preg_replace("/\s+/", " ", $where));

$output = array();
while (!empty($where)) {
...

[Updated on: Sun, 26 October 2014 22:27]

Report message to a moderator

Re: Unexpected "Cannot extract token from" Error Due to Tabs / Newlines / Spaces [message #4612 is a reply to message #4611] Mon, 27 October 2014 06:59 Go to previous message
AJM is currently offline  AJM
Messages: 2347
Registered: April 2006
Location: Surrey, UK
Senior Member
That works, so I will put it in the next release.

Previous Topic: Unexpected "Query was empty" Error Due to Space / Newline
Next Topic: Semicolon in Strings within SQL Multi Query String
Goto Forum:
  


Current Time: Thu Mar 28 21:17:32 EDT 2024

Total time taken to generate the page: 0.01143 seconds