• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

Calc error - Argument number specifier must be greater than zero and less than 2147483647

ontarget

Active Member
I have a calc element returning
PHP:
$iban = '{aaa_my_profile___iban}';
//split array into chunks of 4 chars
$iban = str_split($iban,4);
//print_r($iban);
$iban = $iban[1];
$myDb = JFactory::getDbo();
$myQuery = $myDb->getQuery(true);
$myQuery = "SELECT `bic` FROM `aaa_bic` WHERE `bic` LIKE '%$iban%'";
$myDb->setQuery($myQuery);
$bic = $myDb->loadResult();
//var_dump($bic);
//exit;
return $bic;
The var_dump returns a valid string however on form submission i get the error:
0
Argument number specifier must be greater than zero and less than 2147483647
I think it's something to do with the LIKE '%$iban%'"; because when i remove the wildcard % the form submits fine.
However then calc doesn't output anything because there is no match!
Any ideas on how to fix this please?
 
Try
Code:
$myQuery = "SELECT `bic` FROM `aaa_bic` WHERE `bic` LIKE '%".$iban."%'";
 
I might be wrong, but this looks more like an error from an incorrect translation or language override.
 
I tried this too
PHP:
$iban = 'IE04IBPSIE123456123456123456';
//split array into chunks of 4 chars
$iban = str_split($iban,4);
//print_r($iban);
$iban = $iban[1];

$db = JFactory::getDbo();
$query = $db
    ->getQuery(true)
    ->select('bic')
    ->from($db->quoteName('aaa_bic'))
    ->where($db->quoteName('bic') . ' LIKE ' . $db->quote('%'. $iban . '%'));


$db->setQuery($query);
$result = $db->loadResult();

return $result;
I get the Error:
0 Unknown format specifier "$"
var_dump returns Null

This post seems to offer a solution but as I'm on Fabrik4 / joomla 4 the JString class is not recognised so I'm not sure how to make it work
https://stackoverflow.com/questions/21267795/php-query-search-a-string-in-a-row/21272382#21272382
 
Ok I updated my code to below to use:
substr($iban, 4, 4);
and improving the where bit:
where($db->qn('bic') . ' LIKE ' . $db->q('%' . $db->escape($iban, true) . '%', false));

The var_dump($result); now shows the correct output:):
string(8) "IPBSIE2D"

PHP:
$iban= 'IBPSIE123456123456123456';

$iban = substr($iban, 4, 4);

$db = JFactory::getDBO();
$query = $db->getQuery(true)
            ->select($db->qn('bic'))
            ->from($db->qn('aaa_bic'))
            ->where($db->qn('bic') . ' LIKE ' . $db->q('%' . $db->escape($iban, true) . '%', false));
$db->setQuery($query);

$result = $db->loadResult();
//var_dump($result);
//exit;

return $result;
However when I return the result I now get the 0 error:
0
Unknown format specifier " "
:(
 
It looks as though the wildcard search string is not being enclosed in quotation marks.

try

->where($db->qn('bic') . ' LIKE ' . '"'. $db->q('%' . $db->escape($iban, true) . '%', false).'"');

where the quotation marks are single double single (if not clear from the above!)

The StackOverflow suggests using the quote() function as an alternative
HTH
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top