Terrel Asked: I was installing a blog on my site
I think this may have effect my directory? I clicked on the link to my directory and this is the messages I recieved:
“Fatal error: Call to a member function on a non-object in /home/costa/public_html/directory/include/functions.php on line 47”
I don’t know much about php but here is info for lines 40-51 I checked with dreamweaver
40 */ 41 function read_config($db) { 42 global $tables, $tpl; 43 $sql = “SELECT * FROM {$tables[‘config’][‘name’]}”; 44 $db->SetFetchMode(ADODB_FETCH_ASSOC); 45 $rs = $db->Execute($sql); 46 while (!$rs->EOF) { 47 define($rs->Fields(‘ID’), $rs->Fields 48 (‘VALUE’)); 49 $rs->MoveNext(); 50 } 51 } |
Here is the whole code
<?php
function read_config($db) { function get_tpl() { function _L($str) { function get_table_data($table) { function get_categs_tree($db, $id) { while (!$rs->EOF) { function get_grant_categs_tree($db, $id) { while (!$rs->EOF) { function get_client_ip() { function get_page($list_total) { function request_uri() { //IIS with ISAPI_REWRITE function get_category($uri = NULL) { function validate_link($url) { function validate_url_online($value, $empty, & $params, & $form) { function validate_recpr_link($value, $empty, & $params, & $form) { function check_recpr_link($data) { define(‘URL_RESPONSE’, 0); } function parse_news($str) { function validate_unique($value, $empty, & $params, & $form) { function check_unique($table, $field, $value, $exclude_id = NULL, $parent_field = NULL, $parent_value = NULL) { function validate_symbolic_unique($value, $empty, & $params, & $form) { function validate_symbolic_parent($value, $empty, & $params, & $form) { function validate_not_equal($value, $empty, & $params, & $form) { function validate_not_equal_var($value, $empty, & $params, & $form) { function parse_version($val) { if (!function_exists(‘file_get_contents’)) { function replace_email_vars($text, $data, $type = 1) { function get_emailer() { function get_emailer_admin(){ function db_replace($table, $data, $keyCol) { function send_submit_notifications($data) { $tmpl = $notif_msg[‘submit’]; function date_add($timestamp, $months) { function calculate_expiry_date($start, $units, $um) { function update_link_payment($pid, $data, $success, $raw) { $pdata = $db->GetRow(“SELECT * FROM {$tables[‘payment’][‘name’]} WHERE ID = “.$db->qstr($pid)); } function sprint_r($val) { function numeric_entify_utf8($utf8_string) { function xml_utf8_encode($str){ function validate_email_and_add_link($value, $empty, & $params, & $form) { function validate_not_sub_category($value, $empty, & $params, & $form) { $category = $value; $sql = “SELECT PARENT_ID FROM “.$tables[‘category’][‘name’].” WHERE ID = “. $form[‘CATEGORY_ID’]; if ($category != 0) { $count_sql = “SELECT COUNT(*) FROM “.$tables[‘user_permission’][‘name’].” WHERE USER_ID = “.$db->qstr($u). ” AND (CATEGORY_ID = ” . $category; while ($category != 0) { function find_child_categories() { $child_count = 0; $rs = $db->Execute(“SELECT CATEGORY_ID FROM {$tables[‘user_permission’][‘name’]} WHERE USER_ID = “.$db->qstr($u)); while (!$rs->EOF) { $category = $row[‘CATEGORY_ID’]; while ($category != 0) { return $child_count; function delete_child_categories() { $child_count = 0; $rs = $db->Execute(“SELECT ID, CATEGORY_ID FROM {$tables[‘user_permission’][‘name’]} WHERE USER_ID = “.$db->qstr($u)); while (!$rs->EOF) { $category = $row[‘CATEGORY_ID’]; while ($category != 0) { function get_editor_permission($user_id) { $all_first_iteration = true; $rs = $db->Execute(“SELECT CATEGORY_ID FROM {$tables[‘user_permission’][‘name’]} WHERE USER_ID = “.$db->qstr($user_id)); while (!$rs->EOF) { $user_permission_array[] = $row[‘CATEGORY_ID’]; $new_sub_categories = get_sub_categories($db, $row[‘CATEGORY_ID’]); foreach ($new_sub_categories as $category_id) { } function get_sub_categories($db, $id) { ?> |
How can this be fixed?
Hues asked: Just checked your directory, its working fine. , how did you fix this? I am having the same problem
Tarheit replied: I was able to fix it in my case by adding the following line to the beginning of index.php, submit.php, etc.
global $tables, $tpl, $db;
I think for some reason when the files .php files are included inside the blog (or cms in my case) they simply don’t get reconized as global and can’t be found by various functions that expect them.
This might vary depending on what you are trying to plug in to your cms/blog. Another real-estate system I had to plug in required the global statements to be added to the index.php of the cms rather than just the index.php of application I was trying to add on. So if the first doesn’t work, then try the other.
I should add that if your cms/blog already uses those variables elsewhere you could end up with a conflict requireing you to rename all references to the variable in the phpLD code.
(I suspect the orginal poster didn’t get it quite working yet as it appears it hasn’t been pluged into the blog, at least in the link he posted.)
My directory isn’t quite finished yet. It works, but I haven’t setup categories, etc. Just a few for testing. And I’m still working on the appearance. I also reworked the templates to have SEO links that fit within my current CMS.