Hugo Brand 0 Newbie Poster

Hi everyone. Thanks for the posts. I couldn't solve the problem.

Yes. I totally agree with the fact that this in most programming languages refers to object oriented code, but it doesn't look as if the author intended to use object oriented code within his example. If so, then I'm totally confused, because none of his previous code samples, even those that followed, demonstrated any form of object-orientation programming inside of PHP.

Thanks again, maybe I'll figure it out someday.

Hugo Brand 0 Newbie Poster

Josh Connerty

This reply contains the original code in respect to the author who developed it, that I was studying.

<?
// define some constants
// message types
$type = array("text", "multipart", "message", "application", "audio",
"image", "video", "other");
// message encodings
$encoding = array("7bit", "8bit", "binary", "base64", "quoted-printable",
"other");

// parse message body
function parse($structure)
{
	global $type;
	global $encoding;

	// create an array to hold message sections
	$ret = array();

	// split structure into parts
	$parts = $structure->parts;

	for($x=0; $x<sizeof($parts); $x++)
	{
  $ret[$x]["pid"] = ($x+1);

  $this = $parts[$x];

  // default to text
  if ($this->type == "") { $this->type = 0; }
  $ret[$x]["type"] = $type[$this->type] . "/" . strtolower($this->subtype);

  // default to 7bit
  if ($this->encoding == "") { $this->encoding = 0; }
  $ret[$x]["encoding"] = $encoding[$this->encoding];

  $ret[$x]["size"] = strtolower($this->bytes);

  $ret[$x]["disposition"] = strtolower($this->disposition);

  if (strtolower($this->disposition) == "attachment")
  {
  	$params = $this->dparameters;
  	foreach ($params as $p)
  	{
    if($p->attribute == "FILENAME")
    {
    $ret[$x]["name"] = $p->value;
    break;
    }
  	}
  }
}

return $ret;

}
?>

Changing all $this to $result, made the application work, but with unexpected results. I have debugged most of the conditional statements above and my major problem lied with this if statement:

if (strtolower($this->disposition) == "attachment")

It was suppose to read the conditional statement, but instead it doesn't find any value inside of the $this->disposition containing an "attachment" string value.

Any comments would still be appreciated.
Thanks

Hugo Brand 0 Newbie Poster

To clarify, does the line

$this = $parts[$x];

appear within something like the following

class NameOfTheObject
{
}

SimonMayer

No, from reading the line code it looks as if it appeared only in a function, not a class.

Thank you for providing a link, I will look at it when I have some time available.

Hugo Brand 0 Newbie Poster

Thanks

Hugo Brand 0 Newbie Poster

How can I remove my account at DaniWeb?

Hugo Brand 0 Newbie Poster

Hi

I've been doing a study of some PHP code developed by another author in 2002.

The article could be found at:
http://www.devshed.com/c/a/PHP/Building-A-PHPBased-Mail-Client-part-2/3/

The functions I need help with in understanding are:
function parse($structure) //custom function developed by author
function get_attachments($arr) //custom function developed by author

The following line gave me difficulties:

$this = $parts[$x];

I have studied this line of code and would like to know if $this has some sort of special meaning in PHP?

I tried to change $this to $result and the application seemed to be working, but not giving the correct result.

Any help would be appreciated.

Hugo Brand 0 Newbie Poster

Ok. Very strange error message.

I waited a while and tried to connect using telnet localhost 110 again and for some reason it connected.

Not sure why this happened, maybe the server was busy with the port while I was trying to connect to the port.

... :?:

Hugo Brand 0 Newbie Poster

Hi

I need some help with the following problem:

This is the source code:

<html>
<body>

<?php

//Retreiving mail messages from mail server
$server = 'localhost';
$port = 110;
$mail = imap_open("\{$server:$port/pop3}INBOX", 'admin', 'password');

?>
</body>
</html>

This is the error message (exception):
Warning: imap_open() [function.imap-open]: Couldn't open stream \{localhost:110/pop3}INBOX in C:\Program Files\xampp\htdocs\MailWebApp\index.php on line 34

What I do know:

  1. PHP is working
  2. Port 25 is working (tested it with telnet localhost 25)
  3. Port 110 is not working. It was tested with telnet localhost 110 in the Command Prompt and the following error message was reported:

-ERR Your connection is temporarily blacklisted - try again later
Connection to host lost.

Anyone knows what this error message means?

Thanks

Hugo Brand 0 Newbie Poster

Hi everyone.

Thank you very much for everyone's feedback. I managed to get it to work by carefully looking at the code again and the way it was managed.

Hugo Brand 0 Newbie Poster

Is there a way that I can edit some of my posts on this forum?

Hugo Brand 0 Newbie Poster

Thanks for pointing out that semi-colon. That didn't solve my problem.

I use Netbeans on a regular basis, but struggle to get it to work with the web server, and therefore it was decided to use a text editor instead. I know this is not the best way to go, but it is good for now.

Hugo Brand 0 Newbie Poster

Thanks for the suggestion, but I got the following error message:
Parse error: parse error in C:\Program Files\xampp\webdav\content.inc on line 18

Hugo Brand 0 Newbie Poster

I need someone to help me with the following problem please:

First of all I have 3 (there are more, but only these 3 files are needed) files:
index.php (this file is composed of several other files with a .inc extension)
cfg_db_connect.php (contains the code to connect to a database. It does work it has been tested)
content.inc (this file is called from the index.php file and displays the content of a page in the web browser)

Here is the code for the file index.php:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<script type="text/javascript" src="dropdown.js"></script>
<link href="style.css" type="text/css" rel="stylesheet">
<link href="headerstyle.css" type="text/css" rel="stylesheet">
<title>DemoTech Home Page</title>
</head>
<body>

<?php readfile("header.inc");?>
[B]<?php readfile("content.inc");?>[/B]
<?php readfile("sidebar.inc");?>
</div>
<?php readfile("footer.inc");?>
</body>
</html>

Here is the code for the file cfg_db_connect.php:

<?php

function dbopen($hostname, $username, $password )
{
	$dbh = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL");
	print "Connected to MySQL<br>";
	return $dbh;
}

function queryInfo()
{
	$result = mysql_query("SELECT nws_id, nws_title, nws_posted FROM news");
	while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
	print "ID:".$row{'nws_id'}." Title:".$row{'nws_title'}." Posted:".$row{'nws_posted'}."<br>";
	}

	return $result;
}

function queryInfo2()
{
	$result = mysql_query("SELECT nws_title, nws_content, nws_posted FROM news");
	while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
	print "<div class=\"post\">
			<h2 class=\"title\">
				Title:".$row{'nws_title'}."
			</h2>
	       <div class=\"entry\">
			".$row{'nws_content'}."
	       </div>
	       <p class=\"meta\"><span class=\"byline\">Posted by ".$row{'nws_posted'}." on December 22, 2007</span><a href=\"#\" class=\"comments\">18 comments</a></p>
	       
	       </div><br>";
	}

	return $result;
}

function dbclose($dbh)
{
	mysql_close($dbh);	
}
?>

Here is the code for the file content.inc:

<HEAD>
<link href="style.css" type="text/css" rel="stylesheet">
</HEAD> …