Jump to content

Lamez

Members
  • Posts

    1,686
  • Joined

  • Last visited

    Never

Posts posted by Lamez

  1. You are a genius, why did I not think of that? So I commented out main.php and it worked. Then I went and starting commenting out each include to see which one it is. Turns out, when I comment out Email.php it works. Now I have to figure out what is in Email.php that is doing this!

     

    Another side note: I did it right when you where typing, I guess we are on the same page.

  2. Oh ya!

    <?php
    
    $path = "";
    
    include($path."core/includes/constants.php");
    
    include($path."core/includes/Database.php");
    
    include($path."core/includes/Form.php");	
    
    include($path."core/includes/Html.php");
    
    include($path."core/includes/Email.php");	
    
    include($path."core/includes/Session.php");
    
    include($path."core/includes/Password.php");
    
    include($path."core/includes/Page.php");
    
    ?>
    
    
    

  3. Sure, mind it is long and a split up template I downloaded. Side note: I hate using pre-made templates, but I am kind of on a time crunch.

     

    header.php

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>title</title>
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    <link href="style/default.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
    <!--
    @import url("style/layout.css");
    -->
    </style>
    </head>
    <body>
    <div id="wrapper" class="bg4">
    <div id="menus">
    	<p class="style1" id="mainmenu"></p>
    	<p class="style1" id="topmenu"><a href="#">Home</a>  |  <a href="#">Contact</a></p>
    </div>
        <br />
    <center><font size="6">Krazy Pickem</font></center>
        <br />
    <div id="content" class="two-col">
    	<div class="colA bg10">
    		<div id="box1" class="box bg6">
    			<div class="bg7">
    				<div class="title">
    					<h2 class="text1"><b>Top Ten Players</b></h2>
    				</div>
    				<div class="content bg5">
    					<ul class="ul1">
    						<li class="toplink"><a href="#" class="link1"><b>Vestibulum gravida</b></a></li>
    
    					</ul>
    				</div>
    			</div>
    			<div class="extra">
    				<div class="extraL"></div>
    				<div class="extraR"></div>
    			</div>
    		</div>
    		<!-- end #box1 -->
    	</div>
    	<!-- end .colA -->
    	<div class="colB">
    		<div class="bg16">
    			<div class="bg17">
    				<div id="search" class="bg12">
    				<p class="text2"></p>
    					<a href="#" class="link2"></a> 
                            </div>
    				<!-- end #search -->
    				<div id="box7" class="bg15">
    
    

     

    footer.php

    
    					<h2 class="text4"><b>title</b></h2>
    					<p class="text5">Date Went here</p>
    				</div>
    				<!-- end #box7 -->
    				<div id="box8" class="bg18" style="padding-bottom:1px;">
    					<p>Content Sun of a gun</p>
    				</div>
    				<!-- end #box8 -->
    				<div style="clear: both"></div>
    			</div>
    		</div>
    		<div class="extra">
    			<div class="extraL"></div>
    			<div class="extraR"></div>
    		</div>
    	</div>
    	<!-- end .colB -->
    	<br style="clear: both" />
    </div>
    </div>
    <div id="footer" class="bg21">
    <div class="extraL"></div>
    <p class="style2">Copyright or something</p>
    <div class="extraR"></div>
    </div>
    </body>
    </html>
    

     

    I still don't understand.

  4. I am getting nothing but my HTML outputted. Here is a screen shot: http://i.imgur.com/yoetz.png

     

    I have tested this on three different Apache servers, so I know it is not the settings. I am clueless and not sure why this is happening. Here is some code:

     

    <?php
    include("core/main.php");
    //$page = new Page("New", "");
    //$page->header();
    //$page->footer();
    include("core/includes/pages/header.php");
    echo "STUFF";
    include("core/includes/pages/footer.php");
    ?>
    

     

    Hey, thanks guys. I am unsure. I am not really sure on what code I should post. That is the exact code from the screen shot. Please help me solve this riddle!

  5. I am currently working on my email class, it works but I am do slight modifications to make it a little better.

    Here is the function I am working on:

    	function addAccount($name, $email, $username, $password, $protocol, $port, $server){
    		if(!empty($name) && !empty($email) && !empty($username) && !empty($password) && !empty($protocol) && !empty($port) && !empty($server)){
    			echo $this->db->select(TBL_SMTP, "email", "email = '$email'")->numRows();// This line here returns -1
    			if($this->db->select(TBL_SMTP, "email", "email = '$email'")->numRows() == 0){
    				$name = ucwords(strtolower($name));
    				$email = strtolower($email);
    				$this->db->execute("INSERT INTO ".TBL_SMTP." (name, email, username, password, protocol, port, server) VALUES ('$name', '$email', '$username', '$password', '$protocol', '$port', '$server')");
    				return true;
    			}else
    				return false;
    		}
    		return false;
    	}
    

     

    Notice the line I marked that said, this returns -1. Well I thought if it did not exist in the database, that it was suppose to return 0? Any help?

     

    Oh here is my database class:

    <?php
        class Database{
            var $mysqli, $result, $q, $affectedRows;
            function __construct($host, $user, $pass, $db){
                $this->mysqli = new MySQLi($host, $user, $pass, $db);
            }
            function execute($query, $error = false, $mode = MYSQLI_STORE_RESULT){
                $this->q = $query;
                if(!$error)
                    $result = $this->mysqli->query($query, $mode);
                else
                    $result = $this->mysqli->query($query, $mode) or die($this->mysqli->error);
                    
                if(is_object($result) && $result instanceof MySQLi_Result){//if result is a object and is part of the mysqli class?
                    $this->result = $result;
                    $this->affectedRows = $this->result->num_rows;
                }else
                    $this->affectedRows = $this->mysqli->affected_rows;
                return $this;
            }
            function fetchRow($mode = MYSQLI_ASSOC){
                return $this->result->fetch_assoc($mode);
            }
            function fetchAll($mode = MYSQLI_ASSOC){
                $row = $this->result->fetch_all($mode);
                return !empty($row) ? $row : array();//if not empty return row, else return an array?
            }
            function numRows(){
                return $this->affectedRows;
            }
            function delete($table, $where){
                return $this->execute("DELETE FROM ".$table." WHERE ".$where);
            }
            function deleteAll($table){
                return $this->execute("TRUNCATE ".$table);
            }
            function update($table, $set, $where){
                return $this->execute("UPDATE ".$table." SET ".$set." WHERE ".$where);
            }
            function select($table, $select = "*", $where = NULL){
                if(is_null($where))
                    $where = "";
                return $this->execute("SELECT ".$select." FROM ".$table." ".$where);
            }
            function resetInc($table, $inc){
                $this->execute("ALTER TABLE ".$table." AUTO_INCREMENT = ".$inc);
            }
        }
        $db = new Database(DB_HOST, DB_USER, DB_PASS, DB_DB);
    ?>

     

    Hey, Thanks guys!

  6. So I am trying to run my execute function from my database class from my email class. I have SMTP system to handle emails on the website. I am working on a function in the email class called addAccount. It is suppose to add a row in the database under the SMTP table. When I run the function, I get no parsing errors, so I add the or die to my query from the execute function, still nothing at all.

    So here is some code:

     

    -The addAccount function from Email.php:

    function addAccount($name, $email, $username, $password, $protocol, $port, $server){
    		//Error checking & cleaning vars. will be done in the application, not the backend.
    		if(!empty($name) && !empty($email) && !empty($username) && !empty($password) && !empty($proctocol) && !empty($port) && !empty($server)){
    			$name = ucwords(strtolower($name));
    			$email = strtolower($email);
    			$this->db->execute("INSERT INTO ".TBL_SMTP." (name, email, username, password, protocol, port, server) VALUES ('$name', $email', '$username', '$password' '$protocol', '$port', '$server')", true);
    			return true;
    		}else
    			return false;
    	}
    

     

    -The entire email class from Email.php

    <?php
    require_once("pear/Mail.php");
    class Email{
    	var $from_name, $from_email, $to_name, $to_email, $subject, $body, $host, $port, $username, $password;
    	private $db = NULL;
    	function __construct(Database $db){
    		$this->db = $db;
    	}
    	function dbEmail($id, $name, $email, $subject, $body){
    		$q = $this->db->select(TBL_SMTP, "*", "id='".$id."'");
    		if($q->numRows() > 0){
    			$f = $q->fetchRow();
    			$this->from_name = $f['name'];
    			$this->from_email = $f['email'];
    			$this->username = $f['username'];
    			$this->password = $f['password'];
    			$this->host = $f['protocol']."://".$f['server'];
    			$this->port = $f['port'];
    			$this->to_name = $name;
    			$this->to_email = $email;
    			$this->subject = $subject;
    			$this->body = $body;
    			return sendEmail();
    		}else
    			return false;
    	}
    	function sendEmail(){
    		$from = $this->from_name." <".$this->from_email.">";
    		$to = $this->to_name." <".$this->to_email.">";
    		$headers = array ('From' => $this->from,
      					  			'To' => $this->to,
      					  		'Subject' => $this->subject);		  
    			$smtp = Mail::factory('smtp',
    			array ( 'host' => $this->host,
        			   	'port' => $this->port,
        				'auth' => true,
        			'username' => $this->username,
        			'password' => $this->password));
    		$mail = $smtp->send($to, $headers, $this->body);
    		if(PEAR::isError($mail)){
      				//echo($mail->getMessage()); //For debugging purposes only
    			return false;
    			}else
      				return true;
    	}
    	function addAccount($name, $email, $username, $password, $protocol, $port, $server){
    		//Error checking & cleaning vars. will be done in the application, not the backend.
    		if(!empty($name) && !empty($email) && !empty($username) && !empty($password) && !empty($proctocol) && !empty($port) && !empty($server)){
    			$name = ucwords(strtolower($name));
    			$email = strtolower($email);
    			$this->db->execute("INSERT INTO ".TBL_SMTP." (name, email, username, password, protocol, port, server) VALUES ('$name', $email', '$username', '$password' '$protocol', '$port', '$server')", true);
    			return true;
    		}else
    			return false;
    	}		
    }
    $email = new Email($db);
    ?>
    

     

    The entire database class from Database.php

    <?php
    class Database{
    	var $mysqli, $result, $q, $affectedRows;
    	function __construct($host, $user, $pass, $db){
    		$this->mysqli = new MySQLi($host, $user, $pass, $db);
    	}
    	function execute($query, $error = false, $mode = MYSQLI_STORE_RESULT){
    		$this->q = $query;
    		if(!$error)
    			$result = $this->mysqli->query($query, $mode);
    		else
    			$result = $this->mysqli->query($query, $mode) or die($this->mysqli->error);
    
    		if(is_object($result) && $result instanceof MySQLi_Result){//if result is a object and is part of the mysqli class?
    			$this->result = $result;
    			$this->affectedRows = $this->result->num_rows;
    		}else
    			$this->affectedRows = $this->mysqli->affected_rows;
    		return $this;
    	}
    	function fetchRow($mode = MYSQLI_ASSOC){
    		return $this->result->fetch_assoc($mode);
    	}
    	function fetchAll($mode = MYSQLI_ASSOC){
    		$row = $this->result->fetch_all($mode);
    		return !empty($row) ? $row : array();//if not empty return row, else return an array?
    	}
    	function numRows(){
    		return $this->affectedRows;
    	}
    	function delete($table, $where){
    		return $this->execute("DELETE FROM ".$table." WHERE ".$where);
    	}
    	function deleteAll($table){
    		return $this->execute("TRUNCATE ".$table);
    	}
    	function update($table, $set, $where){
    		return $this->execute("UPDATE ".$table." SET ".$set." WHERE ".$where);
    	}
    	function select($table, $select = "*", $where = NULL){
    		if(is_null($where))
    			$where = "";
    		return $this->execute("SELECT ".$select." FROM ".$table." ".$where);
    	}
    }
    $db = new Database(DB_HOST, DB_USER, DB_PASS, DB_DB);
    ?>
    

     

    Chances are it is my email class since it was 100% written by me. The database class I had some help from a member here.

     

    What do you experts think?

  7. I am new to classes, I was returning to one of my forever long projects to return to this error:

     

    Notice: Undefined property: Database::$numRows in C:\Wamp\www\Webby\core\includes\Email.php on line 11

     

    Here is line 11:

    if($q->numRows > 0){

     

    After staring at it for an hour, I was hoping to find some help from you guys:

    <?php
    require_once("pear/Mail.php");
    class Email extends Database{
    	var $from_name, $from_email, $to_name, $to_email, $subject, $body, $host, $port, $username, $password;
    	private $db = NULL;
    	function __construct(Database $db){
    		$this->db = $db;
    	}
    	function dbEmail($id, $name, $email, $subject, $body){
    		$q = $this->db->select(TBL_SMTP, "*", "id='".$id."'");
    		if($q->numRows > 0){
    			$f = $q->fetchRow();
    			$this->from_name = $f['name'];
    			$this->from_email = $f['email'];
    			$this->username = $f['username'];
    			$this->password = $f['password'];
    			$this->host = $f['protocol']."://".$f['server'];
    			$this->port = $f['port'];
    			$this->to_name = $name;
    			$this->to_email = $email;
    			$this->subject = $subject;
    			$this->body = $body;
    			return sendEmail();
    		}else
    			return false;
    	}
    	function sendEmail(){
    		$from = $this->from_name." <".$this->from_email.">";
    		$to = $this->to_name." <".$this->to_email.">";
    		$headers = array ('From' => $this->from,
      					  			'To' => $this->to,
      					  		'Subject' => $this->subject);		  
    			$smtp = Mail::factory('smtp',
    			array ( 'host' => $this->host,
        			   	'port' => $this->port,
        				'auth' => true,
        			'username' => $this->username,
        			'password' => $this->password));
    		$mail = $smtp->send($to, $headers, $this->body);
    		if(PEAR::isError($mail)){
      				//echo($mail->getMessage()); //For debugging purposes only
    			return false;
    			}else
      				return true;
    	}
    	function addAccount($name, $email, $username, $password, $protocol, $port, $server){
    		//nothing yet..
    	}
    }
    $db = new Database(DB_HOST, DB_USER, DB_PASS, DB_DB);
    $email = new Email($db);
    ?>

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.