Re: [PHP] Help on objects [with reply]

2006-10-05 Thread benifactor
yea, thanks for the input... but do you think my solution would be better
for original poster?
- Original Message - 
From: Dave Goodchild [EMAIL PROTECTED]
To: benifactor [EMAIL PROTECTED]
Cc: Robert Cummings [EMAIL PROTECTED]; Satyam
[EMAIL PROTECTED]; Deckard [EMAIL PROTECTED];
php-general@lists.php.net
Sent: Thursday, October 05, 2006 4:55 AM
Subject: Re: [PHP] Help on objects [with reply]


 Re the last suggestion, ensure you keep those database details outside the
 web root (ie in a file called connect.inc for example) or if have to keep
it
 there add a .htaccess file that prevents download of *.inc files.

 Also, avoid use of the error suppression operator (@). You need to see
your
 errors.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help on objects [with reply]

2006-10-05 Thread Dave Goodchild

Undoubtedly. He could also use the PEAR DB abstraction layer.


Re: [PHP] Help on objects

2006-10-05 Thread Martin Alterisio

2006/10/4, Deckard [EMAIL PROTECTED]:


Hi,

I'm trying to lay my hands on PHP OOP, but it's not easy :(
I've read several examples in the web, but cannot transpose to may case.

I'm trying to set a class to make SQL inserts in mysql.

I have the class:
-
?php

  class dBInsert
{
  // global variables
  var $first;

// constructor
function dBInsert($table, $sql)
{
  $this-table = $table;
  $this-sql   = $sql;

  return(TRUE);
}


  // function that constructs the sql and inserts it into the database
  function InsertDB($sql)
   {

print($sql);
// connect to MySQL
$conn-debug=1;
$conn = ADONewConnection('mysql');
$conn-PConnect('localhost', 'deckard', 'ble', 'wordlife');

if ($conn-Execute($sql) === false)
print 'error inserting: '.$conn-ErrorMsg().'BR';

return (TRUE);
   }
}


and the code that calls it:

?php

include_once(classes/dBInsert.php);
$sql = INSERT INTO wl_admins VALUES ('',2);
$dBInsert = new dBInsert('wl_admins', '$sql');
$dBInsert-InsertDB('$sql');

?


but it's not working ?

Can anyone give me a hand here ?

I've read the manuals, examples, etc.

Any help would be appreciated.

Best Regards,
Deckard

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



For database interaction, give PDO a chance: http://php.net/pdo
IMO it's cleaner and more efficient than adodb.

Then, I believe what you're trying to make is a query builder. I would break
down the differente parts of an sql query and create abstractions for each
part (some can be reused on different types of queries), then have builder
create the queries abstractions from the different parts.


Re: [PHP] Help on objects

2006-10-05 Thread Martin Alterisio

2006/10/5, Satyam [EMAIL PROTECTED]:


I've seen you already had a good answer on the errors in the code so I
won't
go on that.  As for OOP, the one design error you have is that you are
asking for an action, not an object.   You want to make SQL inserts, that
is
your purpose, and that is an action, which is solved by a statement, not
by
an object.   There is no doer.  Objects are what even your English teacher
would call objects while describing a sentence.  You are asking for a
verb,
you don't have a subject, you don't have an object.   Of course you can
wrap
an action in a class, but that is bad design.  Classes will usually have
names representing nouns, methods will be verbs, properties adjectives,
more
or less, that's OOP for English teachers.

Satyam



You're wrong, partially: an action can be an object and it's not necessarily
a bad design, take for example function objects or the program and
statements as objects in lisp-like languages. It's acceptable to make a
class that works as an abstract representation of an sql query. This kind of
classes are used very efficiently in object persistence libraries. What I
agree with you is that it's not right that this class works as the insert
action and not as a representation of the insert operation.


Re: [PHP] Help on objects

2006-10-05 Thread Satyam


- Original Message - 
From: Robert Cummings [EMAIL PROTECTED]

To: Satyam [EMAIL PROTECTED]
Cc: Deckard [EMAIL PROTECTED]; php-general@lists.php.net
Sent: Thursday, October 05, 2006 11:16 AM
Subject: Re: [PHP] Help on objects



On Thu, 2006-10-05 at 07:04 +0200, Satyam wrote:
I've seen you already had a good answer on the errors in the code so I 
won't

go on that.  As for OOP, the one design error you have is that you are
asking for an action, not an object.   You want to make SQL inserts, that 
is
your purpose, and that is an action, which is solved by a statement, not 
by
an object.   There is no doer.  Objects are what even your English 
teacher
would call objects while describing a sentence.  You are asking for a 
verb,
you don't have a subject, you don't have an object.   Of course you can 
wrap

an action in a class, but that is bad design.  Classes will usually have
names representing nouns, methods will be verbs, properties adjectives, 
more

or less, that's OOP for English teachers.


Properties are very often nouns in addition to adjectives. For instance
a linked list class will undoubtedly have noun objects referring to the
current link, the next link, etc.

Cheers,
Rob.
--


Indeed, they often are:  you as an object are defined by properties such as 
height, color of your hair and many other adjectives and you have many other 
objects which define you, fingers, legs, etc, which are also properties. 
Being more detailed, instead of the color of your hair being a property of 
you as a whole, you might have a property pointing to a hair object (a noun) 
which has a color property.


Other noun properties might not be so helpful in defining you, your friends 
might give a hint of who you are, your clients do not.  But, after all, 
neither does your hair, mine is deserting me and I'm still myself.  So, I 
would say that while adjectives define an object, nouns are relations in 
between objects and might not define neither.


Anyway, I didn't mean this analogy to be complete, nor I mean to teach OOP 
to English teachers, and though it can be talked much about, stretching it 
too far would certainly break it.  I don't mean to defend it very strongly.


Cheers

Satyam

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help on objects

2006-10-05 Thread Satyam

  - Original Message - 
  From: Martin Alterisio 
  To: Satyam 
  Cc: Deckard ; php-general@lists.php.net 
  Sent: Thursday, October 05, 2006 3:50 PM
  Subject: Re: [PHP] Help on objects


  2006/10/5, Satyam [EMAIL PROTECTED]:
I've seen you already had a good answer on the errors in the code so I won't
go on that.  As for OOP, the one design error you have is that you are
asking for an action, not an object.   You want to make SQL inserts, that 
is 
your purpose, and that is an action, which is solved by a statement, not by
an object.   There is no doer.  Objects are what even your English teacher
would call objects while describing a sentence.  You are asking for a verb, 
you don't have a subject, you don't have an object.   Of course you can wrap
an action in a class, but that is bad design.  Classes will usually have
names representing nouns, methods will be verbs, properties adjectives, 
more 
or less, that's OOP for English teachers.

Satyam


  You're wrong, partially: 

I am sure you could have stated that in a more courteous way.

Re: [PHP] Help on objects

2006-10-05 Thread Martin Alterisio

2006/10/5, Satyam [EMAIL PROTECTED]:




- Original Message -
*From:* Martin Alterisio [EMAIL PROTECTED]
*To:* Satyam [EMAIL PROTECTED]
*Cc:* Deckard [EMAIL PROTECTED] ; php-general@lists.php.net
*Sent:* Thursday, October 05, 2006 3:50 PM
*Subject:* Re: [PHP] Help on objects

2006/10/5, Satyam [EMAIL PROTECTED]:

 I've seen you already had a good answer on the errors in the code so I
 won't
 go on that.  As for OOP, the one design error you have is that you are
 asking for an action, not an object.   You want to make SQL inserts,
 that is
 your purpose, and that is an action, which is solved by a statement, not
 by
 an object.   There is no doer.  Objects are what even your English
 teacher
 would call objects while describing a sentence.  You are asking for a
 verb,
 you don't have a subject, you don't have an object.   Of course you can
 wrap
 an action in a class, but that is bad design.  Classes will usually have
 names representing nouns, methods will be verbs, properties adjectives,
 more
 or less, that's OOP for English teachers.

 Satyam


You're wrong, partially:


I am sure you could have stated that in a more courteous way.



I apologize, english is not my first language and I usually can't express
myself correctly. As a fellow compatriot I hope you'll understand there
weren't ill intentions on what I said.


Re: [PHP] Help on objects

2006-10-04 Thread Penthexquadium
On Thu, 05 Oct 2006 02:47:59 +0100, Deckard [EMAIL PROTECTED] wrote:

 Hi,
 
 I'm trying to lay my hands on PHP OOP, but it's not easy :(
 I've read several examples in the web, but cannot transpose to may case.
 
 I'm trying to set a class to make SQL inserts in mysql.
 
 I have the class:
 -
 ?php
 
   class dBInsert
  {
   // global variables
   var $first;
   
  // constructor
  function dBInsert($table, $sql)
  {
   $this-table = $table;
   $this-sql   = $sql;
   
   return(TRUE);   
  }
 
 
   // function that constructs the sql and inserts it into the database
   function InsertDB($sql)
{
 
 print($sql);
 // connect to MySQL
 $conn-debug=1;
 $conn = ADONewConnection('mysql');
 $conn-PConnect('localhost', 'deckard', 'ble', 'wordlife');
   
   if ($conn-Execute($sql) === false)
   print 'error inserting: '.$conn-ErrorMsg().'BR';
   
   return (TRUE);
}
 }
 
 
 and the code that calls it:
 
 ?php
 
  include_once(classes/dBInsert.php);
  $sql = INSERT INTO wl_admins VALUES ('',2);
  $dBInsert = new dBInsert('wl_admins', '$sql');
  $dBInsert-InsertDB('$sql');
 
 ?
 
 
 but it's not working ?
 
 Can anyone give me a hand here ?
 
 I've read the manuals, examples, etc.
 
 Any help would be appreciated.
 
 Best Regards,
 Deckard
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

You'd better learn the basic knowledge of PHP. There are several obvious
mistakes in your code.

 $dBInsert = new dBInsert('wl_admins', '$sql');
 $dBInsert-InsertDB('$sql');
Note that variables will *not* be expanded when they occur in single
quoted strings.

 $this-table = $table;
 $this-sql   = $sql;
The two variables seemed useless.

 $conn-debug=1;
 $conn = ADONewConnection('mysql');
Called $conn before creating it.

And, I could not to know what is the purpose of this class.

PS, a description such as it's not working is useless for solving the
problem.

-- 
Sorry for my poor English.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help on objects

2006-10-04 Thread Satyam
I've seen you already had a good answer on the errors in the code so I won't 
go on that.  As for OOP, the one design error you have is that you are 
asking for an action, not an object.   You want to make SQL inserts, that is 
your purpose, and that is an action, which is solved by a statement, not by 
an object.   There is no doer.  Objects are what even your English teacher 
would call objects while describing a sentence.  You are asking for a verb, 
you don't have a subject, you don't have an object.   Of course you can wrap 
an action in a class, but that is bad design.  Classes will usually have 
names representing nouns, methods will be verbs, properties adjectives, more 
or less, that's OOP for English teachers.


Satyam

- Original Message - 
From: Deckard [EMAIL PROTECTED]

To: php-general@lists.php.net
Sent: Thursday, October 05, 2006 3:47 AM
Subject: [PHP] Help on objects



Hi,

I'm trying to lay my hands on PHP OOP, but it's not easy :(
I've read several examples in the web, but cannot transpose to may case.

I'm trying to set a class to make SQL inserts in mysql.

I have the class:
-
?php

 class dBInsert
{
 // global variables
 var $first;

// constructor
function dBInsert($table, $sql)
{
 $this-table = $table;
 $this-sql   = $sql;

 return(TRUE);
}


 // function that constructs the sql and inserts it into the database
 function InsertDB($sql)
  {

   print($sql);
   // connect to MySQL
   $conn-debug=1;
   $conn = ADONewConnection('mysql');
   $conn-PConnect('localhost', 'deckard', 'ble', 'wordlife');

if ($conn-Execute($sql) === false)
print 'error inserting: '.$conn-ErrorMsg().'BR';

return (TRUE);
  }
}


and the code that calls it:

?php

include_once(classes/dBInsert.php);
$sql = INSERT INTO wl_admins VALUES ('',2);
$dBInsert = new dBInsert('wl_admins', '$sql');
$dBInsert-InsertDB('$sql');

?


but it's not working ?

Can anyone give me a hand here ?

I've read the manuals, examples, etc.

Any help would be appreciated.

Best Regards,
Deckard

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help converting C to PHP

2006-09-23 Thread Richard Lynch
On Fri, September 22, 2006 7:40 pm, Rory Browne wrote:
 Fair enough.
 Prime Number Script Competition ( for Bragging Rights ).

 I challenge the readers of this list to produce the necessary code to
 find
 the lowest prime number higher than a certain inputted number.

 The script must be web based, and ask the user to enter a number. The
 script
 must then calculate the lowest Prime Number above that number.

 Scripts will be rated on Functional Accuracy ( the program must
 correctly
 perform its required function ), Code Maintainability(eg Presence of
 Comments, etc ), Ease of Use, and Code Efficiency, in that order.
 Brownie
 points may be earned through use interesting or original ideas or
 methodologies, provided they do not compromise the previous four
 criteria.

 The submitted script will be rated by volunteers from this list.
 Submitting
 an entry disqualifys you as a volunteer judge, whilst judging someone
 elses
 code disqualifys you as a candidate. Deadline for submissions is 12:00
 (Noon) (CEST UTC + 2 Hours) on Friday 29 September.

 Interesting to see (a) if anyone enters, and (b) what the code will be
 like.

 I think it would be a lot of fun if well executed.

I'm in.

What's the submission process?

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help converting C to PHP

2006-09-23 Thread Rory Browne

Whoops - sorry replied directly to Richard instead of to the list.

Submission process is simply to post to the list. It's probably a good idea
( and acceptable ) to just post an SHA1(MD5 for this purpose is compromised)
hash of your code before the deadline, and submit your actual code shortly
after the deadline.

The result must be greater than the input. For 2 as an input, I'd expect 3
as output.

Rory


RE: [PHP] Help converting C to PHP

2006-09-22 Thread Jay Blanchard
[snip]
Codegolf...

heh.. nice little twist.
[/snip]

At least we weren't asked to help someone write his homework. 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help converting C to PHP

2006-09-22 Thread Rory Browne

On 9/22/06, Kevin Waterson [EMAIL PROTECTED] wrote:


This one time, at band camp, Curt Zirzow [EMAIL PROTECTED] wrote:

 what about using:
   php.net/pi

 note the precision description.

 or are we talking about a different pi.

The goal of the codegolf.com challenge is to print pi to 1000 places.
The programmer to do it in the least keystrokes is the winner.



I personally don't think this is a very healthy contest. It discourages
comments, and use of whitespace to make code readable.

I'd perfer a contest that rewarded code readability, and maintainability as
well as minimal keystrokes. After all you only enter the aforementioned
keystrokes once. Perhaps one like codegolf, with an enforced coding style (
eg KR Style, or GNU Style)


Re: [PHP] Help converting C to PHP

2006-09-22 Thread tedd

At 2:38 PM +0200 9/22/06, Rory Browne wrote:

On 9/22/06, Kevin Waterson [EMAIL PROTECTED] wrote:

The goal of the codegolf.com challenge is to print pi to 1000 places.
The programmer to do it in the least keystrokes is the winner.


I personally don't think this is a very healthy contest. It discourages
comments, and use of whitespace to make code readable.

I'd perfer a contest that rewarded code readability, and maintainability as
well as minimal keystrokes. After all you only enter the aforementioned
keystrokes once. Perhaps one like codegolf, with an enforced coding style (
eg KR Style, or GNU Style)


Agreed, but our old ways remain to haunt us.

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help converting C to PHP

2006-09-22 Thread Martin Alterisio

2006/9/22, Rory Browne [EMAIL PROTECTED]:


On 9/22/06, Kevin Waterson [EMAIL PROTECTED] wrote:

 This one time, at band camp, Curt Zirzow [EMAIL PROTECTED] wrote:

  what about using:
php.net/pi
 
  note the precision description.
 
  or are we talking about a different pi.

 The goal of the codegolf.com challenge is to print pi to 1000 places.
 The programmer to do it in the least keystrokes is the winner.


I personally don't think this is a very healthy contest. It discourages
comments, and use of whitespace to make code readable.

I'd perfer a contest that rewarded code readability, and maintainability
as
well as minimal keystrokes. After all you only enter the aforementioned
keystrokes once. Perhaps one like codegolf, with an enforced coding style
(
eg KR Style, or GNU Style)



I completely agree. This kind of contests do not provide any measure of the
good qualities of a programmer working as part of a team. The objectives
ussualy end up being something of the sort: let's see who can fit the most
in a for declaration.

Anyway... as you say, it would be nice to have a contest that rewards
readability and maintainability... but, how can we messure that qualities in
this type of games? Should your code be praised by others and voted on? Is
that reliable? I think enforcing a coding style is too restrictive... Also,
how do we measure the declarativity of var and function names?


Re: [PHP] Help converting C to PHP

2006-09-22 Thread Tom Atkinson

Martin Alterisio wrote:

2006/9/22, Rory Browne [EMAIL PROTECTED]:


On 9/22/06, Kevin Waterson [EMAIL PROTECTED] wrote:

 This one time, at band camp, Curt Zirzow [EMAIL PROTECTED] wrote:

  what about using:
php.net/pi
 
  note the precision description.
 
  or are we talking about a different pi.

 The goal of the codegolf.com challenge is to print pi to 1000 places.
 The programmer to do it in the least keystrokes is the winner.


I personally don't think this is a very healthy contest. It discourages
comments, and use of whitespace to make code readable.

I'd perfer a contest that rewarded code readability, and maintainability
as
well as minimal keystrokes. After all you only enter the aforementioned
keystrokes once. Perhaps one like codegolf, with an enforced coding style
(
eg KR Style, or GNU Style)



I completely agree. This kind of contests do not provide any measure of the
good qualities of a programmer working as part of a team. The objectives
ussualy end up being something of the sort: let's see who can fit the most
in a for declaration.

Anyway... as you say, it would be nice to have a contest that rewards
readability and maintainability... but, how can we messure that 
qualities in

this type of games? Should your code be praised by others and voted on? Is
that reliable? I think enforcing a coding style is too restrictive... Also,
how do we measure the declarativity of var and function names?



The value of these games is that they give you interesting problems to 
solve without forcing you to maintain the code. That's the entire point. 
It's exactly the sort of thing that's fun to write when you have to make 
a living from your code the rest of the time. If you want to write 
quality software in your free time then you start/join an FOSS project 
and put the code to good use.


Nobody is claiming that this is a good way to write code or a good way 
to learn PHP, it's just for fun.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help converting C to PHP

2006-09-22 Thread php
Hello all,

  I personally don't think this is a very healthy contest. It
  discourages comments, and use of whitespace to make code readable.

 Anyway... as you say, it would be nice to have a contest that rewards
 readability and maintainability... but, how can we messure that
 qualities in this type of games? Should your code be praised by others
 and voted on? Is that reliable? I think enforcing a coding style is
 too restrictive... Also, how do we measure the declarativity of var
 and function names?

For some real trouble, try the International Obsfucated C Code Contest:
http://www.ioccc.org/

These contests like Code Golf are just for fun, I can't say that they
encourage bad practice as long as you understand what the contest is
about.

That aside, I think that it would be very beneficial to the community as a
whole if a contest was started that encouraged readability and good
practices.

The scoring and judging could be done by a panel, but I think that it
would be more fun if the community itself was able to vote on various
attributes; readability, efficiency, general approach, originality, etc.
Allow people to comment on each entry. I don't know about the winner
getting anything besides bragging rights, but it if gets large enough
maybe there can be a few corporate sponsors giving away licenses or
something. Who knows?

I think it would be a lot of fun if well executed.

-K.Bear

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help converting C to PHP

2006-09-22 Thread Martin Alterisio

2006/9/22, Tom Atkinson [EMAIL PROTECTED]:


Martin Alterisio wrote:
 2006/9/22, Rory Browne [EMAIL PROTECTED]:

 On 9/22/06, Kevin Waterson [EMAIL PROTECTED] wrote:
 
  This one time, at band camp, Curt Zirzow [EMAIL PROTECTED] wrote:
 
   what about using:
 php.net/pi
  
   note the precision description.
  
   or are we talking about a different pi.
 
  The goal of the codegolf.com challenge is to print pi to 1000 places.
  The programmer to do it in the least keystrokes is the winner.


 I personally don't think this is a very healthy contest. It discourages
 comments, and use of whitespace to make code readable.

 I'd perfer a contest that rewarded code readability, and
maintainability
 as
 well as minimal keystrokes. After all you only enter the aforementioned
 keystrokes once. Perhaps one like codegolf, with an enforced coding
style
 (
 eg KR Style, or GNU Style)


 I completely agree. This kind of contests do not provide any measure of
the
 good qualities of a programmer working as part of a team. The objectives
 ussualy end up being something of the sort: let's see who can fit the
most
 in a for declaration.

 Anyway... as you say, it would be nice to have a contest that rewards
 readability and maintainability... but, how can we messure that
 qualities in
 this type of games? Should your code be praised by others and voted on?
Is
 that reliable? I think enforcing a coding style is too restrictive...
Also,
 how do we measure the declarativity of var and function names?


The value of these games is that they give you interesting problems to
solve without forcing you to maintain the code. That's the entire point.
It's exactly the sort of thing that's fun to write when you have to make
a living from your code the rest of the time. If you want to write
quality software in your free time then you start/join an FOSS project
and put the code to good use.

Nobody is claiming that this is a good way to write code or a good way
to learn PHP, it's just for fun.



You're right, it's just for fun but... they could still be fun and be
useful. These kind of games could easily be used for education and training.
We all know that the quest/mob grinding factor can be very addictive, why
don't use all that energy for the good? You could still learn how to do a
good job while having fun...


Re: [PHP] Help converting C to PHP

2006-09-22 Thread Richard Lynch
On Thu, September 21, 2006 9:32 pm, Curt Zirzow wrote:
 On 9/21/06, Tom Atkinson [EMAIL PROTECTED] wrote:
 Hello,

 I am attempting to convert this code for generating the digits of pi
 from the original C (below) to PHP.

   long k=4e3,p,a[337],q,t=1e3;
main(j){for(;a[j=q=0]+=2,--k;)
for(p=1+2*k;j337;q=a[j]*k+q%p*t,a[j++]=q/p)
k!=j2?:printf(%.3d,a[j-2]%t+q/p/t);}


 wow this is rather bad. it would probably be better to write this in
 asm, it would be easier to read than the way it is in C.


 I converted this to a more readable form:

 what about using:
   php.net/pi

 note the precision description.

 or are we talking about a different pi.

We're probably talking about that silly contest started the other day
to calculate pi to 1000 digits...

:-)

My best guess is that the C code is relying on type-casting to hack
something somewhere.

-- 
Like Music?
http://l-i-e.com/artists.htm



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help converting C to PHP

2006-09-22 Thread Richard Lynch
On Fri, September 22, 2006 11:59 am, Martin Alterisio wrote:
 Anyway... as you say, it would be nice to have a contest that rewards
 readability and maintainability... but, how can we messure that
 qualities in
 this type of games?

If you think of the Open Market of software out there as the game
and people's decisions to use or not use it, then you've got a pretty
good contest.

And PHP is winning. :-)

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help converting C to PHP

2006-09-22 Thread Rory Browne

That aside, I think that it would be very beneficial to the community as a
whole if a contest was started that encouraged readability and good
practices.

The scoring and judging could be done by a panel, but I think that it
would be more fun if the community itself was able to vote on various
attributes; readability, efficiency, general approach, originality, etc.
Allow people to comment on each entry. I don't know about the winner
getting anything besides bragging rights, but it if gets large enough
maybe there can be a few corporate sponsors giving away licenses or
something. Who knows?



Fair enough.
Prime Number Script Competition ( for Bragging Rights ).

I challenge the readers of this list to produce the necessary code to find
the lowest prime number higher than a certain inputted number.

The script must be web based, and ask the user to enter a number. The script
must then calculate the lowest Prime Number above that number.

Scripts will be rated on Functional Accuracy ( the program must correctly
perform its required function ), Code Maintainability(eg Presence of
Comments, etc ), Ease of Use, and Code Efficiency, in that order. Brownie
points may be earned through use interesting or original ideas or
methodologies, provided they do not compromise the previous four criteria.

The submitted script will be rated by volunteers from this list. Submitting
an entry disqualifys you as a volunteer judge, whilst judging someone elses
code disqualifys you as a candidate. Deadline for submissions is 12:00
(Noon) (CEST UTC + 2 Hours) on Friday 29 September.

Interesting to see (a) if anyone enters, and (b) what the code will be like.




I think it would be a lot of fun if well executed.





Re: [PHP] Help converting C to PHP

2006-09-22 Thread Richard Lynch
On Fri, September 22, 2006 7:40 pm, Rory Browne wrote:
 The script must be web based, and ask the user to enter a number. The
 script
 must then calculate the lowest Prime Number above that number.

I would like to have one point clarified:

By above that number do you literally mean  or would = be deemed
the correct interpretation?

E.g. for an input of '2' do you expect '2' or '3' as the answer?

Or is our ability to correctly interpret this as  part of the
exercise?...

Ooops.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help understanding/debugging the following script:

2006-09-21 Thread Robert Cummings
On Thu, 2006-09-21 at 19:26 +0200, Martin Bach Nielsen wrote:
 Hi all.
 
 If you look at the code below, the return() does not produce any output.
 No errors were displayed on screen before I added 'error_reporting(E_ALL);'.
 (Error message: Notice: Undefined variable: this in /oop/test1/index.php on
 line 35, commented on below)
 Trying to echo/print ordinary text or variables works fine.
 
 I have some experience coding PHP scripts, but are new on how-to use/write
 OOP scripts. (Sample found at: http://www.purephotoshop.com/view.php?id=71)
 
 Here's the Code:
 ?php
 error_reporting(E_ALL);
 class Bike
 {
 var $num_speeds, $speed;
 var $rotation;
 var $running = FALSE; // You can set default values for properties,
 these values must be constant
 // Change speed method
 function change_speed( $increment = TRUE )
 {
 // ...
 }
 // Pedal and brake methods
 function pedal()
 {
  // ...
 }
 function brake()
 {
  // ...
 }
 // Turn method
 function turn( $angle )
 {
 // ...
 }
 }
 // Inside the change_speed() method
 if( !$this-running ) // This is line 35

You're not within a class method.

Cheers,
Rob.


 {
  return;
 }
 
 if( $increment  $this-speed != $this-num_speeds )
 {
 $this-speed++;
 return;
 }
 
 if( $this-speed != 1 )
 {
 $this-speed--;
 }
 ?
 
 I will be thankful for any help/hints that leads to a solution. If anymore
 info are needed, please let me know.
 
 
 Regards,
 Martin
 
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help converting C to PHP

2006-09-21 Thread Kevin Waterson
This one time, at band camp, Tom Atkinson [EMAIL PROTECTED] wrote:

 Hello,
 
 I am attempting to convert this code for generating the digits of pi 
 from the original C (below) to PHP.

is this for codegolf?

Kevin

-- 
Democracy is two wolves and a lamb voting on what to have for lunch. 
Liberty is a well-armed lamb contesting the vote.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help converting C to PHP

2006-09-21 Thread Tom Atkinson

Yes, it is.

Kevin Waterson wrote:

This one time, at band camp, Tom Atkinson [EMAIL PROTECTED] wrote:


Hello,

I am attempting to convert this code for generating the digits of pi 
from the original C (below) to PHP.


is this for codegolf?

Kevin



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help converting C to PHP

2006-09-21 Thread Curt Zirzow

On 9/21/06, Kevin Waterson [EMAIL PROTECTED] wrote:

This one time, at band camp, Tom Atkinson [EMAIL PROTECTED] wrote:


heh.. nice little twist.

Curt.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help converting C to PHP

2006-09-21 Thread Curt Zirzow

On 9/21/06, Tom Atkinson [EMAIL PROTECTED] wrote:

Hello,

I am attempting to convert this code for generating the digits of pi
from the original C (below) to PHP.

  long k=4e3,p,a[337],q,t=1e3;
   main(j){for(;a[j=q=0]+=2,--k;)
   for(p=1+2*k;j337;q=a[j]*k+q%p*t,a[j++]=q/p)
   k!=j2?:printf(%.3d,a[j-2]%t+q/p/t);}



wow this is rather bad. it would probably be better to write this in
asm, it would be easier to read than the way it is in C.



I converted this to a more readable form:


what about using:
 php.net/pi

note the precision description.

or are we talking about a different pi.


Curt.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help converting C to PHP

2006-09-21 Thread Kevin Waterson
This one time, at band camp, Curt Zirzow [EMAIL PROTECTED] wrote:

 what about using:
   php.net/pi
 
 note the precision description.
 
 or are we talking about a different pi.

The goal of the codegolf.com challenge is to print pi to 1000 places.
The programmer to do it in the least keystrokes is the winner.

Kevin

-- 
Democracy is two wolves and a lamb voting on what to have for lunch. 
Liberty is a well-armed lamb contesting the vote.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help converting C to PHP

2006-09-21 Thread Tom Atkinson

pi() does not give me enough decimal places, I need the first 1000.

Curt Zirzow wrote:

On 9/21/06, Tom Atkinson [EMAIL PROTECTED] wrote:

Hello,

I am attempting to convert this code for generating the digits of pi
from the original C (below) to PHP.

  long k=4e3,p,a[337],q,t=1e3;
   main(j){for(;a[j=q=0]+=2,--k;)
   for(p=1+2*k;j337;q=a[j]*k+q%p*t,a[j++]=q/p)
   k!=j2?:printf(%.3d,a[j-2]%t+q/p/t);}



wow this is rather bad. it would probably be better to write this in
asm, it would be easier to read than the way it is in C.



I converted this to a more readable form:


what about using:
 php.net/pi

note the precision description.

or are we talking about a different pi.


Curt.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help converting C to PHP

2006-09-21 Thread Christopher Watson

Definitely looks like a grouping and/or precedence problem.  Wish I
had more time to examine it.  Fine-tooth those parens again.

-Christopher

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] help - outputting a jpeg

2006-08-31 Thread Curt Zirzow

On 8/29/06, Ross [EMAIL PROTECTED] wrote:

I just get all the binary data output

?
include(includes/config.php);
$link = mysql_connect($host, $user, $password) or die ('somethng went
wrong:' .mysql_error() );
  mysql_select_db($dbname, $link) or die ('somethng went wrong, DB error:'
.mysql_error() );

$query = SELECT DISTINCT gallery FROM thumbnails;
$result = @mysql_query( $query,$link );


and also dont use @ to suppress errors it will cause your more
problems, turn off display_errors and keep error_reportlng at minimum
E_WARNING, and log the errors to a file.

Curt.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help with dynamic radio buttons

2006-07-24 Thread Dimiter Ivanov

On 7/22/06, Chris Grigor [EMAIL PROTECTED] wrote:

Afternoon all

I need some help here with a problem on dynamic radio buttons.

I have a script that calls a database for a list of questions. The questions
are returned and each question needs to have 5
radio buttons assigned to it. The radio buttons are a score of 1 - 5 (1
being bad, 5 being good)

For example

1 . How would you rate your vacation?1 2 3 4 5 --- those are the radio
buttons.
2. How would you rate your dining at the resort? 1 2 3 4 5


Ok so I have all the questions being returned, I was thinking when creating
the radio buttons as follows

input name=?php echo $row_get_question_list['id']? type=radio
value=1 /
input name=?php echo $row_get_question_list['id']? type=radio
value=2 /
input name=?php echo $row_get_question_list['id']? type=radio
value=3 /
input name=?php echo $row_get_question_list['id']? type=radio
value=4 /
input name=?php echo $row_get_question_list['id']? type=radio
value=5 /

The input name for each radio group is the questions id from the database.
If there are 50 questions you would have 50 radio button answers submitted.
How are you going to identify the radio buttons being submitted as they are
dynamic? and also I would need to be stored in the
session data as they might want to go back / forward a page.

So basically I need to go through each $_GET item, identify it as a radio
submission and put it into an array.

Has anyone done anything similar before / or can point me in the right
direction??

Kind regards
Chris





You won't get all the radio buttons sumbitted.
You will have only the checked buttons.
So for every question's ID you will have the radio button that was checked.

Just do some testing.
Try echoing the $_POST array after you submit the form.
var_dump($_POST);

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help with some clever bit operations

2006-06-13 Thread David Tulloh
The example starting values
$existing = 181; # = 10110101
$new = 92; # = 01011100
$mask = 15; # = 

Get the bits that will be changed
$changing = $new  $mask; # = 12 = 1100

Get the bits that won't be changed
$staying = $existing  ~$mask; # = 176 = 1011

Combine them together
$result = $changing ^ $staying; # = 188 = 1000


David

Niels wrote:
 Hi,
 
 I have a problem I can solve with some loops and if-thens, but I'm sure it
 can be done with bit operations -- that would be prettier. I've tried to
 work it out on paper, but I keep missing the final solution. Maybe I'm
 missing something obvious...
 
 The problem: A function tries to update an existing value, but is only
 allowed to write certain bits.
 
 There are 3 variables:
 A: the existing value, eg. 10110101
 B: what the function wants to write, eg. 01011100
 C: which bits the function is allowed to write, eg. 
 
 With these examples, 1000 should be written.
 
 How do I combine A, B and C to get that result?
 
 
 Thanks,
 Niels
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help with some clever bit operations

2006-06-13 Thread Jochem Maas
Niels wrote:
 Hi,
 
 I have a problem I can solve with some loops and if-thens, but I'm sure it
 can be done with bit operations -- that would be prettier. I've tried to
 work it out on paper, but I keep missing the final solution. Maybe I'm
 missing something obvious...
 
 The problem: A function tries to update an existing value, but is only
 allowed to write certain bits.
 
 There are 3 variables:
 A: the existing value, eg. 10110101
 B: what the function wants to write, eg. 01011100
 C: which bits the function is allowed to write, eg. 
 
 With these examples, 1000 should be written.

My brain needs a crutch when trying doing this kind of thing
(normally I only write hex number literally when dealing with bitwise stuff -
the conversion stuff still makes my head spin) - this is what this table is for:

128 64 32 16 8 4 2 1
1   0  1  1  0 1 0 1
0   1  0  1  1 1 0 0
0   0  0  0  1 1 1 1

and then I did this - hopefully it shows what you can/have to do:

?php

// set some values
$oldval = 128 + 32 + 16 + 4 + 1; // 10110101
$update = 64 + 16 + 8 + 4;   // 01011100
$mask   = 8 + 4 + 2 + 1; // 

// do a 'bit' of surgery ...
$add= $mask  $update;
$keep   = ~$mask  $oldval;
$newval = $keep | $add;

// show what happened
var_dump(
str_pad(base_convert($oldval, 10, 2), 8, 0),
str_pad(base_convert($update, 10, 2), 8, 0),
str_pad(base_convert($mask, 10, 2), 8, 0),
str_pad(base_convert($add, 10, 2), 8, 0),
str_pad(base_convert($keep, 10, 2), 8, 0),
str_pad(base_convert($newval, 10, 2), 8, 0)
);

?

 
 How do I combine A, B and C to get that result?
 
 
 Thanks,
 Niels
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help with some clever bit operations

2006-06-13 Thread Jochem Maas
David Tulloh wrote:
 The example starting values
 $existing = 181; # = 10110101
 $new = 92; # = 01011100
 $mask = 15; # = 
 
 Get the bits that will be changed
 $changing = $new  $mask; # = 12 = 1100
 
 Get the bits that won't be changed
 $staying = $existing  ~$mask; # = 176 = 1011
 
 Combine them together
 $result = $changing ^ $staying; # = 188 = 1000

heck, Davids 'result' line is more correct than mine I believe -
he uses an XOR operation where I used an OR operation - both have the same
result because the set of bits that are 'on' in the first operand are mutually
exclusive to the set of bits that are 'on' in the second operand.

 
 
 David
 
 Niels wrote:
 Hi,

 I have a problem I can solve with some loops and if-thens, but I'm sure it
 can be done with bit operations -- that would be prettier. I've tried to
 work it out on paper, but I keep missing the final solution. Maybe I'm
 missing something obvious...

 The problem: A function tries to update an existing value, but is only
 allowed to write certain bits.

 There are 3 variables:
 A: the existing value, eg. 10110101
 B: what the function wants to write, eg. 01011100
 C: which bits the function is allowed to write, eg. 

 With these examples, 1000 should be written.

 How do I combine A, B and C to get that result?


 Thanks,
 Niels

 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Help with some clever bit operations

2006-06-13 Thread Ford, Mike
On 13 June 2006 10:31, Niels wrote:

 Hi,
 
 I have a problem I can solve with some loops and if-thens,
 but I'm sure it
 can be done with bit operations -- that would be prettier.
 I've tried to
 work it out on paper, but I keep missing the final solution. Maybe
 I'm missing something obvious... 
 
 The problem: A function tries to update an existing value, but is only
 allowed to write certain bits.
 
 There are 3 variables:
 A: the existing value, eg. 10110101
 B: what the function wants to write, eg. 01011100
 C: which bits the function is allowed to write, eg. 
 
 With these examples, 1000 should be written.
 
 How do I combine A, B and C to get that result?

First use  (bitwise-and) to mask out bits the function is not allowed to write:

$b  $c // result is 1100 given above inputs

Then mask the bits that the function will write out of the original value - 
negate the mask and use  again:

$a  ~$c // result is 1011

Then combine the two using | (bitwise-or):

($a  ~$c) | ($b  $c) // result is 1001


Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Help with some clever bit operations

2006-06-13 Thread Niels
On Tuesday 13 June 2006 12:32, Ford, Mike wrote:

 On 13 June 2006 10:31, Niels wrote:
 
 Hi,
 
 I have a problem I can solve with some loops and if-thens,
 but I'm sure it
 can be done with bit operations -- that would be prettier.
 I've tried to
 work it out on paper, but I keep missing the final solution. Maybe
 I'm missing something obvious...
 
 The problem: A function tries to update an existing value, but is only
 allowed to write certain bits.
 
 There are 3 variables:
 A: the existing value, eg. 10110101
 B: what the function wants to write, eg. 01011100
 C: which bits the function is allowed to write, eg. 
 
 With these examples, 1000 should be written.
 
 How do I combine A, B and C to get that result?
 
 First use  (bitwise-and) to mask out bits the function is not allowed to
 write:
 
 $b  $c // result is 1100 given above inputs
 
 Then mask the bits that the function will write out of the original value
 - negate the mask and use  again:
 
 $a  ~$c // result is 1011
 
 Then combine the two using | (bitwise-or):
 
 ($a  ~$c) | ($b  $c) // result is 1001
 [snip]

Thanks! I appreciate your effort!

Regards,
Niels

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help with some clever bit operations

2006-06-13 Thread Niels
On Tuesday 13 June 2006 12:22, Jochem Maas wrote:

 Niels wrote:
 Hi,
 
 I have a problem I can solve with some loops and if-thens, but I'm sure
 it can be done with bit operations -- that would be prettier. I've tried
 to work it out on paper, but I keep missing the final solution. Maybe I'm
 missing something obvious...
 
 The problem: A function tries to update an existing value, but is only
 allowed to write certain bits.
 
 There are 3 variables:
 A: the existing value, eg. 10110101
 B: what the function wants to write, eg. 01011100
 C: which bits the function is allowed to write, eg. 
 
 With these examples, 1000 should be written.
 
 My brain needs a crutch when trying doing this kind of thing
 (normally I only write hex number literally when dealing with bitwise
 stuff - the conversion stuff still makes my head spin) - this is what this
 table is for:
 
 128 64 32 16 8 4 2 1
 1   0  1  1  0 1 0 1
 0   1  0  1  1 1 0 0
 0   0  0  0  1 1 1 1
 
 and then I did this - hopefully it shows what you can/have to do:
 
 ?php
 
 // set some values
 $oldval = 128 + 32 + 16 + 4 + 1; // 10110101
 $update = 64 + 16 + 8 + 4; // 01011100
 $mask   = 8 + 4 + 2 + 1;   // 
 
 // do a 'bit' of surgery ...
 $add= $mask  $update;
 $keep   = ~$mask  $oldval;
 $newval = $keep | $add;
 
 // show what happened
 var_dump(
 str_pad(base_convert($oldval, 10, 2), 8, 0),
 str_pad(base_convert($update, 10, 2), 8, 0),
 str_pad(base_convert($mask, 10, 2), 8, 0),
 str_pad(base_convert($add, 10, 2), 8, 0),
 str_pad(base_convert($keep, 10, 2), 8, 0),
 str_pad(base_convert($newval, 10, 2), 8, 0)
 );
 
 ?
 
 
 How do I combine A, B and C to get that result?
 
 
 Thanks,
 Niels



Thanks, I appreciate your effort! Working code with inlined pun -- very
nice!

Regards,
Niels

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help with some clever bit operations

2006-06-13 Thread Niels
On Tuesday 13 June 2006 12:18, David Tulloh wrote:

 The example starting values
 $existing = 181; # = 10110101
 $new = 92; # = 01011100
 $mask = 15; # = 
 
 Get the bits that will be changed
 $changing = $new  $mask; # = 12 = 1100
 
 Get the bits that won't be changed
 $staying = $existing  ~$mask; # = 176 = 1011
 
 Combine them together
 $result = $changing ^ $staying; # = 188 = 1000
 
 
 David
[snip]

Thank you very much, I appreciate it!

Niels

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help with some clever bit operations

2006-06-13 Thread Satyam


- Original Message - 
From: David Tulloh [EMAIL PROTECTED]

To: [EMAIL PROTECTED]
Cc: php-general@lists.php.net
Sent: Tuesday, June 13, 2006 12:18 PM
Subject: Re: [PHP] Help with some clever bit operations



The example starting values
$existing = 181; # = 10110101
$new = 92; # = 01011100
$mask = 15; # = 

Get the bits that will be changed
$changing = $new  $mask; # = 12 = 1100

Get the bits that won't be changed
$staying = $existing  ~$mask; # = 176 = 1011

Combine them together
$result = $changing ^ $staying; # = 188 = 1000


David



Though the result is the same, logically a bitwise OR (|) would be more 
appropriate.  The bitwise  XOR flips bits which, since in this case one set 
of them is always 0 produces the same result.  The bitwise OR adds the bits.


An informal set of rules is:

, as a filter, extracts those bits where you put ones in the mask
 sets to zero those bits where you put zero in the mask
| sets bits
^ flips the bits where you put a one.

$evenodd   1 is true on odd numbers or otherwise tests for the rightmost 
bit.  Coupled with a right shift  allows you to loop through a set of 
bits.


for ($i=0;$i32;$i++) {
   if ($bitset  1) {
   echo bit $i is set;
   }
   $bitset = 1;
}

Anyway, avoid the most significant bit.  Since in PHP there are no unsigned 
integers, you might get some funny result if anything makes PHP do an 
automatic type conversion.


Satyam

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help with some clever bit operations

2006-06-13 Thread Robert Cummings
On Tue, 2006-06-13 at 06:22, Jochem Maas wrote:

 My brain needs a crutch when trying doing this kind of thing
 (normally I only write hex number literally when dealing with bitwise stuff -
 the conversion stuff still makes my head spin) - this is what this table is 
 for:
 
 128 64 32 16 8 4 2 1
 1   0  1  1  0 1 0 1
 0   1  0  1  1 1 0 0
 0   0  0  0  1 1 1 1
 
 and then I did this - hopefully it shows what you can/have to do:
 
 ?php
 
 // set some values
 $oldval = 128 + 32 + 16 + 4 + 1; // 10110101
 $update = 64 + 16 + 8 + 4; // 01011100
 $mask   = 8 + 4 + 2 + 1;   // 

You could just do the following:

$oldval = bindec( '10110101' );
$update = bindec( '01011100' );
$mask   = bindec( '' );

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help with some clever bit operations

2006-06-13 Thread Jochem Maas
Robert Cummings wrote:
 On Tue, 2006-06-13 at 06:22, Jochem Maas wrote:
 My brain needs a crutch when trying doing this kind of thing
 (normally I only write hex number literally when dealing with bitwise stuff -
 the conversion stuff still makes my head spin) - this is what this table is 
 for:

 128 64 32 16 8 4 2 1
 1   0  1  1  0 1 0 1
 0   1  0  1  1 1 0 0
 0   0  0  0  1 1 1 1

 and then I did this - hopefully it shows what you can/have to do:

 ?php

 // set some values
 $oldval = 128 + 32 + 16 + 4 + 1; // 10110101
 $update = 64 + 16 + 8 + 4;// 01011100
 $mask   = 8 + 4 + 2 + 1;  // 
 
 You could just do the following:
 
 $oldval = bindec( '10110101' );
 $update = bindec( '01011100' );
 $mask   = bindec( '' );

when I was writing the reply I played with about 5 different
conversion funcs - pretty everything expect bindec() !!!

I guess i was being lazy - but then I alway think directly in hex numbers
when doing bitwise stuff (at least I use hex notation for the constant value
that I almost invariably end up creating)

anyway cheers for the lightbuld moment :-)

 
 Cheers,
 Rob.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help with some clever bit operations

2006-06-13 Thread Robert Cummings
On Tue, 2006-06-13 at 11:03, Jochem Maas wrote:
 Robert Cummings wrote:
  On Tue, 2006-06-13 at 06:22, Jochem Maas wrote:
  My brain needs a crutch when trying doing this kind of thing
  (normally I only write hex number literally when dealing with bitwise 
  stuff -
  the conversion stuff still makes my head spin) - this is what this table 
  is for:
 
  128 64 32 16 8 4 2 1
  1   0  1  1  0 1 0 1
  0   1  0  1  1 1 0 0
  0   0  0  0  1 1 1 1
 
  and then I did this - hopefully it shows what you can/have to do:
 
  ?php
 
  // set some values
  $oldval = 128 + 32 + 16 + 4 + 1; // 10110101
  $update = 64 + 16 + 8 + 4;  // 01011100
  $mask   = 8 + 4 + 2 + 1;// 
  
  You could just do the following:
  
  $oldval = bindec( '10110101' );
  $update = bindec( '01011100' );
  $mask   = bindec( '' );
 
 when I was writing the reply I played with about 5 different
 conversion funcs - pretty everything expect bindec() !!!
 
 I guess i was being lazy - but then I alway think directly in hex numbers
 when doing bitwise stuff (at least I use hex notation for the constant value
 that I almost invariably end up creating)
 
 anyway cheers for the lightbuld moment :-)

