roadmap Posted December 9, 2006 Share Posted December 9, 2006 (edited) Hello, I am getting an error in my script and I was wondering if someone could view the code and possibly spply a solution. The error is below and the entire code. The error line is bold and underlined also. Thank in advance. >Fatal error: Cannot access empty property in (MY PATH) db_mysql.php on line 129 <?php class sqldb { var $scriptname = ""; //nama script ni var $user=""; var $pass=""; var $server=""; var $database=""; var $query_id = 0; // query id var $query_counter = 0; var $link_id = 0; var $use_persistent = "0"; var $insert_into = ""; var $insert_data = array(); /* ----------------------------------------------------------- */ function start($server,$user,$password,$database) { $this->server = $server; $this->user = $user; $this->pass = $password; $this->database = $database; $this->connect(); } function connect() { if ($this->use_persistent == 0) { $this->link_id = mysql_connect($this->server,$this->user,$this->pass); } else { $this->link_id = mysql_pconnect($this->server,$this->user,$this->pass); } if (!$this->link_id) { $this->error("Connection to Database ".$this->database." Failed"); } if(!@mysql_select_db($this->database, $this->link_id)) { $this->error("This database (".$this->database.",)cannot be used"); } unset ($this->password); } function show_all() { return "<br /><br /><b> Debug Mode - All Queries :</b><hr size=1> ".$this->query_show."<br />"; } function query($string) { if (trim($string != "")) { $this->query_counter++; $this->query_show .= stripslashes($string)."<hr size='1'>"; $this->query_id = mysql_query($string); } if (!$this->query_id) { $this->error("mySQL Error on Query : ".$string); } return $this->query_id; } function query_insert() { if ( $this->insert_into && (is_array($this->insert_data)) ) { $this->query_counter++; $this->query_show .= stripslashes($string)."<hr size='1'>"; foreach ($this->insert_data as $key => $val) { $value .= $key."='".$val."',"; } if ( (substr($value,-1)) == "," ) { $value = substr($value,0,-1); } $this->query_id = mysql_query("INSERT INTO ".$this->insert_into." SET $value"); } if (!$this->query_id) { $this->error("mySQL Error on Query : ".$string); } return $this->query_id; } function fetch_array($query_id=-1) { if ($query_id != -1) { $this->query_id = $query_id; } $this->result = mysql_fetch_array($this->query_id); return $this->result; } function free_result($query_id=-1) { if ($query_id != -1) { $this->query_id = $query_id; } return @mysql_free_result($this->query_id); } function query_once($query_string) { $this->query($query_string); $get = $this->fetch_array($this->query_id); $this->free_result($this->$query_id); return $get; } function num_rows($query_id=-1) { if ($quert_id != -1) { $this->query_id=$query_id; } return mysql_num_rows($this->query_id); } function insert_id() { return mysql_insert_id($this->link_id); } function get_errordesc() { $this->error=mysql_error(); return $this->error; } function get_error_no() { $this->errorno=mysql_errno(); return $this->errorno; } function close() { mysql_close(); } function error($msg) { global $HTTP_SERVER_VARS,$root; $this->error_desc=mysql_error(); $this->error_no=mysql_errno(); $the_error = "<b>WARNING!</b><br />"; $the_error .= "DB Error $this->scriptname: $msg <br /> Some more usefull information you might want to know: <br />"; $the_error .= "<li> Mysql Error : $this->error_desc"; $the_error .= "<li> Mysql Error no # : $this->error_no"; $the_error .= "<li> Date : ".date("F j, Y, g:i a"); $the_error .= "<li> Referer: ".$HTTP_SERVER_VARS['HTTP_REFERER']; $the_error .= "<li>Script: ".$HTTP_SERVER_VARS['REQUEST_URI']; echo $the_error; die(); } } // end of class ?> Edited December 9, 2006 by roadmap Quote Link to comment Share on other sites More sharing options...
Steve Scrimpshire Posted December 11, 2006 Share Posted December 11, 2006 (edited) Just a quick glance because I don't have much time tonight, but a few lines below your error line, there is a function that looks like this: function num_rows($query_id=-1){ if ($quert_id != -1) { $this->query_id=$query_id; } return mysql_num_rows($this->query_id); } Note the bold variable name. I don't know if that was just a typo while putting the code here or if it is a typo in your actual code, but it might be worth looking into. Soon, I may have more time to give it an indepth look. P.S. If you put your code example inside [ code] [ /code] tags (without the extra spaces, of course) in the forum, your code will stay formatted correctly and be easier to read. Of course, if you want to bold or underline something in your code, you'll have to use [ quote] [ /quote] tags instead, in which case, you'll lose your formatting. Edited December 11, 2006 by Steve Scrimpshire Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.