Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in C:\OpenServer\domains\im\inc\plugins\ResourcesPlg.php on line 18
Warning: mysql_free_result() expects parameter 1 to be resource, boolean given in C:\OpenServer\domains\im\inc\plugins\ResourcesPlg.php on line 30
Fatal error: Uncaught exception 'Exception' with message 'Error loading actions1: No database selected' in C:\OpenServer\domains\im\inc\plugins\SalesActionsPlg.php:69 Stack trace: #0 C:\OpenServer\domains\im\inc\plugins\SalesActionsPlg.php(54): SalesActions->__construct() #1 C:\OpenServer\domains\im\inc\core\plugins.php(40) : eval()'d code(1): SalesActions::getInstance() #2 C:\OpenServer\domains\im\inc\core\plugins.php(40): eval() #3 C:\OpenServer\domains\im\inc\core\plugins.php(24): PluginsManager::activate('SalesActions', Array, 'C:/OpenServer/d...') #4 C:\OpenServer\domains\im\inc\cms.php(34): PluginsManager::load() #5 C:\OpenServer\domains\im\index.php(14): require_once('C:\\OpenServer\\d...') #6 {main} thrown in C:\OpenServer\domains\im\inc\plugins\SalesActionsPlg.php on line 69
<?php
/**
* COMCON1-CMS core class.
* Some manipulation with connections &
* query preparation.
*/
class SQLHelper {
function nop() {;}
public static function getInstance() {
static $inst;
if (!isset($inst))
$inst = new SQLHelper();
return $inst;
}
private function __construct() {
$this->connect();
}
protected function connect() {
$this->nop(); // not use static
if (!mysql_connect($GLOBALS['db_host'],$GLOBALS['db_user'],$GLOBALS['db_password'])) {
echo "<center>".mysql_error()."</center>";
die ("<center><b>Could not connect to local database.</b></center><br>");
}
// Выбор базы данных, выделенной для данного сайта
mysql_select_db($GLOBALS['db_database']);
// TODO: parametrization
mysql_query("SET character_set_client = 'cp1251'");
mysql_query("SET character_set_results = 'cp1251'");
mysql_query("SET character_set_connection = 'cp1251'");
}
public function __destruct() {
mysql_close();
}
/**
* Virtual generation of standart UPDATE-query
* @param string $table
* @param map<string,string> $arr
* @param map<string,string> $where
* @return string
*/
static function generateUpdateQuery($table, $arr, $where) {
if (strpos($table, '`')!== false){
$q = "UPDATE $table SET ";
} else {
$q = "UPDATE `$table` SET ";
}
$strings = array();
foreach ($arr as $key => $val) {
if ($val === '%NOW%') {
$strings[] = "`".$key."` = NOW()";
} else {
$strings[] = "`".$key."` = '".$val."'";
}
}
$stringw = array();
//TODO: count = 0
foreach ($where as $key => $val) {
$stringw[] = "( `".$key."` = '".$val."' )";
}
$q = $q.implode(", ", $strings)." WHERE ".implode(" and ", $stringw);
return $q;
}
// static function
static function generateInsertQuery($table, $arr) {
$strings1 = array();
$strings2 = array();
foreach ($arr as $key => $value) {
$strings1[] = "`".$key."`";
if ($value === '%NOW%') {
$strings2[] = "NOW()";
} elseif ( substr($value, 0, 3) == '###' ) {
$strings2[] = str_replace('###','', $value);
} else {
$strings2[] = "'".$value."'";
}
}
$q = "INSERT INTO `$table` (".implode(", ", $strings1).") VALUES (".implode(", ", $strings2).")";
return $q;
}
public static function getTableStructure($name) {
$q = sprintf("DESCRIBE `%s`;", addslashes($name));
$res = mysql__query($q, __CLASS__.'->'.__FUNCTION__);
$structure = array();
while($row = mysql_fetch_object($res)) {
$_a = explode('(', rtrim($row->Type,')'));
$row->Size = @$_a[1];
$row->Type = $_a[0];
if ($row->Type == 'text') $row->Size = 65535;
if ($row->Type == 'tinytext') $row->Size = 255;
if ($row->Type == 'enum') {
$row->Variants = explode("','", trim($row->Size, "'"));
}
$structure[$row->Field] = $row;
}
return $structure;
}
}
?>
$db_host = "localhost";
$db_user = "root";
$db_password = "new-root-mysql-password";
$db_database = "db";
define('dbPreffix', "ge_");
$WEBSITE_NAME = "im";
$WEBSITE_TITLE = "im";
$WWWHOST = $AUTOHOST = "http://im/";
$ABSPATH = "OpenServer/domains/im";
$WEBSITE_COMPANY = "im";
$PREFIX = dbPreffix;
$PHPEXEC = 'OpenServer/modules/php/PHP-5.6';