Well yours is at least faster since there's no function calls. Though
one can also do the following to avoid memorizing decimal bit values :)

$oldval = (1  7) + (1  5) + (1  4) + (1  2) + (1  0);
$update = (1  6) + (1  4) + (1  3) + (1  2);
$mask   = (1  3) + (1  2) + (1  1) + (1  0);

:)

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help with some clever bit operations

2006-06-13 Thread Jochem Maas
Robert Cummings wrote:
 On Tue, 2006-06-13 at 11:03, Jochem Maas wrote:
 Robert Cummings wrote:
 On Tue, 2006-06-13 at 06:22, Jochem Maas wrote:
 My brain needs a crutch when trying doing this kind of thing
 (normally I only write hex number literally when dealing with bitwise 
 stuff -
 the conversion stuff still makes my head spin) - this is what this table 
 is for:

 128 64 32 16 8 4 2 1
 1   0  1  1  0 1 0 1
 0   1  0  1  1 1 0 0
 0   0  0  0  1 1 1 1

 and then I did this - hopefully it shows what you can/have to do:

 ?php

 // set some values
 $oldval = 128 + 32 + 16 + 4 + 1; // 10110101
 $update = 64 + 16 + 8 + 4;  // 01011100
 $mask   = 8 + 4 + 2 + 1;// 
 You could just do the following:

 $oldval = bindec( '10110101' );
 $update = bindec( '01011100' );
 $mask   = bindec( '' );
 when I was writing the reply I played with about 5 different
 conversion funcs - pretty everything expect bindec() !!!

 I guess i was being lazy - but then I alway think directly in hex numbers
 when doing bitwise stuff (at least I use hex notation for the constant value
 that I almost invariably end up creating)

 anyway cheers for the lightbuld moment :-)
 
 Well yours is at least faster since there's no function calls. Though
 one can also do the following to avoid memorizing decimal bit values :)
 
 $oldval = (1  7) + (1  5) + (1  4) + (1  2) + (1  0);
 $update = (1  6) + (1  4) + (1  3) + (1  2);
 $mask   = (1  3) + (1  2) + (1  1) + (1  0);

