Sinister747 Posted February 8, 2007 Share Posted February 8, 2007 Hi All, I am not a professional at php in anyway at all, but i can get my hands dirty. i recently downloaded a system called "Help Center Live" from www.helpcenterlive.com I had some difficulty's installing it but then i got it fixed, but when i try login i get the below error, and since you guys are no doubht alot better at php and mysql than i am, i am hoping that you can help me. please Error: Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in 'xxxx\hcl\class\database.php on line 265 And that block of code, from line 239 to 309 is below; // Querys whatever is passed into it without SQL validation checking function raw_query($sql, $table, $cache = '', $arg = '') { if ($sql == '') { return false; } if ($arg == '') { $arg = HCL_DB_ROWS; } if ($cache == '') { $cache = HCL_DB_CACHE; } if ($cache == HCL_DB_CLEARCACHE) { $this->clear_cache(); } $this->select_result = ''; if (ereg('^SELECT', $sql)) { // Use cache to reduce database queries if ($cache == HCL_DB_CACHE) { $this->result = $this->get_cache($sql, $table); } else { $this->result = false; } if (!$this->result) { $this->result = mysql_query($sql, $this->id); $this->total_results = 0; Row 256: while ($current_row = mysql_fetch_row($this->result)) { if (($arg == HCL_DB_ALL || $arg == HCL_DB_HEADERS) && $this->total_results == 0) { foreach($current_row as $key => $val) { $this->select_result[$this->total_results][$key] = $this->field($this->result, $key); } $this->total_results++; } if ($arg == HCL_DB_ALL || $arg == HCL_DB_ROWS) { foreach($current_row as $key => $val) { $this->select_result[$this->total_results][$this->field($this->result, $key)] = $val; } $this->total_results++; } } if ($this->select_result !== '') { if ($cache !== HCL_DB_NOCACHE) { $this->set_cache($sql, $table, $this->select_result); } return $this->select_result; } else { if ($cache !== HCL_DB_NOCACHE) { $this->set_cache($sql, $table, false); } return false; } } else { return $this->result; } } else { $this->result = mysql_query($sql, $this->id); if ($this->result && !ereg('^SELECT', $sql)) { if (ereg('^INSERT INTO', $sql)) { $this->clear_cache($table); return $this->id(); } else { $this->clear_cache($table); return $this->affected(); } } else { $this->error = mysql_error($this->id); echo $this->error.'<br /><br />'.$sql; exit; } } } I am hoping someone can see the issue here, if you need anymore info please ask.. all help appreciated alot, thanks in advance Regards, Sinister747 Link to comment https://forums.phpfreaks.com/topic/37597-help-center-live-help-please/ Share on other sites More sharing options...
Sinister747 Posted February 8, 2007 Author Share Posted February 8, 2007 Sorry, is there even a better piece of code to give me a better error message, you know so it outputs the results, or just tell's me to go back to pen and paper because i suck Link to comment https://forums.phpfreaks.com/topic/37597-help-center-live-help-please/#findComment-179769 Share on other sites More sharing options...
JasonLewis Posted February 8, 2007 Share Posted February 8, 2007 change this line, number 254 to this: $this->result = mysql_query($sql, $this->id) or die("Error: ".mysql_error()); Link to comment https://forums.phpfreaks.com/topic/37597-help-center-live-help-please/#findComment-179772 Share on other sites More sharing options...
Sinister747 Posted February 8, 2007 Author Share Posted February 8, 2007 change this line, number 254 to this: $this->result = mysql_query($sql, $this->id) or die("Error: ".mysql_error()); Thanks, it now outputs this error: Error: Unknown column 'admin' in 'where clause' It also showed this error when installing, but it seemed to be because of the MySQL query string, it wasn't formed correctly and it thought that, what it was looking for was actually a column name.. So if you have anymore help, much appreciated, and thanks for the fast reply, also i will try to find the MySQL statement and see can i fix it. Regards, Sinister747 Link to comment https://forums.phpfreaks.com/topic/37597-help-center-live-help-please/#findComment-179775 Share on other sites More sharing options...
JasonLewis Posted February 8, 2007 Share Posted February 8, 2007 what is the $sql variable. can you please post it. because the table you are selecting from does not have the column admin, i would suggest you contact the company about this. Link to comment https://forums.phpfreaks.com/topic/37597-help-center-live-help-please/#findComment-179777 Share on other sites More sharing options...
Sinister747 Posted February 8, 2007 Author Share Posted February 8, 2007 what is the $sql variable. can you please post it. because the table you are selecting from does not have the column admin, i would suggest you contact the company about this. Ok, here are all the Select statements that i think it uses, also Help Center Live is an Open Source project and they don't like to give support.. Select statements below; class Operator { var $result; var $details; var $name; function id() { if (isset($_SESSION['hcl_username']) && isset($_SESSION['hcl_password'])) { if ($this->result = $GLOBALS['db']->query('SELECT * FROM `operators` WHERE `username`="'.$_SESSION['hcl_username'].'" AND `password`="'.$_SESSION['hcl_password'].'"')) { return $this->result[0]['id']; } else { return false; } } else { return false; } } function name($id = '') { if ($id == '') { $id = $this->id(); if (!$this->id()) { return false; } } $this->result = $GLOBALS['db']->query('SELECT `username`, `firstname`, `lastname` FROM `operators` WHERE `id`="'.$id.'"'); $this->name = $GLOBALS['conf']['operator_name']; $this->name = str_replace('USERNAME', htmlspecialchars($this->result[0]['username']), $this->name); $this->name = str_replace('FIRSTNAME', htmlspecialchars($this->result[0]['firstname']), $this->name); $this->name = str_replace('LASTNAME', htmlspecialchars($this->result[0]['lastname']), $this->name); return $this->name; } function username($id = '') { if ($id == '') { $id = $this->id(); if (!$this->id()) { return false; } } $this->result = $GLOBALS['db']->query('SELECT `username` FROM `operators` WHERE `id`="'.$id.'"'); return $this->result[0]['username']; } function online($id = '') { if ($id == '') { $id = $this->id(); if (!$this->id()) { return false; } } if ($GLOBALS['db']->query('SELECT * FROM `operators` WHERE `id`="'.$id.'" AND `timestamp`>"'.(time() - $GLOBALS['conf']['live_timeout']).'"')) { return true; } else { return false; } } function sounds($id = '') { if ($id == '') { $id = $this->id(); if (!$this->id()) { return false; } } $this->result = $GLOBALS['db']->query('SELECT `sounds` FROM `operators` WHERE `id`="'.$id.'"'); if ($this->result[0]['sounds'] == '1') { return true; } else { return false; } } function autosave_transcripts($id = '') { if ($id == '') { $id = $this->id(); if (!$this->id()) { return false; } } $this->result = $GLOBALS['db']->query('SELECT * FROM `operators` WHERE `id`="'.$id.'"'); if ($this->result[0]['autosave'] == '1') { return true; } else { return false; } } function picture($id = '') { if ($id == '') { $id = $this->id(); if (!$this->id()) { return false; } } if ($this->result = $GLOBALS['db']->query('SELECT `picture` FROM `operators` WHERE `id`="'.$id.'"')) { return base64_decode($this->result[0]['picture']); } else { return ''; } } function boot($id = '') { if ($id == '') { $id = $this->id(); if (!$this->id()) { return false; } } if ($id == '0') { $GLOBALS['db']->query('DELETE FROM `activity` WHERE 1'); $GLOBALS['db']->query('DELETE FROM `sessions` WHERE 1'); $GLOBALS['db']->query('UPDATE `operators` SET `timestamp`="9" WHERE 1'); } else { $GLOBALS['db']->query('DELETE FROM `activity` WHERE `operatorid`="'.$id.'"'); $GLOBALS['db']->query('DELETE FROM `sessions` WHERE `operatorid`="'.$id.'"'); $GLOBALS['db']->query('UPDATE `operators` SET `timestamp`="9" WHERE `id`="'.$id.'"'); } } function showpic($id = '') { if ($id == '') { $id = $this->id(); if (!$this->id()) { return false; } } if ($this->result = $GLOBALS['db']->query('SELECT `showpic` FROM `operators` WHERE `id`="'.$id.'"')) { return $this->result[0]['showpic']; } else { return false; } } function get($id = '') { if ($id == '') { $id = $this->id(); if (!$this->id()) { return false; } } if ($this->result = $GLOBALS['db']->query('SELECT * FROM `operators` WHERE `id`="'.$id.'"')) { return $this->result[0]; } else { return false; } } Link to comment https://forums.phpfreaks.com/topic/37597-help-center-live-help-please/#findComment-179778 Share on other sites More sharing options...
Sinister747 Posted February 8, 2007 Author Share Posted February 8, 2007 Just so you know, during installation, when it was adding the username "admin" to the database, it gave the same error, also when i fixed that it said the same error but for the password etc etc, i had to go into phpMyAdmin and get it to generate the phpcode and then replace it. Hope that explains what is happening... Link to comment https://forums.phpfreaks.com/topic/37597-help-center-live-help-please/#findComment-179780 Share on other sites More sharing options...
JasonLewis Posted February 9, 2007 Share Posted February 9, 2007 from looking at that first code, the query is called from another page. which page are you running to get this error. open the page and search for: raw_query there may be a couple. so look for the one with 'admin' in the where clause. Link to comment https://forums.phpfreaks.com/topic/37597-help-center-live-help-please/#findComment-180487 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.