Need advice to make php server side Datatables work properly - php

There's something weird going on with server-side Datatables from this: https://github.com/n1crack/Datatables.
Don't understand what's going on, i do exactly the same thing as the examples but it simply doesn't work. According to the "where" example https://github.com/n1crack/Datatables/blob/master/public/examples/where/ajax.php, look how simple it should be:
$dt = new Datatables(new MySQL($config));
$dt->query("Select film_id as fid, title, description from film where film_id > 47 and film_id < 83");
echo $dt->generate();
My code:
$config = [ 'host' => 'localhost',
'port' => '3306',
'username' => 'root',
'password' => '',
'database' => 'sys_db_gincana' ];
$dt = new Datatables( new MySQL($config) );
$dt->query("
SELECT seen, id, name, cep, date_format(created,'%d/%m/%Y %h:%i:%s') as created
FROM user
");
echo $dt->generate();
Now look at what my js console prints from my ajax:
A PHP Error was encountered
Severity: 4096 Message: Argument 1 passed to
PHPSQLParser\builders\WhereBuilder::build() must be of the type array,
boolean given, called in C:\Program Files
(x86)\EasyPHP-DevServer-14.1VC11\data\localweb\projects\gincana\vendor\greenlion\php-sql-parser\src\PHPSQLParser\builders\SelectStatementBuilder.php
on line 74 and defined Filename: builders/WhereBuilder.php
Line Number: 112
A PHP Error was encountered
Severity: Warning Message: Invalid argument supplied for
foreach() Filename: builders/WhereBuilder.php Line
Number: 114
A PHP Error was encountered
Severity: 4096 Message: Argument 1 passed to
PHPSQLParser\builders\WhereBuilder::build() must be of the type array,
boolean given, called in C:\Program Files
(x86)\EasyPHP-DevServer-14.1VC11\data\localweb\projects\gincana\vendor\greenlion\php-sql-parser\src\PHPSQLParser\builders\SelectStatementBuilder.php
on line 74 and defined Filename: builders/WhereBuilder.php
Line Number: 112
A PHP Error was encountered
Severity: Warning Message: Invalid argument supplied for
foreach() Filename: builders/WhereBuilder.php Line
Number: 114
Fatal error: Call to a member function
fetch_assoc() on a non-object in C:\Program Files
(x86)\EasyPHP-DevServer-14.1VC11\data\localweb\projects\gincana\vendor\ozdemir\datatables\src\DB\MySQL.php
on line 40
And if if i change the query to:
$dt = new Datatables( new MySQL($config) );
$dt->query("
SELECT seen, id, name, cep, date_format(created,'%d/%m/%Y %h:%i:%s') as created
FROM user
WHERE approved = 0 and canceled = 0
");
echo $dt->generate();
the error changes:
A PHP Error was encountered
Severity: Warning Message: array_merge(): Argument #2 is
not an array Filename: src/Datatables.php Line Number:
47
Fatal error: Call to a member function
fetch_assoc() on a non-object in C:\Program Files
(x86)\EasyPHP-DevServer-14.1VC11\data\localweb\projects\gincana\vendor\ozdemir\datatables\src\DB\MySQL.php
on line 40
Well, the library is a bit new (january 2015), i wonder if someone that had success using it could help me.
Regards

The problem in the WhereBuilder comes from the PHPSQLParser, can you test the latest version from https://github.com/greenlion/PHP-SQL-Parser? It seems to be a simple SQL statement, so actually it should work. I have moved your issue to GitHub, please follow the changes there.

Related

Upgrading from PHP 7.4 to 8.0 bool/null errors

I have managed to fix one problem (found answer on google search) but this one still appears on my site:
Warning: Trying to access array offset on value of type bool in /usr/home/.../template-series.php on line 103
Warning: Trying to access array offset on value of type null in /usr/home/.../template-series.php on line 103
Warning: Trying to access array offset on value of type bool in /usr/home/.../template-series.php on line 105
Warning: Trying to access array offset on value of type null in /usr/home/.../template-series.php on line 105
if ($choice == 'choice1') {
$img1 = get_sub_field('series2_rep_img1');
LINE 103: $thumb1 = $img1['sizes']['foundation-small'];
$img2 = get_sub_field('series2_rep_img2');
LINE 105: $thumb2 = $img2['sizes']['foundation-small'];
I would appreciate any help.
Thank you

Error In Wordpress On All Pages Just Below The Header (Using Theme elumine)

The error is in below lines of the addressed file below (Line 186 & 187):
Website (Live): www.healthyminds.world
Tried restoring an earlier back-up(24 hours back), but that didn't work also.
Line 186 & 187 from source line:
$collections = get_option('google_typography_collections');
$google_fonts_all = $this->get_fonts();
$import_fonts = array();
if ($collections) {
foreach ($collections as $collection) {
$font_family = $collection['font_family'];
$font_index = array_search($font_family,
array_column($google_fonts_all,'family'));//Line 186
$font_variants = implode(',', $google_fonts_all[$font_index ['variants']); //Line 187
array_push(
$import_fonts,
array(
'font_family' => $collection['font_family'],
'font_variant' => $font_variants,
Error Messages (On All Pages Of Website, these are just few of the lines):
content/themes/elumine/includes/integrations/google-typography/google-typography.php on line 186
Warning: array_search() expects parameter 2 to be array, null given in /home/customer/www/healthyminds.world/public_html/wp-content/themes/elumine/includes/integrations/google-typography/google-typography.php on line 186
Warning: Illegal string offset 'variants' in /home/customer/www/healthyminds.world/public_html/wp-content/themes/elumine/includes/integrations/google-typography/google-typography.php on line 187
Warning: implode(): Invalid arguments passed in /home/customer/www/healthyminds.world/public_html/wp-content/themes/elumine/includes/integrations/google-typography/google-typography.php on line 187
You are getting the errors because on line 186 the $google_fonts_all either does not contain an array with 'family' key or it is not an array. In either case the expression, array_column($google_fonts_all, 'family'), returns empty.
You can extract the later expression into a variable:
$family = array_column((array)$google_fonts_all, 'family');
On the line 187, check for the isset( $google_fonts_all[$font_index]['variants'] ) either in a conditional statement or itenary.
Regards
Eliasu
Wisdom Labs has posted a patch to fix the problem.

A PHP Error was encountered Severity: Notice Message: Undefined index: elements_id Filename: views/showdetail.php Line Number: 17

A PHP Error was encountered
Severity: Notice
Message: Undefined index: elements_id
Filename: views/showdetail.php
Line Number: 17
Help me please!
Error on server openshift but Run on localhost no error.
How to fix?
Do this with each variable
$elements_id=isset($row['elements_id'])?$row['elements_id']):'';
You are trying to use the vale of the index of the array without checking first if is set
<?php
print_r($dataelements);
foreach ($dataelements as $row) {
$elements_id =$row['elements_id'];
$elements_number = $row['elements_number'];
$elements_name = $row['elements_name'];
$elements_principle = $row['elements_principle'];
$elements_standard = $row['elements_standard'];
$elements_indicator = $row['elements_indicator'];
}
?>

Notice: Undefined variable: dbRead in C:\vhosts\phpcs5\lesson07\workfiles\scripts\user_registration.php on line 28

I'm getting this error and after checking for similar errors I verified the syntax is correct. The complete error is;
WRITE OK
READ OK
Notice: Undefined variable: dbRead in C:\vhosts\phpcs5\lesson07\workfiles\scripts\user_registration.php on line 28
Fatal error: Call to a member function quoteInto() on a non-object in C:\vhosts\phpcs5\lesson07\workfiles\scripts\user_registration.php on line 28
My connection is defined as:
$dbwrite = new Zend_Db_Adapter_Pdo_Mysql($write);
$dbread = new Zend_Db_Adapter_Pdo_Mysql($read);
I did a test first to make sure it can see the database which is what the Write OK and Read OK are as follows;
if ($dbwrite->getConnection()) {
echo 'WRITE OK<br/>';
}
if ($dbread->getConnection()) {
echo 'READ OK';
}
So I'm not sure why I'm getting this error.
dbRead is undefined. You've defined $dbread. Note the capitalization.
Look through your code base (particularly user_registration.php line 28) and switch all instances to one or the other.

Codeigniter autoload library with parameters

I'm using FX.php together with Codeigniter to access a Filemaker DB. Library and config file are autoloaded in config/autoload.php.
This setup works perfectly well on my development machine (OS X, PHP 5.3.14). However, when I run the project on our dev server (Ubuntu Precise, PHP 5.3.10), it doesn't work. There seems to be an issue with the config parameters not being passed to the library. I get the following error messages:
Severity: Notice
Message: Undefined index: dataServer
Filename: libraries/CIFX.php
Line Number: 9
Severity: Notice
Message: Undefined index: dataPort
Filename: libraries/CIFX.php
Line Number: 9
Severity: Notice
Message: Undefined index: dataType
Filename: libraries/CIFX.php
Line Number: 9
Severity: Notice
Message: Undefined index: dataURLType
Filename: libraries/CIFX.php
Line Number: 9
My libraries/CIFX.php file looks like this:
require('FX.php');
class CIFX extends FX {
function __construct ($params = array())
{
parent::__construct($params['dataServer'], $params['dataPort'], $params['dataType'], $params['dataURLType']);
}
}
?>
My config/CIFX.php file looks like this:
$config['dataServer'] = '192.168.1.10';
$config['dataPort'] = '80';
$config['dataType'] = 'FMPro7';
$config['dataURLType'] = '';
$config['dbuser'] = '';
$config['dbpassword'] = '';
According to the Codeigniter manual, this should be working.
Any help much appreciated!
you need to be Passing Parameters When Initializing Your Class
$params = array(
'dataServer' => $this->config->item('dataServer');,
'dataPort' => $this->config->item('dataPort');
);
$this->load->library('CIFX ', $params);

Categories