cool - more brainfood. thanks!

 
 :)
 
 Cheers,
 Rob.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help with enter key in Forms

2006-06-02 Thread Martin Alterisio

2006/6/2, George Babichev [EMAIL PROTECTED]:


Awesome, thank you so much! It works!

On 6/1/06, Chris [EMAIL PROTECTED] wrote:

 George Babichev wrote:
  Ok, I sent it to everyone and you. Now can you answer my question
 please?
  I type in
  1
 
 
 
  2
  into my form in the program that i made, then when I view it, it shows
  1 2
  BUT if I check it in PHP My Admin it displays
  1
 
 
 
  2

 The answer is to change this:

 ? echo .$row['post'].

 to this:

 ? echo .nl2br($row['post']).


 like I said before...

 --
 Postgresql  php tutorials
 http://www.designmagick.com/




Now that your problem is solved it would be a nice idea to study a little
bit more about HTML and PHP so that you can find the explanation and
solution for this and other problems on your own. Please read the manual,
specially when someone is kind enough to point you the exact function to
look for.

PS: Have you understood what went wrong in your script? Have you understood
what is the purpose of nl2br? If not, the kindness of those who answered you
will have been in vain.


Re: [PHP] Help with enter key in Forms

2006-06-01 Thread Chris

George Babichev wrote:

Hello everyone, I am programming a blog, and most of it is done, except I
have one issue. When I am typing in the form (before I click submit) and I
click the neter key to make a space, the MySQL database does not recognize
that space. How do I make it recognize it?


Unless you're stripping it out, it will recognise it. View HTML Source 
and you'll see the newline is actually in there. A \n is not a html 
newline so you need to convert it.


What you want is http://php.net/nl2br

--
Postgresql  php tutorials
http://www.designmagick.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help with enter key in Forms

2006-06-01 Thread Chris

George Babichev wrote:
Ok. well I looked more deeply into the issue, and I noticed that PHP My 
Admin does recognize that there are spaces. So if I click edit on PMA, 
it displays everything exactly liked I typed it. So why does my program 
not display it? This is the code I use


Then you're not saving the spaces - so of course they can't be displayed.

Always CC the list, you will get much better responses.


--
Postgresql  php tutorials
http://www.designmagick.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help with enter key in Forms

2006-06-01 Thread George Babichev

Ok, I sent it to everyone and you. Now can you answer my question please?
I type in
1



