Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #11 (permalink)  
Old November 18th, 2003, 09:04 AM
Authorized User
 
Join Date: Nov 2003
Location: Trowbridge, Wilts, United Kingdom.
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

rich, you are a shining light mate, thanks a million!!!!!! if you've got paypal just name your price ;)

jon
Reply With Quote
  #12 (permalink)  
Old November 18th, 2003, 09:11 AM
Authorized User
 
Join Date: Nov 2003
Location: Trowbridge, Wilts, United Kingdom.
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

if you're going to try out the source (you great person you!) then you'll need to setup a .htaccess file with an include_path to various things, an absracted version is below...

Code:
php_value include_path ".:/

path to php libs ie: /usr/lib/php/

webserver root + path to site dirs:

'_lib/_base'
'_lib/_classes'
'/site/'
'/core/'

path to PEAR libs, but I was under the impression that PEAR now comes as standard in php4.3 + but my package doesn't have the mime.php file so I had to make a folder in the root of the site (called pear!) with the mime.php file in it.

php_value register_globals "off"
again, thanks a million mate.

jon
Reply With Quote
  #13 (permalink)  
Old November 18th, 2003, 09:32 AM
Authorized User
 
Join Date: Nov 2003
Location: Trowbridge, Wilts, United Kingdom.
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ahh, getting somewhere now. I posted the code above to the peah mailing list, and was told that it should be:

if (PEAR::isError($this->_oMail)) { // this is line 58!

not

if (Mail::isError($this->_oMail)) { // this is line 58!

so a few things are working now, justy a little bit more debugging to do I think (yeah right, more like tons!!)

jon
Reply With Quote
  #14 (permalink)  
Old November 18th, 2003, 10:01 AM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Quote:
quote:
if (PEAR::isError($this->_oMail)) { // this is line 58!
Well that makes sense because that function doesn't appear in the PEAR mailer class.

This Error:
[Tue Nov 18 11:08:21 2003] [error] PHP Notice: Undefined index: admin_app_perm in /Library/WebServer/Documents/wrox_site/_lib/_classes/class.session.php on line 301

After looking at the source code for that file it appears that this table does not appear in the database. So that could be a huge problem!

This Error:
[Tue Nov 18 11:08:21 2003] [error] PHP Notice: Undefined variable: sReturn in /Library/WebServer/Documents/wrox_site/_lib/_base/elements.php on line 36

$sReturn is concatenated before it is defined.

This Error:
[Tue Nov 18 11:08:21 2003] [error] PHP Notice: A session had already been started - ignoring session_start() in /Library/WebServer/Documents/wrox_site/_lib/_classes/class.session.php on line 68

Something here is calling on that function '_setSession($aArgs)' more than once. session_start should only be called once... this seems to be merely a pourly thought out design.

And this one:
[Tue Nov 18 11:08:49 2003] [error] [client 127.0.0.1] File does not exist: /Library/WebServer/Documents/wrox_site/_img/banners/lg_blank.gif

Well the folder is empty! Is there supposed to be something in there?? What file is asking for these images?

These errors:
[Tue Nov 18 11:08:39 2003] [error] PHP Notice: Undefined index: op in /Library/WebServer/Documents/wrox_site/site/tpl_unsecure.php on line 9
[Tue Nov 18 11:08:39 2003] [error] PHP Notice: Undefined index: id in /Library/WebServer/Documents/wrox_site/site/tpl_unsecure.php on line 10

$_GET["op"] is not defined.

It would be better written:

if (isset($_GET["op"])) $op = $_GET["op"];
if (isset($_GET["id"])) $id = (int) $_GET["id"];

This one:
[Tue Nov 18 11:08:21 2003] [error] PHP Notice: Use of undefined constant version - assumed 'version' in /Library/WebServer/Documents/wrox_site/core/tpl_secure.php on line 40

I'm not sure, I don't see where version is defined. I'm looking at this file and it includes this line at the top:
require_once("elements.php");
require_once("class.session.php");

But neither of these appear in the same directory. Perhaps an absolute path would be better suited. $_SERVER["DOCUMENT_ROOT"] (base path up to www directory) include the remaining path after that.
PHP,however, should fail with a fatal error if it can't include those.

This code is certainly froggy and rather to continue to try and fix it I would suggest pointing out its flaws to the people at apress.

Good luck!
: )
Rich

:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::
Reply With Quote
  #15 (permalink)  
Old November 18th, 2003, 06:28 PM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Ok I need to correct something:

Quote:
quote:
[Tue Nov 18 11:08:21 2003] [error] PHP Notice: Undefined index: admin_app_perm in /Library/WebServer/Documents/wrox_site/_lib/_classes/class.session.php on line 301

After looking at the source code for that file it appears that this table does not appear in the database. So that could be a huge problem!
I meant to say the `field` not the table. The database wrapper function specifies returning an associative array. Maybe you have a typo in the database since it isn't finding that field in the results.

Quote:
quote:
I'm not sure, I don't see where version is defined. I'm looking at this file and it includes this line at the top:
require_once("elements.php");
require_once("class.session.php");

But neither of these appear in the same directory. Perhaps an absolute path would be better suited. $_SERVER["DOCUMENT_ROOT"] (base path up to www directory) include the remaining path after that.
PHP,however, should fail with a fatal error if it can't include those.
I think that your .htaccess file takes care of that and that would make sense since you didn't have any fatal errors from the including of the files failing. I still don't see where the constant 'version' is defined! It may very well be a typo. All of their other constants are in uppercase (as standards dictate) but that one is not. And also that code isn't really important it outputs the constant to HTML comments. You would be alright with commenting it out from the PHP side to get on with things.

The only error that baffles me are the 'file does not exist' errors. It doesn't say where its trying to access these files.

This error:
[Tue Nov 18 11:08:04 2003] [error] PHP Notice: Undefined variable: bg in /Library/WebServer/Documents/wrox_site/_lib/_base/elements.php on line 85

OK its comparing the variable $bg and based on whether the result of strcmp is true or false assigns a new value. Well the problem is it doesn't exist anywhere to be compared!

!strcmp("FFFFFF", $bg) ? $bg = "F6F6F6" : $bg = "FFFFFF";

Its saying in English, if the $bg variable does not look like ffffff true make it f6f6f6 false make it ffffff. Which I'm scratching my head here to see how this makes sense! First the background variable isn't defined. And second if it does look like ffffff make it ffffff? Maybe they are trying to make a table with rows of alternating colour. That would be better done:

if ($i&1) $bg = "ffffff"; # if the count is odd...
else $bg = "f6f6f6"; # if the count is even...

No undefined variables there!
And the while loop they are using would be better written a for loop.

Their HTML sucks too! Not standards compliant.

Are you getting an understanding of how to correct Notice errors? Its basically making things more logical and precise.

Have you posted your ills on the apress forums?

: )
Rich

:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::
Reply With Quote
  #16 (permalink)  
Old November 18th, 2003, 07:12 PM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Quote:
quote:
rich, you are a shining light mate, thanks a million!!!!!! if you've got paypal just name your price ;)
Oh no worries! I'm happy to help out. You certainly don't have to pay for my help! But if you want to express your generosity don't let me stop you! Its richy@smilingsouls.net

Quote:
quote:
if you're going to try out the source (you great person you!) then you'll need to setup a .htaccess file with an include_path to various things, an absracted version is below...
Well I don't really have any documention on this, so I have no idea what it does, and consequently I don't know what to expect of it... so I'm not trying to run it. I don't mind helping you make sense of the errors though. What book is this out of anyway?

: )
Rich

:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::
Reply With Quote
  #17 (permalink)  
Old November 18th, 2003, 10:39 PM
Friend of Wrox
Points: 2,570, Level: 21
Points: 2,570, Level: 21 Points: 2,570, Level: 21 Points: 2,570, Level: 21
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: San Diego, CA, USA
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Okay, clarifications coming: (First let me apologize that I don't have the time to read ALL the correspondance so far in this topic)

Take care,

Nik
http://www.bigaction.org/
Reply With Quote
  #18 (permalink)  
Old November 18th, 2003, 11:05 PM
Friend of Wrox
Points: 2,570, Level: 21
Points: 2,570, Level: 21 Points: 2,570, Level: 21 Points: 2,570, Level: 21
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: San Diego, CA, USA
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Oops. Prematurely sent. Sorry about that.

As Rich said, NOTICE level warnings are usually logged when you're accessing a variable or an array index that doesn't exist yet.


Quote:
quote:
 why do I get a parse error for this line ???

var $_oMail;
"var" is a keyword in PHP that declares member variables of a class, so it doesn't make sense to have "var $something" outside of a class definition.

If your declaration was actually INSIDE a class, for example:

class Foo
{
    var $_oMail;
}

then look ABOVE the variable declaration line for some sort of syntax error (e.g. missing semicolon), because the PHP parser will choke on the next line when it can't figure out what the heck "var" is doing as part of the previous statement.



Moving on....

Quote:
quote:
 and... why can't I find any documentation about this "=&" operator ???? what is it ?? what does it do ???
The =& operator has nothing to do with instantiating a class. It's actually TWO operators: = (assignment) and & (address of/reference).

So this line:
  $this->_oMail =& Mail::factory("mail");

Is setting the _oMail member function of the $this instance of a class to be a reference to the return value of the function Mail::factory().

If you're unclear about references, what they are and how they work, let me know.


Moving on:

Quote:
quote:
OK its comparing the variable $bg and based on whether the result of strcmp is true or false assigns a new value. Well the problem is it doesn't exist anywhere to be compared!

!strcmp("FFFFFF", $bg) ? $bg = "F6F6F6" : $bg = "FFFFFF";

Its saying in English, if the $bg variable does not look like ffffff true make it f6f6f6 false make it ffffff. Which I'm scratching my head here to see how this makes sense! First the background variable isn't defined. And second if it does look like ffffff make it ffffff? Maybe they are trying to make a table with rows of alternating colour. That would be better done:

if ($i&1) $bg = "ffffff"; # if the count is odd...
else $bg = "f6f6f6"; # if the count is even...
You're right about it alternating the rows. strcmp() returns a negative number if the first string is less than the second, zero if they're equal, and a positive number if the first string is greater than the second. These comparisons are made using case-sensitive character matching; that is, a < b but a > Z.

The ! in front of the call to strcmp inverts the return value -- it makes a FALSE value TRUE and a TRUE value FALSE. In the context of integers, it turns NONZERO values into ZERO, and ZERO values to some NONZERO number (typically 1).

So: The statement actually reads in English as:
  If $bg is "FFFFFF", set it to "F6F6F6", otherwise change it to "FFFFFF".

What's nice about the trinary operator (aka question-colon) is that you can express if-else expressions on a single line as a single statement. It's much cleaner, more concise, and readable (once you get the hang of it) than this:

if(!strcmp($bg, "FFFFFF"))
{
    $bg = "F6F6F6";
}
else
{
    $bg = "FFFFFF";
}

I do have a problem with the way the original statement was written. The whole point of using the trinary operator is to determine which value to assign to $bg. This should be rewritten as:

$bg = (!strcmp($bg, "FFFFFF"))? "F6F6F6" : "FFFFFF";

See how the assignment does NOT happen inside the case expressions? The case expressions are simply the resultant value of the trinary oprerator. There are no side effects (e.g. assignment) happening as the result the conditional expression. More plainly: The trinary operator should evaluate to a VALUE, just like the addition or subtraction operators.



Moving on.....

Quote:
quote:slightly edited for readability
I get this error:

Undefined variable: _oMail in /Library/WebServer/Documents/wrox_site/mail_test.php on line 10

with this script:

<?php

require_once("Mail.php");
require_once("DB.php");

function mailTest(){

    echo "mailTest() called!";

    $_oMail;

    snip snip snip
}

but I don't get any errors regarding a missing include file, is this a PEAR problem!!!!! (sorry to kee banging on about it) I only ask because isError() is a method of the PEAR class, so maybe I'm not including the main pear class, and if I was all this would be sorted!!!!!
Okay, you see that line where you have $_oMail just sitting by itself? That's a valid statement. You're not DOING anything -- no assignments, function calls, sending output, etc... -- the statement simply evaluates to the value of $_oMail. It's just as if you had this code:

Code:
<?php

42;

?>
But guess what? You don't have $_oMail initialized anywhere; it doesn't exist before that line... so what do you get? An uninitialized variable warning.



Hope this helps clear some things up.


Take care,

Nik
http://www.bigaction.org/
Reply With Quote
  #19 (permalink)  
Old November 18th, 2003, 11:12 PM
Friend of Wrox
Points: 2,570, Level: 21
Points: 2,570, Level: 21 Points: 2,570, Level: 21 Points: 2,570, Level: 21
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: San Diego, CA, USA
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'll post this link anyway:

  http://www.php.net/references


Take care,

Nik
http://www.bigaction.org/
Reply With Quote
  #20 (permalink)  
Old November 19th, 2003, 05:37 PM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Thanks for the clarifications Nik. I had searched and searched through the manual to find both the trinary operator and that bit on references. I did actually finally find the part on the trinay operator at some point yesterday. I thought that logic seemed kind of out there!

: )
Rich



:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows based Problem Design Solution Book ricpue BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 5 September 1st, 2006 07:47 AM
php-mysql website - problem design solution pannet1 Pro PHP 0 December 23rd, 2005 01:49 PM
php/mysql programming problem - design - solution jben.net Beginning PHP 8 November 14th, 2003 09:00 PM
PHP MySQL Website Programming P-D-S robmorrish All Other Wrox Books 1 August 5th, 2003 01:29 AM
Building a PHP Intranet Problem-Design-Solution kseba All Other Wrox Books 0 June 23rd, 2003 04:26 PM



All times are GMT -4. The time now is 09:26 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.