Menu

MySQL error

Help
2007-05-31
2013-04-16
  • Clecio Dias

    Clecio Dias - 2007-05-31

    Hi.

    I tried to install the idcms, but following alll the short instructions I only get this response from the we webserver (Apache 2.0) using PHP 5.2.2 and MySQL 5.0:

    "; print"
    Mysql Message

    "; if( $query == '' ) return 0; global $SQL_INT; if( !isset($SQL_INT) ) $SQL_INT = 0; //[dv] this has to come first or you will have goofy results later. $query = preg_replace("/['\"]([^'\"]*)['\"]/i", "'
    $1'", $query, -1); $query = str_ireplace( array ( '*', 'SELECT ', 'UPDATE ', 'DELETE ', 'INSERT ', 'INTO', 'VALUES', 'FROM', 'LEFT', 'JOIN', 'WHERE', 'LIMIT', 'ORDER BY', 'AND', 'OR ', //[dv] note the space. otherwise you match to 'COLOR' ;-) 'DESC', 'ASC', 'ON ' ), array ( "*", "SELECT ", "UPDATE ", "DELETE ", "INSERT ", "INTO", "VALUES", "FROM", "LEFT", "JOIN", "WHERE", "LIMIT", "ORDER BY", "AND", "OR ", "DESC", "ASC", "ON " ), $query ); echo "
    SQL[".$SQL_INT."]: ".$query."; \n"; $SQL_INT++; print"
    "; } function connectDbMysql($connection,$username,$database,$password) { $this->connection=$connection; $this->username=$username; $this->databaseName=$database; $this->password=$password; if($this->mysql_version=='normal') { $this->link=mysql_connect($this->connection,$this->username,$this->password); } elseif($this->mysql_version=='lite') { $this->link=mysqli_connect($this->connection,$this->username,$this->password,$this->databaseName,$this->port,$this->socket); } if(!$this->link) { if($this->mysql_version=='normal') { echo $this->SQL_DEBUG($this->sql."
    ".mysql_error()); exit; } elseif($this->mysql_version=='lite') { echo $this->SQL_DEBUG($this->sql."
    ".mysqli_error()); exit; } } else { if($this->mysql_version=="normal") { $resources=mysql_select_db($this->databaseName,$this->link); } elseif($this->mysql_version=="lite") { $resources=mysqli_select_db($this->link,$this->databaseName); } if(!$resources) { echo $this->SQL_DEBUG($this->sql."
    ".mysql_error()); exit; } } } function date_query($sql,$rowname,$date1,$type) { $this->type=NULL; $this->rowname=NULL; $this->date1=NULL; $this->sql=NULL; $this->type=$type; $this->rowname=$rowname; $this->date1=$date1; $this->sql=$sql; //get variable date $day=substr($this->date1,6,2); $month=substr($this->date1,4,2); $year=substr($this->date1,0,4); if($this->type=="day") { return($this->sql." and `".$this->tablename."`.`".$this->rowname."`='".$_GET['date']."'"); } elseif($this->type=="month") { return($this->sql." and month(`".$this->tablename."`.`".$this->rowname."`)='".$_GET['month']."' and year(`".$this->tablename."`.`".$rowname."`)='".$_GET['year']."'"); } elseif($this->type=="year") { return($this->sql." and year(`".$this->tablename."`.`".$this->rowname."`)='".$_GET['year']."'"); } elseif($this->type=="between") { return($sql."and `".$this->tablename."`.`".$this->rowname."` between '".$_GET['date1']."' and '".$_GET['date2']."' "); } } // this function parse sql value function dataType($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue; switch ($theType) { case "text": $theValue = ($theValue != "") ? " " . $theValue . " " : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? " " . doubleval($theValue) . " " : "NULL"; break; case "date": $theValue = ($theValue != "") ? " " . $theValue . " " : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } function sort_query($sql,$rowname,$type) { $this->type=NULL; $this->rowname=NULL; $this->sql=NULL; $this->type=$type; $this->rowname=$rowname; $this->sql=$sql; $total_row=count($this->rowname); if($this->type=='sort') { $revert=' and ('; for($d=0;$d<$total_row;$d++) { $this->sql=$this->sql.$revert." ".$this->rowname[$d]." like '".$_GET['value']."%'"; $revert=' or '; } $this->sql=$this->sql." ) "; return($this->sql); } elseif($this->type=='search') { $revert=' and ( '; for($d=0;$d<$total_row;$d++) { $this->sql=$this->sql.$revert." ".$this->rowname[$d]." like '%".$_GET['value']."%'"; $revert=' or '; } $this->sql=$this->sql." ) "; return($this->sql); } elseif($this->type=='exact') { $revert=' and ( '; for($d=0;$d<$total_row;$d++) { $this->sql=$this->sql.$revert." ".$this->rowname[$d]." = '".$_GET['value']."'"; $revert=' or '; } return($this->sql)." ) "; } elseif($this->type=='id') { return($this->sql."and `".$this->rowid."`='".$_GET['value']."'"); } elseif($this->type='else') { return($this->sql."and `".$this->rowname."`='".$_GET['value']."'"); } } function query($sql,$type) { $this->sql=NULL; $this->type=NULL; $this->sql=$sql; $this->type=$type; if($this->mysql_version=='normal') { $result=mysql_query($this->sql,$this->link); //mysql query // debugging only purpose echo $this->SQL_DEBUG($this->sql); } elseif($this->mysql_version=='lite') { $result=mysqli_query($this->link,$this->sql,$this->resultmode); // mysqlite query } if(!$result) { if($this->mysql_version=='normal') { echo $this->SQL_DEBUG($this->sql."
    ".mysql_error()); } elseif($this->mysql_version=='lite') { echo $this->SQL_DEBUG($this->sql."
    ".mysqli_error()); } return 0; } else { if($this->mysql_version=='normal') { $total_record=@mysql_num_rows($result); } elseif($this->mysql_version=='lite') { $total_record=mysqli_num_rows($result); } if(!$total_record) { return 0; } else { if($this->type=='result') { if($total_record==0) { return 0; } else { return $result; } } elseif($this->type=='totalrecord') { return $total_record; } } } } function module($operation) { // for more secure option must set at mysql access grant level // if 1 access granted which mean 1 record if null no mean no access to the db level $this->operation=NULL; $this->operation=$operation; $sql_operation="select * from `access` where `access`.`module`='".$this->tablename."' and `access`.`".$this->operation."`='1' and `humanId`='".$_SESSION['MM_Username']."'"; $result_operation=mysql_query($sql_operation) or die(mysql_error()); //log the database table any operation either it was access granted or not $result_row=@mysql_num_rows($result_operation); if($result_row==1) { $result_text='Granted'; } elseif($result_row==0) { $result_text='Denied'; } $sql_log="insert into `log` ( `module`, `operation`, `date`, `userId`, `access` ) values ( '".$this->tablename."', '".$this->operation."', NOW(), '".$_SESSION['MM_Username']."', '".$result_text."' )"; mysql_query($sql_log) or die(mysql_error()); return($result_row); } function query_page($sql) { if($this->module('access_view') == 1) { $this->sql=NULL; $this->countRecord=NULL; $this->sql=$sql; //echo $this->sql; $this->countRecord=$this->query($this->sql,'totalrecord'); $limitQuery=" order by `".$this->tablename."`.`".$this->rowid."` desc"." limit ".$this->offset.",".$this->limit; $this->sql=$this->sql.$limitQuery; return($this->query($this->sql,'result')); } else { print""; } } function query_delete() { if(isset($_GET['mode'])) { if($_GET['mode']==3) { if($this->module('access_delete')== 1) { $sql="delete from `".$this->tablename."` where `".$this->rowid."`='".$_GET[$this->rowid]."'"; mysql_query($sql) or die(mysql_error()); if(isset($_GET['assetId']) && !empty($_GET['assetId']) ) { print""; } else { print""; } } // ni mana dtg ni ? else { print""; } } } // php can input directly get mode } function query_insert($sql) { if($this->module('access_insert')==1) { $this->sql=NULL; $this->sql=$sql; return($this->query($this->sql,'result')); } else { print""; } } function query_update($sql) { if($this->module('access_update')==1) { $this->sql=NULL; $this->sql=$sql; return($this->query($this->sql,'result')); } else { print""; } } function query_view($sql) { if($this->module('access_view')==1) { $this->sql=NULL; $this->sql=$sql; return($this->query($this->sql,'result')); } else { print""; } } function debug() { // this is call ansseor. print"
    "; print"
    Mysql Query

    "; echo $this->SQL_DEBUG($this->sql); print"
    "; } function record() { // this is call ansseor. return($this->countRecord); } function close() { // close mysql connections mysql_close($this->link); } } ?>

    I'm trying to find in the code some answer, but maybe you can help me.

    Thanks

    Clecio

     
    • idcms

      idcms - 2007-06-01

      I tested the application on two type of mysql5 and mysql community xampp.Can you give your platform problem.Mysql version 5.xxx the detail.I will try to test in my computer again.I not yet tested  on linux enviroment yet :(

      Can you login at the page?
      Default login
      username: root
      password:nazilah

      if there are problem before loading at the page .I will check it out immediaty

      If you want to find error on the page or to check what's the query about.
      <?
      $q->debug($sql);
      ?>
      Paste at the bottom of the page
      Manual are at readme.doc

       
    • raoul

      raoul - 2007-06-01

      Hi,

      I solved this problem.
      The PHP code contains a lot of short_open_tags !!
      So <? instead of <?php

      This can be solved by changing your PHP.INI

      Short_open_tag = On

      Regards
      Raoul

       

Log in to post a comment.