2
into my form in the program that i made, then when I view it, it shows
1 2
BUT if I check it in PHP My Admin it displays
1



2

So why is my program not showing those spaces?


On 6/1/06, Chris [EMAIL PROTECTED] wrote:


George Babichev wrote:
 I can't exactly reply all, because It is only sending it to you. Ok, so
 wait, the data with the spaces (enter keys), but why does my program not
 show it? Look. This is what I mean

In your email program hit Reply ALL instead of Reply.

Until you work out how to do that, I'm going to ignore your emails.

--
Postgresql  php tutorials
http://www.designmagick.com/



Re: [PHP] Help with enter key in Forms

2006-06-01 Thread Chris

George Babichev wrote:

Ok, I sent it to everyone and you. Now can you answer my question please?
I type in
1



2
into my form in the program that i made, then when I view it, it shows
1 2
BUT if I check it in PHP My Admin it displays
1



2


The answer is to change this:

? echo .$row['post'].

to this:

? echo .nl2br($row['post']).


like I said before...

--
Postgresql  php tutorials
http://www.designmagick.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help with enter key in Forms

2006-06-01 Thread Chuck Anderson

Chris wrote:

George Babichev wrote:
  

Hello everyone, I am programming a blog, and most of it is done, except I
have one issue. When I am typing in the form (before I click submit) and I
click the neter key to make a space, the MySQL database does not recognize
that space. How do I make it recognize it?



Unless you're stripping it out, it will recognise it. View HTML Source 
and you'll see the newline is actually in there. A \n is not a html 
newline so you need to convert it.


What you want is http://php.net/nl2br

  

Uhhh  did you try this -- nl2br?

--
*
Chuck Anderson • Boulder, CO
http://www.CycleTourist.com
*

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help with enter key in Forms

2006-06-01 Thread George Babichev

Awesome, thank you so much! It works!

On 6/1/06, Chris [EMAIL PROTECTED] wrote:


George Babichev wrote:
 Ok, I sent it to everyone and you. Now can you answer my question
please?
 I type in
 1



 2
 into my form in the program that i made, then when I view it, it shows
 1 2
 BUT if I check it in PHP My Admin it displays
 1



 2

The answer is to change this:

? echo .$row['post'].

to this:

? echo .nl2br($row['post']).


like I said before...

--
Postgresql  php tutorials
http://www.designmagick.com/



Re: [PHP] help needed with pager

2006-05-25 Thread Rabin Vincent

On 5/25/06, Ross [EMAIL PROTECTED] wrote:


http://scottishsocialnetworks.org/editor.php

http://scottishsocialnetworks.org/editor.phps

the pager in this page works except try and choose aberdeen from the area
dropdown. You should get 18 answers which is fine except when page 2 is
pressed at the bottom the query seems to be scrubbed and it returns the full
database.

any ideas how I can 'save' the query and not create a new blank query every
time the page is slef submitted?


Get your variables, like 'area', from $_GET if they're not in $_POST.
And then you can change your page navigation links to something
like:

echo $pager-get_prev('a href={LINK_HREF}area=' . $area . '
title=Previouslaquo;/a');

Rabin

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] HELP - Clean and simple

2006-05-22 Thread chris smith

On 5/22/06, Jonas Rosling [EMAIL PROTECTED] wrote:

I don't know if I'm explaining things in a difficult way or not. But I'm
gonna try to explaine what I want very clean and simple.

1. I wan't to check if an array is decleard or not, refering to a value in a
row/field ($row[0])
2. If it's not decleard I declear it and assign it's name by the value from
a row/field ($row[0])
- Further down I shell fill it with values like $arrayname[$row[2]] =
$row[1] (arrayname based on $row[0])
3. Else if it's decleard fill it with values like above.

Hope someone understands me.


And what code do you have so far? We're not going to write it for you.

--
Postgresql  php tutorials
http://www.designmagick.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] HELP - Clean and simple

2006-05-22 Thread Jay Blanchard
[snip]
I don't know if I'm explaining things in a difficult way or not. But I'm
gonna try to explaine what I want very clean and simple.

1. I wan't to check if an array is decleard or not, refering to a value
in a
row/field ($row[0])
2. If it's not decleard I declear it and assign it's name by the value
from
a row/field ($row[0])
- Further down I shell fill it with values like
$arrayname[$row[2]] =
$row[1] (arrayname based on $row[0])
3. Else if it's decleard fill it with values like above.
[/snip]

http://www.php.net/array
http://www.php.net/is_array

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] HELP - Clean and simple

2006-05-22 Thread Rabin Vincent

On 5/22/06, Jonas Rosling [EMAIL PROTECTED] wrote:

:-) Sorry! I've been digging with this for a while now so I don't think I
have the best code left. But this is what I have for the moment:

while($row=mysql_fetch_array($result)) {

if (!$$row[0]) {

$$row[0] = array();

$$row[0][$row[2]] = $row[1];

}

else {

$$row[0][$row[2]] = $row[1];

}

}

I've been trying with eval() a bit as well without any good result.


The above code will work properly if you surround the
dynamic variable names by curly brackets:

   ${$row[0]}[$row[2]] = $row[1];

Rabin

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] HELP - Clean and simple

2006-05-22 Thread Scott Hurring

On 5/22/06, Jonas Rosling [EMAIL PROTECTED] wrote:


while($row=mysql_fetch_array($result)) {

if (!$$row[0]) {

$$row[0] = array();

$$row[0][$row[2]] = $row[1];

}

else {

$$row[0][$row[2]] = $row[1];

}

}



IMO, unless you have a *really* good reason for doing things this way,
putting values into an array is almost always better than using the $$
direct declaration.

i.e.  why not use? $vars[ $row[0] ][ $row[2] ] = $row[1];

--
Scott Hurring [scott dot hurring dot lists at gmail dot com]
http://hurring.com/


Re: [PHP] HELP - Clean and simple

2006-05-22 Thread Richard Lynch

http://php.net/isset


On Mon, May 22, 2006 8:45 am, Jonas Rosling wrote:
 I don't know if I'm explaining things in a difficult way or not. But
 I'm
 gonna try to explaine what I want very clean and simple.

 1. I wan't to check if an array is decleard or not, refering to a
 value in a
 row/field ($row[0])
 2. If it's not decleard I declear it and assign it's name by the value
 from
 a row/field ($row[0])
   - Further down I shell fill it with values like $arrayname[$row[2]] =
 $row[1] (arrayname based on $row[0])
 3. Else if it's decleard fill it with values like above.

 Hope someone understands me.

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help w/ 'headers already sent' and file download

2006-05-16 Thread Mike Walsh

Rabin Vincent [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
On 5/16/06, Mike Walsh [EMAIL PROTECTED] wrote:

[ ... snipped ... ]


 Is there a way to both display a web page and send content to be saved by
 the user?  If someone knows of an example I could look at I'd be greatful.

No, you cannot display both a webpage and send a file
on the same page to the user.

What you could do is save the processed file in a temporary
folder and provide a link to download the file in your processing
statistics page. Or, you could redirect the user to the file after
showing the statistics page.

Rabin

[ ... snipped ... ]

I found a solution to my problem - an IFRAME with a 0 height and 0 width 
does the trick.

Here is a thread which helped: 
http://forums.invisionpower.com/index.php?showtopic=214649

Mike

--
Mike Walsh - mike_walsh at mindspring.com 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help w/ 'headers already sent' and file download

2006-05-16 Thread Richard Lynch
On Mon, May 15, 2006 10:48 pm, Mike Walsh wrote:
 Is there a way to both display a web page and send content to be saved
 by
 the user?

Not really really, but you can sort of hack it...

 If someone knows of an example I could look at I'd be
 greatful.

Send out the HTML for the stats, and bury a META tag something like:

META HTTP-EQUIV=REFRESH
CONTENT=0;http://example.com/cached_results.csv; /

Course, now you have to work out how to keep the CSV file around long
enough for it to download, and not criss-cross the files and purge
them when they are old and all that...

But it will sort of work like you think you want.

Another option would be to just display the stats and provide a
download link for right-click to get the CSV

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help w/ 'headers already sent' and file download

2006-05-15 Thread Rabin Vincent

On 5/16/06, Mike Walsh [EMAIL PROTECTED] wrote:

I have an application which I am working on which takes a file supplied by
the user via a File Upload, peforms some processing on it, then prompts the
user to download a generated CSV file.  What I would like to do is report
some processing statistics prior to the user prior to sending the CSV steam.

My CSV export ends with this:


header(Content-type: application/vnd.ms-excel) ;
header(Content-disposition:  attachment; filename=CSVData. .
date(Y-m-d)..csv) ;

print $csvStream ;

Unfortunately if I display any content prior to sending the CSV stream I get
the 'headers already sent' error message.

Is there a way to both display a web page and send content to be saved by
the user?  If someone knows of an example I could look at I'd be greatful.


No, you cannot display both a webpage and send a file
on the same page to the user.

What you could do is save the processed file in a temporary
folder and provide a link to download the file in your processing
statistics page. Or, you could redirect the user to the file after
showing the statistics page.

Rabin

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help!

2006-04-29 Thread chris smith

On 4/29/06, Dave Goodchild [EMAIL PROTECTED] wrote:

Thanks all. Worst case scenario I can rebuild from the demo as it works
(really don't want to do that). Was loathe to plaster your screens with
miles of code but understand it's hard to assit without it.


If you still need help..

http://www.pastebin.com

send us a url with your code and we'll go from there.

--
Postgresql  php tutorials
http://www.designmagick.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help!

2006-04-29 Thread Dave Goodchild

Misleading to who? I own the app and am the only person who will ever use
it. Rather anal.

On 29/04/06, Martin Alterisio [EMAIL PROTECTED] wrote:


2006/4/28, Barry [EMAIL PROTECTED]:

 Martin Alterisio schrieb:
  2006/4/28, Dave Goodchild [EMAIL PROTECTED]:
 
  Hi all - I am attempting to solve some maddening behaviour that has
me
  totally stumped and before I take a blade to my throat I thought I
 would
  pick the brains of the group/hive/gang.
 
  I am working on a viral marketing application that uses multipart
 emails
  to
  notify entrants of their progress in the 'game'. I have a demo
version
  which
  works fine, and the current rebranded version was also fine until the
  client
  asked for some changes then POW!
 
  I will try and define the issue as simply as I can. I am passing 11
  arguments to a function called sendSantaMail (don't ask) and as a
 sanity
  check I have called mail() to let me know the values just before they
 are
  passed in to the function. I get this result:
 
 
  sendSantaMail That's just not a *declarative* way of naming a
 function.
 Do you know what santa means? No? so how can you tell it's not
 declarative.
 Santa could be a coded Mailer and that functions uses that specific
 Mailer Deamon called santa to send mails.


Yeah you're right, I was thinking the exact same thing a while after I
posted that. Maybe it was a correct name in the context used, but, I still
think Santa is a really misleading name for a mailer, and not to mention
that a mass mailer identifying itself as Santa mailer in the headers is
asking to be send directly to spam. Anyway, I was wrong.

 Then, 11 arguments Errr, passing an associative array with the email
  parameters wouldn't have been a cleaner and better option?

 He just told he passes 11 arguments, never told how he does that.


Well, if somebody tells you a function has 11 arguments what would you
think?





--
http://www.web-buddha.co.uk

dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css)

look out for project karma, our new venture, coming soon!


Re: [PHP] Help!

2006-04-29 Thread Richard Lynch
On Fri, April 28, 2006 8:11 am, Dave Goodchild wrote:
 I am working on a viral marketing application that uses multipart
 emails to
 notify entrants of their progress in the 'game'. I have a demo version
 which
 works fine, and the current rebranded version was also fine until the
 client
 asked for some changes then POW!

Maybe your scripts have a viral infection? :-)

 I will try and define the issue as simply as I can. I am passing 11
 arguments to a function called sendSantaMail (don't ask) and as a
 sanity
 check I have called mail() to let me know the values just before they
 are
 passed in to the function. I get this result:

 Values to be passed to sendSantaMail:

 Friend Name: Treyt
 Friend Email: [EMAIL PROTECTED]
 Sender Name: Bull Sykes
 Sender Email: [EMAIL PROTECTED]
 Prize ID: 1
 Nominator ID: 2555004452133557e4d
 Nominee ID: 851355445213355cc6f
 Chain ID: CHAIN824452133561a8d

 - this is all good and correct. I also call mail from the receiving
 function
 to check the actual values received by the function and I get this:

 Values sent into sendSantaMail function:

 Friend Name: [EMAIL PROTECTED]
 Friend Email: Look what you may have won!
 Sender Name: 8 Use of undefined constant prize - assumed 'prize'

I dunno how you managed to get this inte the $name variable, or
whatever, but in line 8 of *SOME* script somewhere, you have something
like:

$foo = prize;

PHP is complaining because prize isn't delimited by quotes or
apostrophes, so you're pretty much pushing PHP up against a wall and
forcing it to GUESS what the heck you meant.

And computers do NOT like to guess.  Nosireebob.

So put some quotes around prize and make it prize or 'prize'

 Sender Email: 158

I dunno where the 158 is coming from...

Or maybe it's line 158, and the 8 is the number corresponding to
E_NOTICE, and you have a custom error handler outputting E_NOTICE,
which is really 8...

 Sender Email: /home/friend/public_html/process1.php

I'm guessing that the error on line 8 (or maybe 158) is actually in
the file 'process1.php'

If your scripts are passing stuff around to each other, with ':' in
between, this would all make a lot of sense, as you've got one script
printing out an error about line 158 in process1.php, and you've got
another script reading that error output and assuming it's valid data.

 [EMAIL PROTECTED]Prize: 1
 Subject: 158
 Nominator ID: 33238744520f5235b85
 Nominee ID: 96658244520f524bb19
 Chain ID: CHAIN84644520f525a56f

 What is happening? I have checked the order of values being passed in
 and
 the function prototype and they match in the correct order, there are
 no
 default values. I have been trying to solve this for two days and am
 particularly concerned that somewhere along the way the sender email
 value
 becomes the script name.

 Any ideas on this black Friday?

I don't even want to think about what your code must look like if my
theories are correct...

I just hope to [deity] that these are all opt-in lists or whatever and
I'm not helping some spammer. :-(

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help!

2006-04-29 Thread Dave Goodchild

All my variables are correctly delimited. And don't make assumptions about
what my code looks like - I am asking for help, not judgements, and my
question was valid (unlike many you see here). I am not a spammer either,
this is an application for the marketing department of a charity.

On 29/04/06, Richard Lynch [EMAIL PROTECTED] wrote:


On Fri, April 28, 2006 8:11 am, Dave Goodchild wrote:
 I am working on a viral marketing application that uses multipart
 emails to
 notify entrants of their progress in the 'game'. I have a demo version
 which
 works fine, and the current rebranded version was also fine until the
 client
 asked for some changes then POW!

Maybe your scripts have a viral infection? :-)

 I will try and define the issue as simply as I can. I am passing 11
 arguments to a function called sendSantaMail (don't ask) and as a
 sanity
 check I have called mail() to let me know the values just before they
 are
 passed in to the function. I get this result:

 Values to be passed to sendSantaMail:

 Friend Name: Treyt
 Friend Email: [EMAIL PROTECTED]
 Sender Name: Bull Sykes
 Sender Email: [EMAIL PROTECTED]
 Prize ID: 1
 Nominator ID: 2555004452133557e4d
 Nominee ID: 851355445213355cc6f
 Chain ID: CHAIN824452133561a8d

 - this is all good and correct. I also call mail from the receiving
 function
 to check the actual values received by the function and I get this:

 Values sent into sendSantaMail function:

 Friend Name: [EMAIL PROTECTED]
 Friend Email: Look what you may have won!
 Sender Name: 8 Use of undefined constant prize - assumed 'prize'

I dunno how you managed to get this inte the $name variable, or
whatever, but in line 8 of *SOME* script somewhere, you have something
like:

$foo = prize;

PHP is complaining because prize isn't delimited by quotes or
apostrophes, so you're pretty much pushing PHP up against a wall and
forcing it to GUESS what the heck you meant.

And computers do NOT like to guess.  Nosireebob.

So put some quotes around prize and make it prize or 'prize'

 Sender Email: 158

I dunno where the 158 is coming from...

Or maybe it's line 158, and the 8 is the number corresponding to
E_NOTICE, and you have a custom error handler outputting E_NOTICE,
which is really 8...

 Sender Email: /home/friend/public_html/process1.php

I'm guessing that the error on line 8 (or maybe 158) is actually in
the file 'process1.php'

If your scripts are passing stuff around to each other, with ':' in
between, this would all make a lot of sense, as you've got one script
printing out an error about line 158 in process1.php, and you've got
another script reading that error output and assuming it's valid data.

 [EMAIL PROTECTED]Prize: 1
 Subject: 158
 Nominator ID: 33238744520f5235b85
 Nominee ID: 96658244520f524bb19
 Chain ID: CHAIN84644520f525a56f

 What is happening? I have checked the order of values being passed in
 and
 the function prototype and they match in the correct order, there are
 no
 default values. I have been trying to solve this for two days and am
 particularly concerned that somewhere along the way the sender email
 value
 becomes the script name.

 Any ideas on this black Friday?

I don't even want to think about what your code must look like if my
theories are correct...

I just hope to [deity] that these are all opt-in lists or whatever and
I'm not helping some spammer. :-(

--
Like Music?
http://l-i-e.com/artists.htm






--
http://www.web-buddha.co.uk

dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css)

look out for project karma, our new venture, coming soon!


Re: [PHP] Help!

2006-04-29 Thread chris smith

On 4/29/06, Dave Goodchild [EMAIL PROTECTED] wrote:

All my variables are correctly delimited. And don't make assumptions about
what my code looks like - I am asking for help, not judgements, and my
question was valid (unlike many you see here). I am not a spammer either,
this is an application for the marketing department of a charity.


Did you try the debug_backtrace idea someone mentioned? What did that show?

Are you passing values in by reference anywhere?

--
Postgresql  php tutorials
http://www.designmagick.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help!

2006-04-29 Thread Richard Lynch
On Fri, April 28, 2006 8:57 am, T.Lensselink wrote:
 In the demo version the script accesses the $_GET array - an example
 value:

 $data[email]

 ..which works fine in the demo app. If I quote all the values thus
 in the
 new version:

 $data['email']

 ..the arguments appear in the correct order. I understand the second
 format
 is better to disambiguate constants but the former format works fine
 for
 the
 demo version. Any reason for the discrepancy?

The demo is running on a badly-configured server with the default
value for error_reporting of E_ALL ~ E_NOTICE

So you never *SEE* the error notice message on the demo server --
because it's getting swallowed.

On the REAL server, which is properly configured with E_ALL, you are
seeing the E_NOTICE messages telling you that your code is broken
because not putting quotes there is just plain broken.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help!

2006-04-29 Thread Richard Lynch
On Fri, April 28, 2006 9:01 am, Dave Goodchild wrote:
 Thanks - now the parameters reach the function intact but the mailer
 still
 does not work. Basically, the form is a self-reloader. If the form has
 been
 submitted and the data validated (including emails sent) it displays a
 thank
 you message. Otherwise it shows the starter form.

 All that happens when I submit is a white page - no errors
 (display_errors
 is on and error reporting set to the default level) and no html. Nada.
 When
 I try and view source I am given the browser re-post warning.

Probably:
The demo server is also badly-configured to show you error messages,
and the real server is properly-configured to not display error
messages in the browser.

You'll need to check the Apache error logs and see if the error
messages are there, or check php.ini to see if that's also turned off
-- which it might be for performance reasons...

The big problem is that your code doesn't have any sort of sanity
checking on the data, nor any decent error-handling...

It's way beyond the scope of this list to correct that, really, other
than to tell you that you really need to write a lot more code to
validate your data, and to catch and handle error conditions.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help!

2006-04-29 Thread Richard Lynch
On Fri, April 28, 2006 9:19 am, Dave Goodchild wrote:
 I would do but there are 5000+ lines and no indication of where the
 error is
 occurring. I have just copied the demo version into the same dir and
 it
 works fine - and that version calls the same classes (includes).

Go ahead and let he broser re-post the data when you do View Source
and see what you get.

If that does nothing, then add some debug lines in your code to print
out what it is doing where.

There is certainly no way any of us can guess what's wrong in the
5000+ lines any better than you can guess...

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help!

2006-04-29 Thread Dave Goodchild

Wrong - both versions run on the same server (virtual hosts but same php.ini).
I will check the values however, thanks!

On 29/04/06, Richard Lynch [EMAIL PROTECTED] wrote:


On Fri, April 28, 2006 8:57 am, T.Lensselink wrote:
 In the demo version the script accesses the $_GET array - an example
 value:

 $data[email]

 ..which works fine in the demo app. If I quote all the values thus
 in the
 new version:

 $data['email']

 ..the arguments appear in the correct order. I understand the second
 format
 is better to disambiguate constants but the former format works fine
 for
 the
 demo version. Any reason for the discrepancy?

The demo is running on a badly-configured server with the default
value for error_reporting of E_ALL ~ E_NOTICE

So you never *SEE* the error notice message on the demo server --
because it's getting swallowed.

On the REAL server, which is properly configured with E_ALL, you are
seeing the E_NOTICE messages telling you that your code is broken
because not putting quotes there is just plain broken.

--
Like Music?
http://l-i-e.com/artists.htm






--
http://www.web-buddha.co.uk

dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css)

