Page 1 of 1

Some symbols not printed?

Posted: Tue Dec 30, 2003 4:29 am
by aquila125
Hi there,

I've build my own database connection class with a debug function. If the debug function is on, it should generate some comments in the html file. All works well. This is my source:

Code: Select all

<?php

class MySQL{
	
	var $connection; //Connection for this instance
	var $result = array();
	var $debug=0;
	
	function MySQL($user,$pwd,$dbname,$host,$debug){
		$this->debug=$debug;
		if ($this->debug==1) echo "<!-- DB Connection: ".$dbname." on ".$host." -->\n";
		if (!$this->connection=@mysql_connect($host,$user,$pwd)) echo "<br><span class='error'>Connection to database failed</span><br />\n";
		if (!@mysql_select_db($dbname,$this->connection)) echo "<br><span class='error'>Error: " . mysql_errno() . " : " . mysql_error() . "</span><br />\n";
	}
	
	function query($query){
		if ($this->debug==1) echo "<!-- Query: ".$query." -->\n";		
		if (!$this->result[]=@mysql_query($query,$this->connection)) {
			echo "<br><span class='error'>Error: " . mysql_errno() . " : " . mysql_error() . "</span><br />\n ";
			return false;
		}
		if ($this->debug==1) echo "<!-- Query successful: ".(count($this->result)-1)." query ID-->\n ";		
		return count($this->result)-1;
	}
	
	function iterate($id){
		if ($this->debug==1) echo "<!-- Iterating through resultset -->\n ";
		return mysql_fetch_array($this->result[$id]);
	}
	
	function num_rows($id){
		return mysql_num_rows($this->result[$id]);
	}
	
	function get_var($query){				
		$resultid=$this->query($query);		
		if ($this->debug==1) {
			echo "<!-- get_var: ".$query." successful query -- ID: ".$resultid." -->\n ";
		}
		$row=$this->iterate($resultid);
		return $row[0];		
	}
}
?>
But when I run the get_var function on my local server (Apache) and view the page with Mozilla, I get these lines of comment:

<!-- DB Connection: mobileschool on localhost -->
<!-- Query: SELECT pagetitle FROM pagetitles WHERE pageid=1 AND language='NL' -->
<!-- Query successful: 0 query ID-->
-- get_var: SELECT pagetitle FROM pagetitles WHERE pageid=1 AND language='NL' successful query -- ID: 0 -->
<!-- Iterating through resultset -->

As you see, the <! is missing in front of get_var. Viewing the page with IE, or placing it on a remote server and viewing it both with IE and Mozilla gives me the missing <! (so the line is hidden from normal view).

Is there some strange setting like: 'hide random <! characters for Mozilla Browsers' in Apache that I am unaware of?

tnx!

Posted: Tue Dec 30, 2003 4:50 am
by devork
try using single qoute
it php will print it as it is

Code: Select all

if ($this->debug==1) &#123; 
         echo '<!-- get_var: '.$query." successful query -- ID: ".$resultid." -->\n "; 
      &#125;

Posted: Tue Dec 30, 2003 7:12 am
by aquila125
that didn't work... I don't think there is something wrong with my code... Perhaps something with Apache?