Hi there,
I’ve started experimenting with the scary prospect of having a Modx form (on a front end) suggest possible existing entries in a MySQL database. When I try and carry out an array creation to read from the MySQL I get an error such as this
Notice: Trying to get property of non-object in E:\AXIS_WIKI\Apache2\htdocs\cms_tests\assets\snippets\Axis_populate_array.php on line 5
Fatal error: Call to a member function select() on a non-object in E:\AXIS_WIKI\Apache2\htdocs\cms_tests\assets\snippets\Axis_populate_array.php on line 5
The php ’file’ has these lines in there:
<? php
global $modx;
global $table_prefix;
$table = $table_prefix.'ppl_info';
$result = $modx->db->select( "pplname", $table, "");
$array_b = $modx->db->makeArray( $result );
}
array defined etc.. echo matching (similar) entries etc..
When ever I try and tell it to run the php as a snippet call (it just drops in an existing page article in to the HTML!
If I straight declare the array in the php (aka bypass any dbapi) I have no such problems.
Has anyone had much joy with this. Is there a way I can get a php page to parse the database table involved (using Modx dbapi) where possible.
Any help (or again pointing out the blindingly obvious) is more than welcome!
Using the below ’simple’ method to try this.
http://www.w3schools.com/PHP/php_ajax_suggest.asp
Cheers
TxRx