look out for project karma, our new venture, coming soon!


Re: [PHP] Help!

2006-04-29 Thread Jochem Maas

Dave Goodchild wrote:
All my variables are correctly delimited. 


strings constants are delimited not variables, semantically speaking.

And don't make assumptions about what my code looks like 


why not? besides how are you going to stop someone from assuming your
code looks like [x]?

- I am asking for help, not judgements, and my

Richard didn't judge, he merely aired a thought (and added 'if my
theories are correct' for good measure).

 besides you only control the question not the answer.

oh and Richard is one of the best people on this list to be helping you
- alienating him isn't in your best interests.

question was valid (unlike many you see here). 


the validity of the question is a matter of consensus, again
something you don't control.


I am not a spammer either,
this is an application for the marketing department of a charity.


charities can potentially spam just as much as anybody - that they happen to
have a 'good cause' doesn't give them a 'get out of jail free' card, they have 
to
obey the email-marketing rules just like any other organization.

ad
'buy a lovely WNF cuddly toy to help protect endangered animals'
(hand made by an 8 y/o in china)
/ad

...

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help!

2006-04-29 Thread Martin Alterisio

That's ok, but then I can't help you more than I tried to.
Just check with what I told you about debug_backtrace(), at least that way
you can trace where the function was called with wrong arguments.

2006/4/29, Dave Goodchild [EMAIL PROTECTED]:


Misleading to who? I own the app and am the only person who will ever use
it. Rather anal.


On 29/04/06, Martin Alterisio  [EMAIL PROTECTED] wrote:

 2006/4/28, Barry  [EMAIL PROTECTED]:
 
  Martin Alterisio schrieb:
   2006/4/28, Dave Goodchild [EMAIL PROTECTED]:
  
   Hi all - I am attempting to solve some maddening behaviour that has
 me
   totally stumped and before I take a blade to my throat I thought I
  would
   pick the brains of the group/hive/gang.
  
   I am working on a viral marketing application that uses multipart
  emails
   to
   notify entrants of their progress in the 'game'. I have a demo
 version
   which
   works fine, and the current rebranded version was also fine until
 the
   client
   asked for some changes then POW!
  
   I will try and define the issue as simply as I can. I am passing 11
   arguments to a function called sendSantaMail (don't ask) and as a
  sanity
   check I have called mail() to let me know the values just before
 they
  are
   passed in to the function. I get this result:
  
  
   sendSantaMail That's just not a *declarative* way of naming a
  function.
  Do you know what santa means? No? so how can you tell it's not
  declarative.
  Santa could be a coded Mailer and that functions uses that specific
  Mailer Deamon called santa to send mails.


 Yeah you're right, I was thinking the exact same thing a while after I
 posted that. Maybe it was a correct name in the context used, but, I
 still
 think Santa is a really misleading name for a mailer, and not to
 mention
 that a mass mailer identifying itself as Santa mailer in the headers
 is
 asking to be send directly to spam. Anyway, I was wrong.

  Then, 11 arguments Errr, passing an associative array with the
 email
   parameters wouldn't have been a cleaner and better option?
 
  He just told he passes 11 arguments, never told how he does that.


 Well, if somebody tells you a function has 11 arguments what would you
 think?




--

http://www.web-buddha.co.uk

dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css)

look out for project karma, our new venture, coming soon!



Re: [PHP] Help!

2006-04-29 Thread Richard Lynch
On Sat, April 29, 2006 11:11 am, Jochem Maas wrote:
 Dave Goodchild wrote:
 All my variables are correctly delimited.

 strings constants are delimited not variables, semantically speaking.

Not to mention that they CANNOT be correctly delimited, or you would
NOT be seeing that error message.

It's that simple.

You SHOULD have the apostrophes (or quotes) on non-numeric array indices.

PHP issues an E_NOTICE error message if you don't.  You may have
suppressed that message, and chosen to ignore it, but that doesn't
fix the code.

After all, using the SAME mechanism of suppression, you can choose to
ignore ALL PHP errors, no matter how drastic.  Surely you cannot claim
that ignoring an error that halts the script in the middle of
execution is somehow correct

 And don't make assumptions about what my code looks like

 why not? besides how are you going to stop someone from assuming your
 code looks like [x]?

One HAS to make assumptions about the code when you fail to post
sufficient information about the code to correctly answer your
question.

 - I am asking for help, not judgements, and my

 Richard didn't judge, he merely aired a thought (and added 'if my
 theories are correct' for good measure).

   besides you only control the question not the answer.

 oh and Richard is one of the best people on this list to be helping
 you
 - alienating him isn't in your best interests.

You have to work at it pretty hard to alienate me... :-)

 I am not a spammer either,
 this is an application for the marketing department of a charity.

 charities can potentially spam just as much as anybody - that they
 happen to
 have a 'good cause' doesn't give them a 'get out of jail free' card,
 they have to
 obey the email-marketing rules just like any other organization.

Yeah, I get a fair amount of spam from otherwise legitimate charities.

Which is a shame, since then they DEFINITELY are not getting any money
from me, ever again.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help!

2006-04-28 Thread T.Lensselink
A blade? come on :)

Seems to me it's just an error in : /home/friend/public_html/process1.php
line 158 that mangles up your email output. Try and fix this undefined
constant.

 Hi all - I am attempting to solve some maddening behaviour that has me
 totally stumped and before I take a blade to my throat I thought I would
 pick the brains of the group/hive/gang.

 I am working on a viral marketing application that uses multipart emails
 to
 notify entrants of their progress in the 'game'. I have a demo version
 which
 works fine, and the current rebranded version was also fine until the
 client
 asked for some changes then POW!

 I will try and define the issue as simply as I can. I am passing 11
 arguments to a function called sendSantaMail (don't ask) and as a sanity
 check I have called mail() to let me know the values just before they are
 passed in to the function. I get this result:

 Values to be passed to sendSantaMail:

 Friend Name: Treyt
 Friend Email: [EMAIL PROTECTED]
 Sender Name: Bull Sykes
 Sender Email: [EMAIL PROTECTED]
 Prize ID: 1
 Nominator ID: 2555004452133557e4d
 Nominee ID: 851355445213355cc6f
 Chain ID: CHAIN824452133561a8d

 - this is all good and correct. I also call mail from the receiving
 function
 to check the actual values received by the function and I get this:

 Values sent into sendSantaMail function:

 Friend Name: [EMAIL PROTECTED]
 Friend Email: Look what you may have won!
 Sender Name: 8 Use of undefined constant prize - assumed 'prize'
 Sender Email: 158
 Sender Email: /home/friend/public_html/process1.php
 [EMAIL PROTECTED]Prize: 1
 Subject: 158
 Nominator ID: 33238744520f5235b85
 Nominee ID: 96658244520f524bb19
 Chain ID: CHAIN84644520f525a56f

 What is happening? I have checked the order of values being passed in and
 the function prototype and they match in the correct order, there are no
 default values. I have been trying to solve this for two days and am
 particularly concerned that somewhere along the way the sender email value
 becomes the script name.

 Any ideas on this black Friday?







 --
 http://www.web-buddha.co.uk

 dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css)

 look out for project karma, our new venture, coming soon!


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help!

2006-04-28 Thread T.Lensselink
Well there is an undefined constant prize somewhere.. well it's just a
notice but it really looks like the problem.. Try setting
error_reporting(0) and see if it runs...

 process1.php only has 64 lines.

 On 28/04/06, T.Lensselink [EMAIL PROTECTED] wrote:

 A blade? come on :)

 Seems to me it's just an error in :
 /home/friend/public_html/process1.php
 line 158 that mangles up your email output. Try and fix this undefined
 constant.

  Hi all - I am attempting to solve some maddening behaviour that has me
  totally stumped and before I take a blade to my throat I thought I
 would
  pick the brains of the group/hive/gang.
 
  I am working on a viral marketing application that uses multipart
 emails
  to
  notify entrants of their progress in the 'game'. I have a demo version
  which
  works fine, and the current rebranded version was also fine until the
  client
  asked for some changes then POW!
 
  I will try and define the issue as simply as I can. I am passing 11
  arguments to a function called sendSantaMail (don't ask) and as a
 sanity
  check I have called mail() to let me know the values just before they
 are
  passed in to the function. I get this result:
 
  Values to be passed to sendSantaMail:
 
  Friend Name: Treyt
  Friend Email: [EMAIL PROTECTED]
  Sender Name: Bull Sykes
  Sender Email: [EMAIL PROTECTED]
  Prize ID: 1
  Nominator ID: 2555004452133557e4d
  Nominee ID: 851355445213355cc6f
  Chain ID: CHAIN824452133561a8d
 
  - this is all good and correct. I also call mail from the receiving
  function
  to check the actual values received by the function and I get this:
 
  Values sent into sendSantaMail function:
 
  Friend Name: [EMAIL PROTECTED]
  Friend Email: Look what you may have won!
  Sender Name: 8 Use of undefined constant prize - assumed 'prize'
  Sender Email: 158
  Sender Email: /home/friend/public_html/process1.php
  [EMAIL PROTECTED]Prize: 1
  Subject: 158
  Nominator ID: 33238744520f5235b85
  Nominee ID: 96658244520f524bb19
  Chain ID: CHAIN84644520f525a56f
 
  What is happening? I have checked the order of values being passed in
 and
  the function prototype and they match in the correct order, there are
 no
  default values. I have been trying to solve this for two days and am
  particularly concerned that somewhere along the way the sender email
 value
  becomes the script name.
 
  Any ideas on this black Friday?
 
 
 
 
 
 
 
  --
  http://www.web-buddha.co.uk
 
  dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml,
 css)
 
  look out for project karma, our new venture, coming soon!
 





 --
 http://www.web-buddha.co.uk

 dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css)

 look out for project karma, our new venture, coming soon!


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help!

2006-04-28 Thread T.Lensselink
Hey Dave,

Besides from example two being the correct way to call array elements. I
think it has something todo with error reporting. It's the only thing that
comes to mind right now. Maybe you demo server doesn't echo notices...
Maybe i'm wrong .. it's friday and my brain don't work that good :)

p.s.
plz reply to the list :)

 Hmmm...

 In the demo version the script accesses the $_GET array - an example
 value:

 $data[email]

 ..which works fine in the demo app. If I quote all the values thus in the
 new version:

 $data['email']

 ..the arguments appear in the correct order. I understand the second
 format
 is better to disambiguate constants but the former format works fine for
 the
 demo version. Any reason for the discrepancy?

 On 28/04/06, T.Lensselink [EMAIL PROTECTED] wrote:

 Well there is an undefined constant prize somewhere.. well it's just a
 notice but it really looks like the problem.. Try setting
 error_reporting(0) and see if it runs...

  process1.php only has 64 lines.
 
  On 28/04/06, T.Lensselink [EMAIL PROTECTED] wrote:
 
  A blade? come on :)
 
  Seems to me it's just an error in :
  /home/friend/public_html/process1.php
  line 158 that mangles up your email output. Try and fix this
 undefined
  constant.
 
   Hi all - I am attempting to solve some maddening behaviour that has
 me
   totally stumped and before I take a blade to my throat I thought I
  would
   pick the brains of the group/hive/gang.
  
   I am working on a viral marketing application that uses multipart
  emails
   to
   notify entrants of their progress in the 'game'. I have a demo
 version
   which
   works fine, and the current rebranded version was also fine until
 the
   client
   asked for some changes then POW!
  
   I will try and define the issue as simply as I can. I am passing 11
   arguments to a function called sendSantaMail (don't ask) and as a
  sanity
   check I have called mail() to let me know the values just before
 they
  are
   passed in to the function. I get this result:
  
   Values to be passed to sendSantaMail:
  
   Friend Name: Treyt
   Friend Email: [EMAIL PROTECTED]
   Sender Name: Bull Sykes
   Sender Email: [EMAIL PROTECTED]
   Prize ID: 1
   Nominator ID: 2555004452133557e4d
   Nominee ID: 851355445213355cc6f
   Chain ID: CHAIN824452133561a8d
  
   - this is all good and correct. I also call mail from the receiving
   function
   to check the actual values received by the function and I get this:
  
   Values sent into sendSantaMail function:
  
   Friend Name: [EMAIL PROTECTED]
   Friend Email: Look what you may have won!
   Sender Name: 8 Use of undefined constant prize - assumed 'prize'
   Sender Email: 158
   Sender Email: /home/friend/public_html/process1.php
   [EMAIL PROTECTED]Prize: 1
   Subject: 158
   Nominator ID: 33238744520f5235b85
   Nominee ID: 96658244520f524bb19
   Chain ID: CHAIN84644520f525a56f
  
   What is happening? I have checked the order of values being passed
 in
  and
   the function prototype and they match in the correct order, there
 are
  no
   default values. I have been trying to solve this for two days and
 am
   particularly concerned that somewhere along the way the sender
 email
  value
   becomes the script name.
  
   Any ideas on this black Friday?
  
  
  
  
  
  
  
   --
   http://www.web-buddha.co.uk
  
   dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml,
  css)
  
   look out for project karma, our new venture, coming soon!
  
 
 
 
 
 
  --
  http://www.web-buddha.co.uk
 
  dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml,
 css)
 
  look out for project karma, our new venture, coming soon!
 

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




 --
 http://www.web-buddha.co.uk

 dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css)

 look out for project karma, our new venture, coming soon!


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help!

2006-04-28 Thread Dave Goodchild

Thanks - now the parameters reach the function intact but the mailer still
does not work. Basically, the form is a self-reloader. If the form has been
submitted and the data validated (including emails sent) it displays a thank
you message. Otherwise it shows the starter form.

All that happens when I submit is a white page - no errors (display_errors
is on and error reporting set to the default level) and no html. Nada. When
I try and view source I am given the browser re-post warning.

On 28/04/06, T.Lensselink [EMAIL PROTECTED] wrote:


Hey Dave,

Besides from example two being the correct way to call array elements. I
think it has something todo with error reporting. It's the only thing that
comes to mind right now. Maybe you demo server doesn't echo notices...
Maybe i'm wrong .. it's friday and my brain don't work that good :)

p.s.
plz reply to the list :)

 Hmmm...

 In the demo version the script accesses the $_GET array - an example
 value:

 $data[email]

 ..which works fine in the demo app. If I quote all the values thus in
the
 new version:

 $data['email']

 ..the arguments appear in the correct order. I understand the second
 format
 is better to disambiguate constants but the former format works fine for
 the
 demo version. Any reason for the discrepancy?

 On 28/04/06, T.Lensselink [EMAIL PROTECTED] wrote:

 Well there is an undefined constant prize somewhere.. well it's just a
 notice but it really looks like the problem.. Try setting
 error_reporting(0) and see if it runs...

  process1.php only has 64 lines.
 
  On 28/04/06, T.Lensselink [EMAIL PROTECTED] wrote:
 
  A blade? come on :)
 
  Seems to me it's just an error in :
  /home/friend/public_html/process1.php
  line 158 that mangles up your email output. Try and fix this
 undefined
  constant.
 
   Hi all - I am attempting to solve some maddening behaviour that
has
 me
   totally stumped and before I take a blade to my throat I thought I
  would
   pick the brains of the group/hive/gang.
  
   I am working on a viral marketing application that uses multipart
  emails
   to
   notify entrants of their progress in the 'game'. I have a demo
 version
   which
   works fine, and the current rebranded version was also fine until
 the
   client
   asked for some changes then POW!
  
   I will try and define the issue as simply as I can. I am passing
11
   arguments to a function called sendSantaMail (don't ask) and as a
  sanity
   check I have called mail() to let me know the values just before
 they
  are
   passed in to the function. I get this result:
  
   Values to be passed to sendSantaMail:
  
   Friend Name: Treyt
   Friend Email: [EMAIL PROTECTED]
   Sender Name: Bull Sykes
   Sender Email: [EMAIL PROTECTED]
   Prize ID: 1
   Nominator ID: 2555004452133557e4d
   Nominee ID: 851355445213355cc6f
   Chain ID: CHAIN824452133561a8d
  
   - this is all good and correct. I also call mail from the
receiving
   function
   to check the actual values received by the function and I get
this:
  
   Values sent into sendSantaMail function:
  
   Friend Name: [EMAIL PROTECTED]
   Friend Email: Look what you may have won!
   Sender Name: 8 Use of undefined constant prize - assumed 'prize'
   Sender Email: 158
   Sender Email: /home/friend/public_html/process1.php
   [EMAIL PROTECTED]Prize: 1
   Subject: 158
   Nominator ID: 33238744520f5235b85
   Nominee ID: 96658244520f524bb19
   Chain ID: CHAIN84644520f525a56f
  
   What is happening? I have checked the order of values being passed
 in
  and
   the function prototype and they match in the correct order, there
 are
  no
   default values. I have been trying to solve this for two days and
 am
   particularly concerned that somewhere along the way the sender
 email
  value
   becomes the script name.
  
   Any ideas on this black Friday?
  
  
  
  
  
  
  
   --
   http://www.web-buddha.co.uk
  
   dynamic web programming from Reigate, Surrey UK (php, mysql,
xhtml,
  css)
  
   look out for project karma, our new venture, coming soon!
  
 
 
 
 
 
  --
  http://www.web-buddha.co.uk
 
  dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml,
 css)
 
  look out for project karma, our new venture, coming soon!
 

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




 --
 http://www.web-buddha.co.uk

 dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css)

 look out for project karma, our new venture, coming soon!


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





--
http://www.web-buddha.co.uk

dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css)

look out for project karma, our new venture, coming soon!


Re: [PHP] Help!

2006-04-28 Thread T.Lensselink
Maybe show some code... Think some error inside a class / function causes
that no output is send...

 Thanks - now the parameters reach the function intact but the mailer still
 does not work. Basically, the form is a self-reloader. If the form has
 been
 submitted and the data validated (including emails sent) it displays a
 thank
 you message. Otherwise it shows the starter form.

 All that happens when I submit is a white page - no errors (display_errors
 is on and error reporting set to the default level) and no html. Nada.
 When
 I try and view source I am given the browser re-post warning.

 On 28/04/06, T.Lensselink [EMAIL PROTECTED] wrote:

 Hey Dave,

 Besides from example two being the correct way to call array elements. I
 think it has something todo with error reporting. It's the only thing
 that
 comes to mind right now. Maybe you demo server doesn't echo notices...
 Maybe i'm wrong .. it's friday and my brain don't work that good :)

 p.s.
 plz reply to the list :)

  Hmmm...
 
  In the demo version the script accesses the $_GET array - an example
  value:
 
  $data[email]
 
  ..which works fine in the demo app. If I quote all the values thus in
 the
  new version:
 
  $data['email']
 
  ..the arguments appear in the correct order. I understand the second
  format
  is better to disambiguate constants but the former format works fine
 for
  the
  demo version. Any reason for the discrepancy?
 
  On 28/04/06, T.Lensselink [EMAIL PROTECTED] wrote:
 
  Well there is an undefined constant prize somewhere.. well it's just
 a
  notice but it really looks like the problem.. Try setting
  error_reporting(0) and see if it runs...
 
   process1.php only has 64 lines.
  
   On 28/04/06, T.Lensselink [EMAIL PROTECTED] wrote:
  
   A blade? come on :)
  
   Seems to me it's just an error in :
   /home/friend/public_html/process1.php
   line 158 that mangles up your email output. Try and fix this
  undefined
   constant.
  
Hi all - I am attempting to solve some maddening behaviour that
 has
  me
totally stumped and before I take a blade to my throat I thought
 I
   would
pick the brains of the group/hive/gang.
   
I am working on a viral marketing application that uses
 multipart
   emails
to
notify entrants of their progress in the 'game'. I have a demo
  version
which
works fine, and the current rebranded version was also fine
 until
  the
client
asked for some changes then POW!
   
I will try and define the issue as simply as I can. I am passing
 11
arguments to a function called sendSantaMail (don't ask) and as
 a
   sanity
check I have called mail() to let me know the values just before
  they
   are
passed in to the function. I get this result:
   
Values to be passed to sendSantaMail:
   
Friend Name: Treyt
Friend Email: [EMAIL PROTECTED]
Sender Name: Bull Sykes
Sender Email: [EMAIL PROTECTED]
Prize ID: 1
Nominator ID: 2555004452133557e4d
Nominee ID: 851355445213355cc6f
Chain ID: CHAIN824452133561a8d
   
- this is all good and correct. I also call mail from the
 receiving
function
to check the actual values received by the function and I get
 this:
   
Values sent into sendSantaMail function:
   
Friend Name: [EMAIL PROTECTED]
Friend Email: Look what you may have won!
Sender Name: 8 Use of undefined constant prize - assumed 'prize'
Sender Email: 158
Sender Email: /home/friend/public_html/process1.php
[EMAIL PROTECTED]Prize: 1
Subject: 158
Nominator ID: 33238744520f5235b85
Nominee ID: 96658244520f524bb19
Chain ID: CHAIN84644520f525a56f
   
What is happening? I have checked the order of values being
 passed
  in
   and
the function prototype and they match in the correct order,
 there
  are
   no
default values. I have been trying to solve this for two days
 and
  am
particularly concerned that somewhere along the way the sender
  email
   value
becomes the script name.
   
Any ideas on this black Friday?
   
   
   
   
   
   
   
--
http://www.web-buddha.co.uk
   
dynamic web programming from Reigate, Surrey UK (php, mysql,
 xhtml,
   css)
   
look out for project karma, our new venture, coming soon!
   
  
  
  
  
  
   --
   http://www.web-buddha.co.uk
  
   dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml,
  css)
  
   look out for project karma, our new venture, coming soon!
  
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 
  --
  http://www.web-buddha.co.uk
 
  dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml,
 css)
 
  look out for project karma, our new venture, coming soon!
 

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




 --
 http://www.web-buddha.co.uk

 dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css)

 

Re: [PHP] Help!

2006-04-28 Thread Dave Goodchild

I would do but there are 5000+ lines and no indication of where the error is
occurring. I have just copied the demo version into the same dir and it
works fine - and that version calls the same classes (includes).

On 28/04/06, T.Lensselink [EMAIL PROTECTED] wrote:


Maybe show some code... Think some error inside a class / function causes
that no output is send...

 Thanks - now the parameters reach the function intact but the mailer
still
 does not work. Basically, the form is a self-reloader. If the form has
 been
 submitted and the data validated (including emails sent) it displays a
 thank
 you message. Otherwise it shows the starter form.

 All that happens when I submit is a white page - no errors
(display_errors
 is on and error reporting set to the default level) and no html. Nada.
 When
 I try and view source I am given the browser re-post warning.

 On 28/04/06, T.Lensselink [EMAIL PROTECTED] wrote:

 Hey Dave,

 Besides from example two being the correct way to call array elements.
I
 think it has something todo with error reporting. It's the only thing
 that
 comes to mind right now. Maybe you demo server doesn't echo notices...
 Maybe i'm wrong .. it's friday and my brain don't work that good :)

 p.s.
 plz reply to the list :)

  Hmmm...
 
  In the demo version the script accesses the $_GET array - an example
  value:
 
  $data[email]
 
  ..which works fine in the demo app. If I quote all the values thus in
 the
  new version:
 
  $data['email']
 
  ..the arguments appear in the correct order. I understand the second
  format
  is better to disambiguate constants but the former format works fine
 for
  the
  demo version. Any reason for the discrepancy?
 
  On 28/04/06, T.Lensselink [EMAIL PROTECTED] wrote:
 
  Well there is an undefined constant prize somewhere.. well it's just
 a
  notice but it really looks like the problem.. Try setting
  error_reporting(0) and see if it runs...
 
   process1.php only has 64 lines.
  
   On 28/04/06, T.Lensselink [EMAIL PROTECTED] wrote:
  
   A blade? come on :)
  
   Seems to me it's just an error in :
   /home/friend/public_html/process1.php
   line 158 that mangles up your email output. Try and fix this
  undefined
   constant.
  
Hi all - I am attempting to solve some maddening behaviour that
 has
  me
totally stumped and before I take a blade to my throat I
thought
 I
   would
pick the brains of the group/hive/gang.
   
I am working on a viral marketing application that uses
 multipart
   emails
to
notify entrants of their progress in the 'game'. I have a demo
  version
which
works fine, and the current rebranded version was also fine
 until
  the
client
asked for some changes then POW!
   
I will try and define the issue as simply as I can. I am
passing
 11
arguments to a function called sendSantaMail (don't ask) and as
 a
   sanity
check I have called mail() to let me know the values just
before
  they
   are
passed in to the function. I get this result:
   
Values to be passed to sendSantaMail:
   
Friend Name: Treyt
Friend Email: [EMAIL PROTECTED]
Sender Name: Bull Sykes
Sender Email: [EMAIL PROTECTED]
Prize ID: 1
Nominator ID: 2555004452133557e4d
Nominee ID: 851355445213355cc6f
Chain ID: CHAIN824452133561a8d
   
- this is all good and correct. I also call mail from the
 receiving
function
to check the actual values received by the function and I get
 this:
   
Values sent into sendSantaMail function:
   
Friend Name: [EMAIL PROTECTED]
Friend Email: Look what you may have won!
Sender Name: 8 Use of undefined constant prize - assumed
'prize'
Sender Email: 158
Sender Email: /home/friend/public_html/process1.php
[EMAIL PROTECTED]Prize: 1
Subject: 158
Nominator ID: 33238744520f5235b85
Nominee ID: 96658244520f524bb19
Chain ID: CHAIN84644520f525a56f
   
What is happening? I have checked the order of values being
 passed
  in
   and
the function prototype and they match in the correct order,
 there
  are
   no
default values. I have been trying to solve this for two days
 and
  am
particularly concerned that somewhere along the way the sender
  email
   value
becomes the script name.
   
Any ideas on this black Friday?
   
   
   
   
   
   
   
--
http://www.web-buddha.co.uk
   
dynamic web programming from Reigate, Surrey UK (php, mysql,
 xhtml,
   css)
   
look out for project karma, our new venture, coming soon!
   
  
  
  
  
  
   --
   http://www.web-buddha.co.uk
  
   dynamic web programming from Reigate, Surrey UK (php, mysql,
xhtml,
  css)
  
   look out for project karma, our new venture, coming soon!
  
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 
  --
  http://www.web-buddha.co.uk
 
  dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml,
 css)
 
  look out for 

Re: [PHP] Help!

2006-04-28 Thread Barry

Dave Goodchild schrieb:
I would do but there are 5000+ lines and no indication of where the 
error is

occurring. I have just copied the demo version into the same dir and it
works fine - and that version calls the same classes (includes).


The problem is without code we neither can give any hints.

Checking the vars going inside the function, and checking the imside 
thefunction again and then again before the mail is sent.


Checking checking debugging. That's in this cases the onyl thing you can 
do. And we cant give any more hints because we actually don't see 
anything ^^



--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help!

2006-04-28 Thread T.Lensselink
Without code it is hard to give an indication... Try and match php.ini's..
Anyway i go home now. Maybe in the evening have some time to think.. Or
maybe some other bright mind on the list has an idea..

goodluck,

Thijs

 I would do but there are 5000+ lines and no indication of where the error
 is
 occurring. I have just copied the demo version into the same dir and it
 works fine - and that version calls the same classes (includes).

 On 28/04/06, T.Lensselink [EMAIL PROTECTED] wrote:

 Maybe show some code... Think some error inside a class / function
 causes
 that no output is send...

  Thanks - now the parameters reach the function intact but the mailer
 still
  does not work. Basically, the form is a self-reloader. If the form has
  been
  submitted and the data validated (including emails sent) it displays a
  thank
  you message. Otherwise it shows the starter form.
 
  All that happens when I submit is a white page - no errors
 (display_errors
  is on and error reporting set to the default level) and no html. Nada.
  When
  I try and view source I am given the browser re-post warning.
 
  On 28/04/06, T.Lensselink [EMAIL PROTECTED] wrote:
 
  Hey Dave,
 
  Besides from example two being the correct way to call array
 elements.
 I
  think it has something todo with error reporting. It's the only thing
  that
  comes to mind right now. Maybe you demo server doesn't echo
 notices...
  Maybe i'm wrong .. it's friday and my brain don't work that good :)
 
  p.s.
  plz reply to the list :)
 
   Hmmm...
  
   In the demo version the script accesses the $_GET array - an
 example
   value:
  
   $data[email]
  
   ..which works fine in the demo app. If I quote all the values thus
 in
  the
   new version:
  
   $data['email']
  
   ..the arguments appear in the correct order. I understand the
 second
   format
   is better to disambiguate constants but the former format works
 fine
  for
   the
   demo version. Any reason for the discrepancy?
  
   On 28/04/06, T.Lensselink [EMAIL PROTECTED] wrote:
  
   Well there is an undefined constant prize somewhere.. well it's
 just
  a
   notice but it really looks like the problem.. Try setting
   error_reporting(0) and see if it runs...
  
process1.php only has 64 lines.
   
On 28/04/06, T.Lensselink [EMAIL PROTECTED] wrote:
   
A blade? come on :)
   
Seems to me it's just an error in :
/home/friend/public_html/process1.php
line 158 that mangles up your email output. Try and fix this
   undefined
constant.
   
 Hi all - I am attempting to solve some maddening behaviour
 that
  has
   me
 totally stumped and before I take a blade to my throat I
 thought
  I
would
 pick the brains of the group/hive/gang.

 I am working on a viral marketing application that uses
  multipart
emails
 to
 notify entrants of their progress in the 'game'. I have a
 demo
   version
 which
 works fine, and the current rebranded version was also fine
  until
   the
 client
 asked for some changes then POW!

 I will try and define the issue as simply as I can. I am
 passing
  11
 arguments to a function called sendSantaMail (don't ask) and
 as
  a
sanity
 check I have called mail() to let me know the values just
 before
   they
are
 passed in to the function. I get this result:

 Values to be passed to sendSantaMail:

 Friend Name: Treyt
 Friend Email: [EMAIL PROTECTED]
 Sender Name: Bull Sykes
 Sender Email: [EMAIL PROTECTED]
 Prize ID: 1
 Nominator ID: 2555004452133557e4d
 Nominee ID: 851355445213355cc6f
 Chain ID: CHAIN824452133561a8d

 - this is all good and correct. I also call mail from the
  receiving
 function
 to check the actual values received by the function and I get
  this:

 Values sent into sendSantaMail function:

 Friend Name: [EMAIL PROTECTED]
 Friend Email: Look what you may have won!
 Sender Name: 8 Use of undefined constant prize - assumed
 'prize'
 Sender Email: 158
 Sender Email: /home/friend/public_html/process1.php
 [EMAIL PROTECTED]Prize: 1
 Subject: 158
 Nominator ID: 33238744520f5235b85
 Nominee ID: 96658244520f524bb19
 Chain ID: CHAIN84644520f525a56f

 What is happening? I have checked the order of values being
  passed
   in
and
 the function prototype and they match in the correct order,
  there
   are
no
 default values. I have been trying to solve this for two days
  and
   am
 particularly concerned that somewhere along the way the
 sender
   email
value
 becomes the script name.

 Any ideas on this black Friday?







 --
 http://www.web-buddha.co.uk

 dynamic web programming from Reigate, Surrey UK (php, mysql,
  xhtml,
css)

 look out for project karma, our new venture, coming soon!

   
   
   
   
   
--

Re: [PHP] Help!

2006-04-28 Thread Dave Goodchild

Thanks all. Worst case scenario I can rebuild from the demo as it works
(really don't want to do that). Was loathe to plaster your screens with
miles of code but understand it's hard to assit without it. Just wanted to
know I wasn't alone! Have a great weekend!

On 28/04/06, Barry [EMAIL PROTECTED] wrote:


Dave Goodchild schrieb:
 I would do but there are 5000+ lines and no indication of where the
 error is
 occurring. I have just copied the demo version into the same dir and it
 works fine - and that version calls the same classes (includes).

The problem is without code we neither can give any hints.

Checking the vars going inside the function, and checking the imside
thefunction again and then again before the mail is sent.

Checking checking debugging. That's in this cases the onyl thing you can
do. And we cant give any more hints because we actually don't see
anything ^^


--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





--
http://www.web-buddha.co.uk

dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css)

look out for project karma, our new venture, coming soon!


Re: [PHP] Help!

2006-04-28 Thread Wolf
Dump some code to the list, just the inside function in and of itself
SHOULD give enough to find the bug.  It is PROBABLY how you are snagging
your data inside from out, or you left out a  somewhere and it is
catching it.  Believe me, I have had a heck of a time due to a single 
missing somewhere that just throws everything off.

Wolf

Dave Goodchild wrote:
 Hi all - I am attempting to solve some maddening behaviour that has me
 totally stumped and before I take a blade to my throat I thought I would
 pick the brains of the group/hive/gang.
-- SNIP --

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help!

2006-04-28 Thread Martin Alterisio

2006/4/28, Dave Goodchild [EMAIL PROTECTED]:


Hi all - I am attempting to solve some maddening behaviour that has me
totally stumped and before I take a blade to my throat I thought I would
pick the brains of the group/hive/gang.

I am working on a viral marketing application that uses multipart emails
to
notify entrants of their progress in the 'game'. I have a demo version
which
works fine, and the current rebranded version was also fine until the
client
asked for some changes then POW!

I will try and define the issue as simply as I can. I am passing 11
arguments to a function called sendSantaMail (don't ask) and as a sanity
check I have called mail() to let me know the values just before they are
passed in to the function. I get this result:



sendSantaMail That's just not a *declarative* way of naming a function.
Then, 11 arguments Errr, passing an associative array with the email
parameters wouldn't have been a cleaner and better option?

Values to be passed to sendSantaMail:


Friend Name: Treyt
Friend Email: [EMAIL PROTECTED]
Sender Name: Bull Sykes
Sender Email: [EMAIL PROTECTED]
Prize ID: 1
Nominator ID: 2555004452133557e4d
Nominee ID: 851355445213355cc6f
Chain ID: CHAIN824452133561a8d

- this is all good and correct. I also call mail from the receiving
function
to check the actual values received by the function and I get this:

Values sent into sendSantaMail function:

Friend Name: [EMAIL PROTECTED]
Friend Email: Look what you may have won!
Sender Name: 8 Use of undefined constant prize - assumed 'prize'
Sender Email: 158
Sender Email: /home/friend/public_html/process1.php
Prize: 1
Subject: 158
Nominator ID: 33238744520f5235b85
Nominee ID: 96658244520f524bb19
Chain ID: CHAIN84644520f525a56f

What is happening? I have checked the order of values being passed in and
the function prototype and they match in the correct order, there are no
default values. I have been trying to solve this for two days and am
particularly concerned that somewhere along the way the sender email value

becomes the script name.



One idea, you messed up somewhere. Use debug_print_backtrace() on the
function to get a dump of function call stack. Use it with an if to catch
the moment where the wrong values appear. The first entry of the backtrace
should point the file and line where the function was called.

If you're using php4 you'll have to use var_dump(debug_backtrace()) instead
of debug_print_backtrace().

Also check the error Use of undefined constant prize - assumed 'prize'.
Please tell me your are not doing something like this:
$arr[prize]

Any ideas on this black Friday?


--
http://www.web-buddha.co.uk

dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css)

look out for project karma, our new venture, coming soon!




Re: [PHP] Help!

2006-04-28 Thread Barry

Martin Alterisio schrieb:

2006/4/28, Dave Goodchild [EMAIL PROTECTED]:


Hi all - I am attempting to solve some maddening behaviour that has me
totally stumped and before I take a blade to my throat I thought I would
pick the brains of the group/hive/gang.

I am working on a viral marketing application that uses multipart emails
to
notify entrants of their progress in the 'game'. I have a demo version
which
works fine, and the current rebranded version was also fine until the
client
asked for some changes then POW!

I will try and define the issue as simply as I can. I am passing 11
arguments to a function called sendSantaMail (don't ask) and as a sanity
check I have called mail() to let me know the values just before they are
passed in to the function. I get this result:



sendSantaMail That's just not a *declarative* way of naming a function.
Do you know what santa means? No? so how can you tell it's not 
declarative.
Santa could be a coded Mailer and that functions uses that specific 
Mailer Deamon called santa to send mails.

Then, 11 arguments Errr, passing an associative array with the email
parameters wouldn't have been a cleaner and better option?


He just told he passes 11 arguments, never told how he does that.


--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help!

2006-04-28 Thread Martin Alterisio

2006/4/28, Barry [EMAIL PROTECTED]:


Martin Alterisio schrieb:
 2006/4/28, Dave Goodchild [EMAIL PROTECTED]:

 Hi all - I am attempting to solve some maddening behaviour that has me
 totally stumped and before I take a blade to my throat I thought I
would
 pick the brains of the group/hive/gang.

 I am working on a viral marketing application that uses multipart
emails
 to
 notify entrants of their progress in the 'game'. I have a demo version
 which
 works fine, and the current rebranded version was also fine until the
 client
 asked for some changes then POW!

 I will try and define the issue as simply as I can. I am passing 11
 arguments to a function called sendSantaMail (don't ask) and as a
sanity
 check I have called mail() to let me know the values just before they
are
 passed in to the function. I get this result:


 sendSantaMail That's just not a *declarative* way of naming a
function.
Do you know what santa means? No? so how can you tell it's not
declarative.
Santa could be a coded Mailer and that functions uses that specific
Mailer Deamon called santa to send mails.



Yeah you're right, I was thinking the exact same thing a while after I
posted that. Maybe it was a correct name in the context used, but, I still
think Santa is a really misleading name for a mailer, and not to mention
that a mass mailer identifying itself as Santa mailer in the headers is
asking to be send directly to spam. Anyway, I was wrong.


Then, 11 arguments Errr, passing an associative array with the email
 parameters wouldn't have been a cleaner and better option?

He just told he passes 11 arguments, never told how he does that.



Well, if somebody tells you a function has 11 arguments what would you
think?


Re: [PHP] Help using a function within a function, both within a class

2006-04-19 Thread chris smith
On 4/19/06, Adele Botes [EMAIL PROTECTED] wrote:
 To anyone who can help, I would like to know why or how I can execute a
 function within a function used within this class. I want to redirect if
 the results of a insert query was successful, so i made a simple redirect
 function for later use, once I've build onto the class. The problem is that
 i am not sure why or how to get the redirect($url) to work within
 insert_data($table,$values,$where)

 Even if I call the function: print redirect($url); and add the $url
 argument
 to insert_data it still doesn't work. I get undefined function error. What
 am I doing wrong?

 ?php
 require_once('../config.inc.php'); // contains define(WEB_ROOT,
 'http://www.example.com'); and $db_connection

 class DATA {
 // variables
 var $table;
 var $fields;
 var $where;
 var $url;

 // Constructor must be the same name as the class

 // Functions
 function insert_data($table,$values,$where) {
 global $redirect;

You don't use globals inside a class to reference other data inside
the same class.

Instead you need to do something like this:

$add_location-url = 'blah';

then inside the class:

if ($result) {
   # redirect here
   print $this-redirect($this-url);
...

--
Postgresql  php tutorials
http://www.designmagick.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help using a function within a function, both within a class

2006-04-19 Thread Adele Botes

chris smith wrote:


On 4/19/06, Adele Botes [EMAIL PROTECTED] wrote:
 


To anyone who can help, I would like to know why or how I can execute a
function within a function used within this class. I want to redirect if
the results of a insert query was successful, so i made a simple redirect
function for later use, once I've build onto the class. The problem is that
i am not sure why or how to get the redirect($url) to work within
insert_data($table,$values,$where)

Even if I call the function: print redirect($url); and add the $url
argument
to insert_data it still doesn't work. I get undefined function error. What
am I doing wrong?

?php
require_once('../config.inc.php'); // contains define(WEB_ROOT,
'http://www.example.com'); and $db_connection

class DATA {
   // variables
   var $table;
   var $fields;
   var $where;
   var $url;

   // Constructor must be the same name as the class

   // Functions
   function insert_data($table,$values,$where) {
   global $redirect;
   



You don't use globals inside a class to reference other data inside
the same class.

Instead you need to do something like this:

$add_location-url = 'blah';

then inside the class:

if ($result) {
  # redirect here
  print $this-redirect($this-url);
...

--
Postgresql  php tutorials
http://www.designmagick.com/


 


Chris

Thanx allot for your help. I works gr8.

Adele
--

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] help with multidimentional arrays

2006-04-12 Thread John Wells
On 4/11/06, Bing Du [EMAIL PROTECTED] wrote:
 ==
 foreach ($sponsor_id as $sponsor = $arr)
 echo $sponsor:;
 foreach ($arr[$sponsor] as $project) {
 echo $projectbr;
 }
 ==


It looks like you're building your array just fine.  Here though, your
second foreach needs to look like this:

[code]
foreach ($arr as $project)
{
 echo $projectbr;
}
[/code]

Your temprorary $arr variable contains only your array of titles, not
an entire row of your 2-dimensional $sonsor_id array.  So you do not
need to use the $sponsor key to get at that array.

HTH,

John W

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] help with multidimentional arrays

2006-04-12 Thread Bing Du
 On 4/11/06, Bing Du [EMAIL PROTECTED] wrote:
 = foreach ($sponsor_id as $sponsor = $arr)
 echo $sponsor:;
 foreach ($arr[$sponsor] as $project) {
 echo $projectbr;
 }
 =

 It looks like you're building your array just fine.  Here though, your
 second foreach needs to look like this:

 [code]
 foreach ($arr as $project)
 {
  echo $projectbr;
 }
 [/code]

 Your temprorary $arr variable contains only your array of titles, not
 an entire row of your 2-dimensional $sonsor_id array.  So you do not
 need to use the $sponsor key to get at that array.


Thanks so much for pointing out that error on $arr, John.  You are very
right.  Now I realize it's such an obvious error.  But I did not notice it
before I posted.

Bing

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] help with multidimentional arrays

2006-04-11 Thread Richard Lynch
On Tue, April 11, 2006 1:58 pm, Bing Du wrote:
 What I intend to do is put the database query results in a
 multidimentional array like this.

 $sponsor_id['sponsor1'] = ('project1 title', 'project2 title',
 'project3
 title');
 $sponsor_id['sponsor2'] = ('project1 title','project7 title');
 

 Here is the code snippet for doing that:

 ==
 while( ($rec = odbtp_fetch_array($qry)) ) {

echo rec[1] is: $reg[1]br /\n;

if (empty($sponsor_id[$rec[1]])) {
   $sponsor_id[$rec[1]] = array();
} else {
echo adding $rec[0] to $rec[1] arraybr /\n;
array_push($sponsor_id[$rec[1]], $rec[0]);
   }
  }
 ==

 Now, when the following code is used to print the array $sponsor_id,
 it
 only prints out the keys of the array which are:

 sponsor1
 sponsor2

 Those project titles are not printed out.

 ==
 foreach ($sponsor_id as $sponsor = $arr)
 echo $sponsor:;
 foreach ($arr[$sponsor] as $project) {
 echo $projectbr;
 }
 ==

 My expected output should be like:

 sponsor1:
   project1 title
   project2 title
   project3 title

 sponsor2
   project1 title
   project7 title

 What is wrong?  I'd appreciate any help.

 Thanks,

 Bing

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help with a complex scenario

2006-04-07 Thread tedd

At 4:59 PM -0400 4/7/06, Robert Fitzpatrick wrote:

I have an order table that we are trying to figure out a way to find the
best (cheapest) scenario to sending to vendors to fill the orders. Let's
say we have 10 parts ordered, if we split that amongst vendors, even
paying a higher shipping cost in some cases can be cheaper. We can send
2 of those parts from this vendor and 3 from another and so on. We have
an ID, price, ship price and vendor to consider that is retrieved via
the api with each vendor. Does anyone have experience in trying to find
all the scenario possibilities?

--
Robert


Yeah, every time I buy something on eBay -- it's a pretty simple 
problem, don't you think?


tedd
--

http://sperling.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] help with some logic.

2006-04-06 Thread Dallas Cahker
Thanks makes it alot easier to follow.

On 4/4/06, Dallas Cahker [EMAIL PROTECTED] wrote:

 Okay I'll look at that.

 What about switching to setting the password in md5 format in the cookie
 rather then a regular id.  I might not call the cookie password but to me in
 thinking about it seems like the same thing as setting a random id and then
 saving the random id in the db.


 On 4/4/06, Dan McCullough [EMAIL PROTECTED] wrote:
 
  hey Dallas,
 
  have you thought about breaking this up and making two seperate
  functions one the checks the cookie and one that checks the session
  information?  I'm not sure if that is what you were looking for as far
  as an answer but it might be a good start.
 
  On 4/4/06, Dallas Cahker [EMAIL PROTECTED] wrote:
   I've been looking at this code for a few hours now and I get the
  nagging
   feeling that I am overcomplicating something, something I never ever
  do.  I
   have a login that puts some information on the session, and if the
  customer
   wants they can ask to be remembered, the cookie is given the customers
  user
   name and another cookie stores a unique id, similar to a password I
  could do
   the password in a cookie as its md5 encrypted, but I went with an a
  unique
   id which is store in the user db.
  
   Anyway here is what I am trying to do with the code below.  The
  authorized
   user section requires 4 pieces of information, userid, password,
  username
   and user level, a person who logs in each time gets that information
   assigned to their session, that part works *knock on wood*
  perfectly.  When
   a customer says remember me they go away and come back a while later
  they
   are remembered, so that part works perfectly, however I need to get
  the
   persons information and put that on the session, however I would like
  the
   function to behave in such a way as to not overwrite the information
  each
   time the page load.  So for example the cookie is read the information
  is
   valid, the query to the db, the information set to the session.  You
  might
   wonder why I dont set the userlevel to the cookie, well I dont want
  someone
   changing the value of a cookie and getting admin access, which reminds
  me I
   should add that as a check.
   Thats about it.  getCookieInfo() the function inside the checkLogin
  function
   just looks up the information for the cookie in the db.  I know that
  someone
   is going to say something really simple that I am going to slap my
  forehead
   over, I would like to thank that person before hand.
  
   function checkLogin () {
/* Check if user has been remembered */
if (isset($_COOKIE['cookname'])  isset($_COOKIE['cookid'])) {
if (!isset($_SESSION['name'])  !isset($_SESSION['id']) 
   !isset($_SESSION['level'])  !isset($_SESSION['password'])) {
 $cookieInfo=getCookieInfo($_COOKIE['cookname'], $_COOKIE['cookid']);
 
 if ($cookieInfo==0) {
  return 0;
 }
 if ($cookieInfo==1) {
  setcookie(cookname, , time()-60*60*24*100, /);
 setcookie(cookid, , time()-60*60*24*100, /);
  return 1;
 }
 if ($cookieInfo==2) {
  setcookie(cookname, , time()-60*60*24*100, /);
 setcookie(cookid, , time()-60*60*24*100, /);
  return 2;
 }
}
}
  
if (isset($_SESSION['name'])  isset($_SESSION['id']) 
   isset($_SESSION['level'])  isset($_SESSION['password'])) {
if (loginUser($_SESSION['username'], $_SESSION['password'],'') != 1)
  {
 unset($_SESSION['name']);
 unset($_SESSION['id']);
 unset($_SESSION['level']);
 unset($_SESSION['password']);
 $_SESSION = array(); // reset session array
session_destroy();   // destroy session.
 // incorrect information, user not logged in
 return 0;
}
// information valid, user okay
return 1;
} else {
// user not logged in
return 2;
}
   }
  
  
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 



Re: [PHP] help with some logic.

2006-04-04 Thread Dan McCullough
hey Dallas,

have you thought about breaking this up and making two seperate
functions one the checks the cookie and one that checks the session
information?  I'm not sure if that is what you were looking for as far
as an answer but it might be a good start.

On 4/4/06, Dallas Cahker [EMAIL PROTECTED] wrote:
 I've been looking at this code for a few hours now and I get the nagging
 feeling that I am overcomplicating something, something I never ever do.  I
 have a login that puts some information on the session, and if the customer
 wants they can ask to be remembered, the cookie is given the customers user
 name and another cookie stores a unique id, similar to a password I could do
 the password in a cookie as its md5 encrypted, but I went with an a unique
 id which is store in the user db.

 Anyway here is what I am trying to do with the code below.  The authorized
 user section requires 4 pieces of information, userid, password, username
 and user level, a person who logs in each time gets that information
 assigned to their session, that part works *knock on wood* perfectly.  When
 a customer says remember me they go away and come back a while later they
 are remembered, so that part works perfectly, however I need to get the
 persons information and put that on the session, however I would like the
 function to behave in such a way as to not overwrite the information each
 time the page load.  So for example the cookie is read the information is
 valid, the query to the db, the information set to the session.  You might
 wonder why I dont set the userlevel to the cookie, well I dont want someone
 changing the value of a cookie and getting admin access, which reminds me I
 should add that as a check.
 Thats about it.  getCookieInfo() the function inside the checkLogin function
 just looks up the information for the cookie in the db.  I know that someone
 is going to say something really simple that I am going to slap my forehead
 over, I would like to thank that person before hand.

 function checkLogin () {
  /* Check if user has been remembered */
  if (isset($_COOKIE['cookname'])  isset($_COOKIE['cookid'])) {
  if (!isset($_SESSION['name'])  !isset($_SESSION['id']) 
 !isset($_SESSION['level'])  !isset($_SESSION['password'])) {
   $cookieInfo=getCookieInfo($_COOKIE['cookname'], $_COOKIE['cookid']);
   if ($cookieInfo==0) {
return 0;
   }
   if ($cookieInfo==1) {
setcookie(cookname, , time()-60*60*24*100, /);
   setcookie(cookid, , time()-60*60*24*100, /);
return 1;
   }
   if ($cookieInfo==2) {
setcookie(cookname, , time()-60*60*24*100, /);
   setcookie(cookid, , time()-60*60*24*100, /);
return 2;
   }
  }
  }

  if (isset($_SESSION['name'])  isset($_SESSION['id']) 
 isset($_SESSION['level'])  isset($_SESSION['password'])) {
  if (loginUser($_SESSION['username'], $_SESSION['password'],'') != 1) {
   unset($_SESSION['name']);
   unset($_SESSION['id']);
   unset($_SESSION['level']);
   unset($_SESSION['password']);
   $_SESSION = array(); // reset session array
  session_destroy();   // destroy session.
   // incorrect information, user not logged in
   return 0;
  }
  // information valid, user okay
  return 1;
  } else {
  // user not logged in
  return 2;
  }
 }



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] help with some logic.

2006-04-04 Thread Dallas Cahker
Okay I'll look at that.

What about switching to setting the password in md5 format in the cookie
rather then a regular id.  I might not call the cookie password but to me in
thinking about it seems like the same thing as setting a random id and then
saving the random id in the db.

On 4/4/06, Dan McCullough [EMAIL PROTECTED] wrote:

 hey Dallas,

 have you thought about breaking this up and making two seperate
 functions one the checks the cookie and one that checks the session
 information?  I'm not sure if that is what you were looking for as far
 as an answer but it might be a good start.

 On 4/4/06, Dallas Cahker [EMAIL PROTECTED] wrote:
  I've been looking at this code for a few hours now and I get the nagging
  feeling that I am overcomplicating something, something I never ever
 do.  I
  have a login that puts some information on the session, and if the
 customer
  wants they can ask to be remembered, the cookie is given the customers
 user
  name and another cookie stores a unique id, similar to a password I
 could do
  the password in a cookie as its md5 encrypted, but I went with an a
 unique
  id which is store in the user db.
 
  Anyway here is what I am trying to do with the code below.  The
 authorized
  user section requires 4 pieces of information, userid, password,
 username
  and user level, a person who logs in each time gets that information
  assigned to their session, that part works *knock on wood*
 perfectly.  When
  a customer says remember me they go away and come back a while later
 they
  are remembered, so that part works perfectly, however I need to get the
  persons information and put that on the session, however I would like
 the
  function to behave in such a way as to not overwrite the information
 each
  time the page load.  So for example the cookie is read the information
 is
  valid, the query to the db, the information set to the session.  You
 might
  wonder why I dont set the userlevel to the cookie, well I dont want
 someone
  changing the value of a cookie and getting admin access, which reminds
 me I
  should add that as a check.
  Thats about it.  getCookieInfo() the function inside the checkLogin
 function
  just looks up the information for the cookie in the db.  I know that
 someone
  is going to say something really simple that I am going to slap my
 forehead
  over, I would like to thank that person before hand.
 
  function checkLogin () {
   /* Check if user has been remembered */
   if (isset($_COOKIE['cookname'])  isset($_COOKIE['cookid'])) {
   if (!isset($_SESSION['name'])  !isset($_SESSION['id']) 
  !isset($_SESSION['level'])  !isset($_SESSION['password'])) {
$cookieInfo=getCookieInfo($_COOKIE['cookname'], $_COOKIE['cookid']);
if ($cookieInfo==0) {
 return 0;
}
if ($cookieInfo==1) {
 setcookie(cookname, , time()-60*60*24*100, /);
setcookie(cookid, , time()-60*60*24*100, /);
 return 1;
}
if ($cookieInfo==2) {
 setcookie(cookname, , time()-60*60*24*100, /);
setcookie(cookid, , time()-60*60*24*100, /);
 return 2;
}
   }
   }
 
   if (isset($_SESSION['name'])  isset($_SESSION['id']) 
  isset($_SESSION['level'])  isset($_SESSION['password'])) {
   if (loginUser($_SESSION['username'], $_SESSION['password'],'') != 1) {
unset($_SESSION['name']);
unset($_SESSION['id']);
unset($_SESSION['level']);
unset($_SESSION['password']);
$_SESSION = array(); // reset session array
   session_destroy();   // destroy session.
// incorrect information, user not logged in
return 0;
   }
   // information valid, user okay
   return 1;
   } else {
   // user not logged in
   return 2;
   }
  }
 
 

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Help?

2006-03-24 Thread Clinton, Rochelle A
Richard,

You were exactly right - my data was already in the format: lt;/agt;
I have resolved my issue now.

Thank you to all who responded to my question.  I was pleasantly
surprised by the willingness of so many to help a stranger!

Best Regards,
Rochelle

-Original Message-
From: Richard Lynch [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 23, 2006 3:39 PM
To: Clinton, Rochelle A
Cc: php-general@lists.php.net
Subject: RE: [PHP] Help?





On Thu, March 23, 2006 2:19 pm, Clinton, Rochelle A wrote:
 Hi Richard,

 WOW!  Thanks for such a quick response  -  this is just driving me
 crazy!  Not to mention consuming my time.

 I actually had been using the $line = in front of my replace attempts.

 Here is the exact offending code:

 for ($i=0; $i$line_length; $i++) {
$line[$i] = htmlspecialchars($line[$i]);
echo debug: line$i is:  . $line[$i] . BR;
 }
 $line[$line_length-1] = str_replace(/a, ,
 $line[$line_length-1]);
 echo DEBUG: replaced def line is:  .
 $line[$line_length-1] . BR;

 And the uncooperative output:

 debug: line0 is: a name = 73966552/aa

href=http://www.ncbi.nlm.nih.gov:80/entrez/query.fcgi?cmd=Retrievedb=P
roteinlist_uids=73966552dopt=GenPept
 gi
 debug: line1 is: 73966552
 debug: line2 is: ref
 debug: line3 is: XP_866810.1
 debug: line4 is: /a PREDICTED: similar to splicing factor,
 arginine/serine-rich 1
 DEBUG: replaced def line is: /a PREDICTED: similar to splicing
 factor, arginine/serine-rich 1

Use View Source in your browser to see what REALLY is being printed
out...

The browser is interpreting your output, at all stages, and what you
see in the browser is not what you've got.

Word may not be exactly WYSIWYG, but it tries...

A browser is *NOT* WYSIWYG to the Nth degree! :-)

For example, your ACTUAL data might ALREADY be:
lt;/agt; PREDICTED:...

Or, it might be:
lt;/#97;gt; PREDICTED:...

Or, it might be...

There are at least 3x3x3x3 possible combinations on this theme.  Throw
in UTF-8 characters being presented in Latin-1, and you've got that
times a thousand.

I SUSPECT that somebody has already done htmlentities() on your data,
and so you're *seeing* /a in the browser, but your DATA is:
lt;/agt;

So you need to do the str_replace() on THAT, not on what you see.

Or figure out where you already did htmlentities, and don't do that.

Only use htmlentities() at the last possible moment, at browser output.

Never [*] use htmlentities() on data for storage, nor processing.

Only at the last micro-second before spewing out to a browser should
your raw data be converted to a form suitable for browser display.

You'll just confuse yourself otherwise, with data converted too soon,
and not being what you expect when you look at it.

* There are bound to be exceptions to this, for some special 'expert'
situations...

-- 
Like Music?
http://l-i-e.com/artists.htm

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help?

2006-03-23 Thread John Nichel

Clinton, Rochelle A wrote:

Hello,

 


I am fairly new to PHP and am having an (SILLY) issue that I cannot seem
to resolve:

 


I am pulling data from an html file and some of the lines of text that I
need start with /a.

I cannot seem to get rid of that tag!!!

 


I have tried:

*   str_replace(\a, , $line)
*   preg_replace('/\/a/', '', $line)  and various other attempts
at creating the appropriate regex for \a
*   $line = htmlspecialchars($line)

str_replace(lt;/agt;, , $line)

*   And obviously strip_tags is not working for me either!

 


Do you have any suggestions?


Echo out the line before and after you perform something like 
strip_tags() on it to see if you're inputting what you're expecting...


echo ( $line );
$line = strip_tags ( $line );
echo ( $line );

--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help?

2006-03-23 Thread Richard Lynch
On Thu, March 23, 2006 1:50 pm, Clinton, Rochelle A wrote:
 I am fairly new to PHP and am having an (SILLY) issue that I cannot
 seem
 to resolve:

 I am pulling data from an html file and some of the lines of text that
 I
 need start with /a.

Show us an actual line, copy/paste, to be sure we are working on the
right thing...

 I cannot seem to get rid of that tag!!!

 I have tried:

 * str_replace(\a, , $line)

You need to do:
$line = str_replace(/a, , $line);

Otherwise, you calculate the answer you want, and throw it away.

 * preg_replace('/\/a/', '', $line)  and various other attempts

Technically, you'd want:
'/\\/a/'

As \ is a special character inside '' marks, and PHP needs \\ to
represent \

It works because only \\ and \' are special inside '', so PHP
figures out \a as just \a

But it helps one understand strings better to be pedantic and use \\
inside '' to mean \

Again, it would seem you've left out the crucial step of storing the
result you want:

$line = preg_replace(..., $line);

 at creating the appropriate regex for \a

Is it really /a or \a?

Because / and \ are not the same, despite the number of people, even
professional radio announcers, who insist on calling / 'backslash'

/ slash
\ backslash

You'd think they'd do their homework, eh?  Oh well.

I think the browsers have mainly gotten to the point where they just
try switching things around from \ to / if you goof anyway...

Must be frustrating to write a web browser...  Almost as frustrating
as trying to code HTML to one. :-)

 * $line = htmlspecialchars($line)

 str_replace(lt;/agt;, , $line)

This would, in theory, work IF you had '$line =' in front of the
str_replace (again), but adds a pointless extra step to convert to
HTML Entities before ripping out characters you don't want in the
first place.

 * And obviously strip_tags is not working for me either!

$line = strip_tags($line);

It seems like your primary difficulty in all this is in understanding
that MOST (if not all) PHP functions on strings will return the new
value, rather than destructively modify the input string.

It is possible, in some versions of PHP, to specifically craft
functions that will ALTER the input string.  But that's generally done
for performance reasons, and only in very specialized situations in
highly-optimized application code.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Help?

2006-03-23 Thread Richard Lynch




On Thu, March 23, 2006 2:19 pm, Clinton, Rochelle A wrote:
 Hi Richard,

 WOW!  Thanks for such a quick response  -  this is just driving me
 crazy!  Not to mention consuming my time.

 I actually had been using the $line = in front of my replace attempts.

 Here is the exact offending code:

 for ($i=0; $i$line_length; $i++) {
$line[$i] = htmlspecialchars($line[$i]);
echo debug: line$i is:  . $line[$i] . BR;
 }
 $line[$line_length-1] = str_replace(/a, ,
 $line[$line_length-1]);
 echo DEBUG: replaced def line is:  .
 $line[$line_length-1] . BR;

 And the uncooperative output:

 debug: line0 is: a name = 73966552/aa
 href=http://www.ncbi.nlm.nih.gov:80/entrez/query.fcgi?cmd=Retrievedb=Proteinlist_uids=73966552dopt=GenPept;
 gi
 debug: line1 is: 73966552
 debug: line2 is: ref
 debug: line3 is: XP_866810.1
 debug: line4 is: /a PREDICTED: similar to splicing factor,
 arginine/serine-rich 1
 DEBUG: replaced def line is: /a PREDICTED: similar to splicing
 factor, arginine/serine-rich 1

Use View Source in your browser to see what REALLY is being printed
out...

The browser is interpreting your output, at all stages, and what you
see in the browser is not what you've got.

Word may not be exactly WYSIWYG, but it tries...

A browser is *NOT* WYSIWYG to the Nth degree! :-)

For example, your ACTUAL data might ALREADY be:
lt;/agt; PREDICTED:...

Or, it might be:
lt;/#97;gt; PREDICTED:...

Or, it might be...

There are at least 3x3x3x3 possible combinations on this theme.  Throw
in UTF-8 characters being presented in Latin-1, and you've got that
times a thousand.

I SUSPECT that somebody has already done htmlentities() on your data,
and so you're *seeing* /a in the browser, but your DATA is:
lt;/agt;

So you need to do the str_replace() on THAT, not on what you see.

Or figure out where you already did htmlentities, and don't do that.

Only use htmlentities() at the last possible moment, at browser output.

Never [*] use htmlentities() on data for storage, nor processing.

Only at the last micro-second before spewing out to a browser should
your raw data be converted to a form suitable for browser display.

You'll just confuse yourself otherwise, with data converted too soon,
and not being what you expect when you look at it.

* There are bound to be exceptions to this, for some special 'expert'
situations...

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] help with smarty+cms

2006-03-23 Thread Richard Lynch
On Thu, March 23, 2006 11:28 am, ganu wrote:
 Hello all,

 I worked with one site and now is working fine with smarty.
 Now I want to implement the CMS in that,
 I went thru the link http://smarty.php.net/resources.php?category=2

 now I want a CMS so my existing site looks as it is and with some or
 lot of
 changes
 I can implement CMS in that.

 somy body has faced the same situation then plz giude me..
 [ after everything I want to implement the CMS :( ]

 any CMS so I can start work on that...

You can try out a BUNCH of different CMS systems here:
http://www.opensourcecms.com/

YMMV


-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] help with setting menu styles with PHP

2006-03-16 Thread tedd

http://www.inspired-evolution.com/About_Me.php

What I want to do next is to change the menu from being hard coded on all of
my pages to being an include making the menu more manageable. The stumbling
block is I want to be able to keep the CSS functionality where you have the
active indicator which has different CSS for the link of the page you are
on. I have seen this done with PHP before with something like IF on active
page use this style  ELSE use this style. Can any PHP gurus assist me in
coding something like this?

I don't believe it is too difficult, but beyond by scope right at the
moment.


It's not a php solution, but you can change it to one easy enough. 
This will give you the idea.


http://www.sperling.com/examples/menu_aware/

tedd
--

http://sperling.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



<    1   2   3   4   5   6   7   8   9   10   >