php-general Digest 29 Jul 2008 11:33:59 -0000 Issue 5595

2008-07-29 Thread php-general-digest-help

php-general Digest 29 Jul 2008 11:33:59 - Issue 5595

Topics (messages 277405 through 277420):

Re: Web2.0 style tags - where to start?
277405 by: Paul Jinks
277416 by: Børge Holen
277417 by: Jason Norwood-Young
277418 by: Paul Jinks

Scoping?
277406 by: joshua harr
277407 by: joshua harr

PHP4 vs PHP5 classes
277408 by: jeff.mills.winsto.net
277409 by: Chris
277411 by: jeff.mills.winsto.net
277412 by: Chris
277413 by: jeff.mills.winsto.net
277414 by: jeff.mills.winsto.net
277415 by: Chris

Re: Problem with using array_diff  and array_combine
277410 by: Chris

Re: Double results??
277419 by: Paul Gregg

Thumbnail through PHP RSS parser
277420 by: Lyubomir Tsvetanov

Administrivia:

To subscribe to the digest, e-mail:
[EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]

To post to the list, e-mail:
[EMAIL PROTECTED]


--
---BeginMessage---

Jason Norwood-Young wrote:

On Mon, 2008-07-28 at 14:48 +0100, Paul Jinks wrote:
  

I think my first post was ambiguous. What we're thinking of is to build a
site on which people can view videos with the option to add metadata to a
video after viewing it.

We think that the content we have will be of wide interest to a lot of
people and the best way to index it is for users to 'tag' it themselves,
since it's hard for us to anticipate the uses that people may have for the
content.



How do you plan to have users enter the info? Through the Flash player,
through some kinda Ajax form, through a form in a frame or just a static
form? 


Also, would the tags be predefined by you (eg. genres like the ID3 tag
genres) or would people be able to add their own tags?

The way I'd do it would be to let the users enter the info through an
Ajax form below the video, with suggestions popping up as they type.
Then save it in a separate table (I assume all your vids are in their
own table) with a link table between the vids table and the tags table
(M2M relationship). This means that if the tag is already in there and
linked to one vid, you don't replicate it for a second vid. It's also
very easy to do lookups of similar items. I'd also add a weighting to
the tags in the links table, maybe with the more people that add a
specific tag, the more weight that tag gets. 


Also check out http://www.music-map.com/ as an example of showing
similar music - you might even be able to plug into this data.

  

Hi Jason

Hmm, food for thought. music-map is brilliant, though not what I'm 
looking for graphically at the moment (was surprised to find Cesaria 
Evora in close proximity to The Cardigans but I digress).


What you describe is pretty much what I'm chasing, thanks and helps me 
down the road, particularly with thinking about the database set up. 
They 'only' problem is, my php/mysql skills are some way behind my 
javascript/actionscript  knowhow (I'm pretty much a noob here);  what I 
could use now is a how-to tutorial to give me some code to work off, 
either online or in a book. If it ain't there, I can build from scratch 
but it's going to mean a lot of calls for help! =)


Many thanks

Paul


---End Message---
---BeginMessage---
On Tuesday 29 July 2008 00:57:22 Paul Jinks wrote:
 Jason Norwood-Young wrote:
  On Mon, 2008-07-28 at 14:48 +0100, Paul Jinks wrote:
  I think my first post was ambiguous. What we're thinking of is to build
  a site on which people can view videos with the option to add metadata
  to a video after viewing it.
 
  We think that the content we have will be of wide interest to a lot of
  people and the best way to index it is for users to 'tag' it themselves,
  since it's hard for us to anticipate the uses that people may have for
  the content.
 
  How do you plan to have users enter the info? Through the Flash player,
  through some kinda Ajax form, through a form in a frame or just a static
  form?
 
  Also, would the tags be predefined by you (eg. genres like the ID3 tag
  genres) or would people be able to add their own tags?
 
  The way I'd do it would be to let the users enter the info through an
  Ajax form below the video, with suggestions popping up as they type.
  Then save it in a separate table (I assume all your vids are in their
  own table) with a link table between the vids table and the tags table
  (M2M relationship). This means that if the tag is already in there and
  linked to one vid, you don't replicate it for a second vid. It's also
  very easy to do lookups of similar items. I'd also add a weighting to
  the tags in the links table, maybe with the more people that add a
  specific tag, the more weight that tag gets.
 
  Also check out http://www.music-map.com/ as an example of showing
  similar music - you might even be able to plug into this data.

 Hi Jason

 Hmm, food for thought. 

Re: [PHP] Problem with using array_diff and array_combine

2008-07-29 Thread Chris
Richard Kurth wrote:
 I hope I can explain what I am trying to do.
 I have two tables the first one has the custom form elements
 
 
 elements_id elements_field_type elements_field_caption members_id
   35   text  test8
   36   text  test28
 
 
 The second one has the customer id and the field value withe the field name
 
 dbelements_field_name dbelements_field_value members_id customer_id
   35Test This Field  8   346
   36  8   346
   36Test2  8   347
 
 
 If you look at the second table you will see that one field name is
 related to two different  customers and one field name on relates to one
 customer.
 I am trying to look at these two tables and find customer that do not
 have a row for each field name.
 
 I have been trying with
 
 array_combine($dbelements_field_array,$dbelements_id_array)
 and also array_diff($customf_array,$dbelements_field_array)

You can do it in sql.

// find customer_id's who don't have all fields filled in
$subquery = 
select
  customer_id
from
  customformelements cfe
left join
  dbelements de on (cfe.elements_id=de.dbelements_field_name and
de.members_id=cfe.members_id)
where
  cfe.members_id=8
and
de.dbelements_field_name is null
;

Then get your customers:

select
  c.*
from
  contacts
where
  customer_id in
(
  $subquery
);


Also for array_diff you have to check it both ways:

$ cat diff.php
?php

$array_one = array (1,2,3,4,5);
$array_two = array (2,3,4);

$diff_one = array_diff($array_one, $array_two);
echo diff 1:\n;
print_r($diff_one);

$diff_two = array_diff($array_two, $array_one);
echo diff 2:\n;
print_r($diff_two);


$ php diff.php
diff 1:
Array
(
[0] = 1
[4] = 5
)
diff 2:
Array
(
)


-- 
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] PHP4 vs PHP5 classes

2008-07-29 Thread Chris
[EMAIL PROTECTED] wrote:
 Since the Players method is a constructor, it's more about how you set
 the object(s) up.

 What does the loop look like before you create a new object?

 
 Well see here is where it gets messy! This is not my code - I've ported a
 phpnuke module over to dragonflycms.
 
 The $players object is created before the loop:
 $players = new Players($lid);

snip

Which means the code is only executed once since it's in the
constructor. It's not changing per loop because you're not calling the code.

Maybe setting $this-max should be done in

fetchSelectData

since that's what is causing/creating your loop.

-- 
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] PHP4 vs PHP5 classes

2008-07-29 Thread jeff . mills


 Since the Players method is a constructor, it's more about how you set
 the object(s) up.

 What does the loop look like before you create a new object?


Well see here is where it gets messy! This is not my code - I've ported a
phpnuke module over to dragonflycms.

The $players object is created before the loop:
$players = new Players($lid);

The loop is quite big, but here is the important part:

-SNIP-
while (list($pid, $name, $gsid, $stat) = $players-fetchSelectData()) {
  if (DEBUG_LEAGUE == YES) echo trtd colspan=\22\\$maxcol =
$maxcol | \$pid = $pid | \$name = $name | \$gsid = $gsid | \$stat =
$stat/td/tr\$
  $noplayer=0;
  if ($prevgsid != $gsid) {
 $prevgsid = $gsid;
 $players-selectHeaders($gsid);
 if (DEBUG_LEAGUE == YES) var_dump($players);
 displayPlayerSetupRow($players,
.getlink($module).amp;file=indexamp;mode=$modeamp;lid=$lidamp;sid=$sidamp;gsid=$gsid,
$order);
  }
-SNIP-

function displayPlayerSetupRow is also very big, but here it is up to the
troublesome $players-max call:

-SNIP-
function displayPlayerSetupRow($players, $go=, $prevorder=0) {
   global $bgcolor2;

   if ($prevorder==)
  $prevorder=0;

   $urlstart=;
   $urlend=;
   $max = $players-max();

-SNIP-

Then we enter class Players as previously mentioned:

-SNIP-
class Players extends dynamicTable {
   var $setup;
   var $lid;
   var $size;
   var $max;
   var $data;
   var $data_result;
   var $data_index;
   var $player_stats_result;
   var $player_stats_data;
   var $player_stats_index;
   var $player_stats_start;
   var $player_type_result;

   function Players($lid) {
  global $prefix, $db;

  /*
   * Find max size of rows
   */

  $this-lid = $lid;
  $this-max=0;
  $result = $db-sql_query(select * from  . $prefix .
_league_games_setup where lid = $lid);
  while (($rows = $db-sql_fetchrow($result))) {
 $c=0;
 for ($i=3; $i  23; $i++) {
  if ($rows[$i] != )
 $c++;
 }
 if ($c  $this-max)
$this-max = $c;
  }

  $this-index = 3;
   }

   function name() {
  return ($this-setup['name']);
   }

   function max() {
return ($this-max);
   }
-SNIP-






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

 --
 This email has been scanned for viruses and dangerous content by
 Sydney Technology Solutions MailMaster Email Protection Services.

 For more information please visit http://www.sydneytech.com.au
 :Scanned by MailMaster1:





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



Re: [PHP] PHP4 vs PHP5 classes

2008-07-29 Thread jeff . mills


 The $players object is created before the loop:
 $players = new Players($lid);

 snip

 Which means the code is only executed once since it's in the
 constructor. It's not changing per loop because you're not calling the
 code.

 Maybe setting $this-max should be done in

 fetchSelectData

 since that's what is causing/creating your loop.

Thanks Chris, I will give that a shot.
Just to confirm, this script works just fine in php4, so do we put that
down to pure luck, or has there been a change in php5 that will be causing
it?




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

 --
 This email has been scanned for viruses and dangerous content by
 Sydney Technology Solutions MailMaster Email Protection Services.

 For more information please visit http://www.sydneytech.com.au
 :Scanned by MailMaster1:





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



Re: [PHP] PHP4 vs PHP5 classes

2008-07-29 Thread jeff . mills

 Maybe setting $this-max should be done in

 fetchSelectData

 since that's what is causing/creating your loop.


Thanks Chris, I copied the code into the fetchSelectData function and it
seems to be working fine now!
Just need to test removing the code from the constructor to make sure its
still working, and also test that php4 is still working.

I'm just concerned that the code might also be called from somewhere else.

You've cured my headache!


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



Re: [PHP] PHP4 vs PHP5 classes

2008-07-29 Thread Chris
[EMAIL PROTECTED] wrote:
 The $players object is created before the loop:
 $players = new Players($lid);
 snip

 Which means the code is only executed once since it's in the
 constructor. It's not changing per loop because you're not calling the
 code.

 Maybe setting $this-max should be done in

 fetchSelectData

 since that's what is causing/creating your loop.
 
 Thanks Chris, I will give that a shot.
 Just to confirm, this script works just fine in php4, so do we put that
 down to pure luck, or has there been a change in php5 that will be causing
 it?

No idea why it works in php4 - if you're only calling the Players
method once (or through the constructor) it should have behaved the same
in php4.

-- 
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] Web2.0 style tags - where to start?

2008-07-29 Thread Børge Holen
On Tuesday 29 July 2008 00:57:22 Paul Jinks wrote:
 Jason Norwood-Young wrote:
  On Mon, 2008-07-28 at 14:48 +0100, Paul Jinks wrote:
  I think my first post was ambiguous. What we're thinking of is to build
  a site on which people can view videos with the option to add metadata
  to a video after viewing it.
 
  We think that the content we have will be of wide interest to a lot of
  people and the best way to index it is for users to 'tag' it themselves,
  since it's hard for us to anticipate the uses that people may have for
  the content.
 
  How do you plan to have users enter the info? Through the Flash player,
  through some kinda Ajax form, through a form in a frame or just a static
  form?
 
  Also, would the tags be predefined by you (eg. genres like the ID3 tag
  genres) or would people be able to add their own tags?
 
  The way I'd do it would be to let the users enter the info through an
  Ajax form below the video, with suggestions popping up as they type.
  Then save it in a separate table (I assume all your vids are in their
  own table) with a link table between the vids table and the tags table
  (M2M relationship). This means that if the tag is already in there and
  linked to one vid, you don't replicate it for a second vid. It's also
  very easy to do lookups of similar items. I'd also add a weighting to
  the tags in the links table, maybe with the more people that add a
  specific tag, the more weight that tag gets.
 
  Also check out http://www.music-map.com/ as an example of showing
  similar music - you might even be able to plug into this data.

 Hi Jason

 Hmm, food for thought. music-map is brilliant, though not what I'm
 looking for graphically at the moment (was surprised to find Cesaria
 Evora in close proximity to The Cardigans but I digress).

 What you describe is pretty much what I'm chasing, thanks and helps me
 down the road, particularly with thinking about the database set up.
 They 'only' problem is, my php/mysql skills are some way behind my
 javascript/actionscript  knowhow (I'm pretty much a noob here);  what I
 could use now is a how-to tutorial to give me some code to work off,
 either online or in a book. If it ain't there, I can build from scratch
 but it's going to mean a lot of calls for help! =)

http://www.google.com/search?q=mysql+php+tutorialsie=utf-8oe=utf-8aq=trls=org.debian:en-US:unofficialclient=iceweasel-a
I like from scratch... =D I guss I can do that cuz I don't make a living out 
of it ;D


 Many thanks

 Paul



-- 
---
Børge Holen
http://www.arivene.net

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



Re: [PHP] Web2.0 style tags - where to start?

2008-07-29 Thread Jason Norwood-Young

On Mon, 2008-07-28 at 23:57 +0100, Paul Jinks wrote:
 Jason Norwood-Young wrote:
  On Mon, 2008-07-28 at 14:48 +0100, Paul Jinks wrote:

  I think my first post was ambiguous. What we're thinking of is to build a
  site on which people can view videos with the option to add metadata to a
  video after viewing it.
 
  We think that the content we have will be of wide interest to a lot of
  people and the best way to index it is for users to 'tag' it themselves,
  since it's hard for us to anticipate the uses that people may have for the
  content.
  
 
  How do you plan to have users enter the info? Through the Flash player,
  through some kinda Ajax form, through a form in a frame or just a static
  form? 
 
  Also, would the tags be predefined by you (eg. genres like the ID3 tag
  genres) or would people be able to add their own tags?
 
  The way I'd do it would be to let the users enter the info through an
  Ajax form below the video, with suggestions popping up as they type.
  Then save it in a separate table (I assume all your vids are in their
  own table) with a link table between the vids table and the tags table
  (M2M relationship). This means that if the tag is already in there and
  linked to one vid, you don't replicate it for a second vid. It's also
  very easy to do lookups of similar items. I'd also add a weighting to
  the tags in the links table, maybe with the more people that add a
  specific tag, the more weight that tag gets. 
 
  Also check out http://www.music-map.com/ as an example of showing
  similar music - you might even be able to plug into this data.
 

 Hi Jason
 
 Hmm, food for thought. music-map is brilliant, though not what I'm 
 looking for graphically at the moment (was surprised to find Cesaria 
 Evora in close proximity to The Cardigans but I digress).
 
 What you describe is pretty much what I'm chasing, thanks and helps me 
 down the road, particularly with thinking about the database set up. 
 They 'only' problem is, my php/mysql skills are some way behind my 
 javascript/actionscript  knowhow (I'm pretty much a noob here);  what I 
 could use now is a how-to tutorial to give me some code to work off, 
 either online or in a book. If it ain't there, I can build from scratch 
 but it's going to mean a lot of calls for help! =)
 
 Many thanks
 
 Paul

In that case, I suggest the following solution:
1. Download the unternet into your puter
2. Open the file called mysql.com
3. Read and learn
4. Open the file called php.net
5. Read and learn
6. Rinse and repeat

In all seriousness, this is a nice, simple project to learn on. You want
to look at different types of relationships in Sql (one-to-one,
one-to-many and many-to-many) and learn a bit about basic DB
architecture; make some tables and play with getting data in and out
(get PHPMyAdmin to help you out); maybe use a nice simple framework like
CodeIgniter to get you kick-started on the PHP.


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



Re: [PHP] Web2.0 style tags - where to start?

2008-07-29 Thread Paul Jinks

On Tue, July 29, 2008 9:22 am, Jason Norwood-Young wrote:

 On Mon, 2008-07-28 at 23:57 +0100, Paul Jinks wrote:
 Jason Norwood-Young wrote:
  On Mon, 2008-07-28 at 14:48 +0100, Paul Jinks wrote:
 
  I think my first post was ambiguous. What we're thinking of is to
 build a
  site on which people can view videos with the option to add metadata
 to a
  video after viewing it.
 
  We think that the content we have will be of wide interest to a lot
 of
  people and the best way to index it is for users to 'tag' it
 themselves,
  since it's hard for us to anticipate the uses that people may have
 for the
  content.
 
 
  How do you plan to have users enter the info? Through the Flash
 player,
  through some kinda Ajax form, through a form in a frame or just a
 static
  form?
 
  Also, would the tags be predefined by you (eg. genres like the ID3 tag
  genres) or would people be able to add their own tags?
 
  The way I'd do it would be to let the users enter the info through an
  Ajax form below the video, with suggestions popping up as they type.
  Then save it in a separate table (I assume all your vids are in their
  own table) with a link table between the vids table and the tags table
  (M2M relationship). This means that if the tag is already in there and
  linked to one vid, you don't replicate it for a second vid. It's also
  very easy to do lookups of similar items. I'd also add a weighting to
  the tags in the links table, maybe with the more people that add a
  specific tag, the more weight that tag gets.
 
  Also check out http://www.music-map.com/ as an example of showing
  similar music - you might even be able to plug into this data.
 
 
 Hi Jason

 Hmm, food for thought. music-map is brilliant, though not what I'm
 looking for graphically at the moment (was surprised to find Cesaria
 Evora in close proximity to The Cardigans but I digress).

 What you describe is pretty much what I'm chasing, thanks and helps me
 down the road, particularly with thinking about the database set up.
 They 'only' problem is, my php/mysql skills are some way behind my
 javascript/actionscript  knowhow (I'm pretty much a noob here);  what I
 could use now is a how-to tutorial to give me some code to work off,
 either online or in a book. If it ain't there, I can build from scratch
 but it's going to mean a lot of calls for help! =)

 Many thanks

 Paul

 In that case, I suggest the following solution:
 1. Download the unternet into your puter
 2. Open the file called mysql.com
 3. Read and learn
 4. Open the file called php.net
 5. Read and learn
 6. Rinse and repeat

LOL
 In all seriousness, this is a nice, simple project to learn on. You want
 to look at different types of relationships in Sql (one-to-one,
 one-to-many and many-to-many) and learn a bit about basic DB
 architecture; make some tables and play with getting data in and out
 (get PHPMyAdmin to help you out); maybe use a nice simple framework like
 CodeIgniter to get you kick-started on the PHP.


Right, from scratch it is then (installs xampp, starts up PSPad, and
cancels  all meetings)... =)

Cheers

Paul


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



Re: [PHP] Double results??

2008-07-29 Thread Paul Gregg
In mail.php.general, Dan Shirah [EMAIL PROTECTED] wrote:
  $name_result = ifx_query ($name_query, $connect_id);
  while ($name = ifx_fetch_row($name_result)) {
   $party_name = TRIM($name['caa44240004']);
   print_r($name);
  }
 
 print_r($name) will return:
 John
 John
 Mary
 Mary
 Cindy
 Cindy

I don't know anything about the Informix functions, but in other database
types fetch_row can return doubly indexed entries.   e.g.
array(
 0 = 'John',
 'name' = 'John',
)

I would suggest you use var_dump() or var_export() to get a better idea of
what is in $name - you might find if this is the case that your code
is not necessarily wrong because you are getting the right number of rows.

Note it is hard to tell from your code - because your code would run
print_r() for every loop - but that isn't what your suggested output is.

Regards,
PG

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



[PHP] Thumbnail through PHP RSS parser

2008-07-29 Thread Lyubomir Tsvetanov
Hello, folks!

I'm trying to parse RSS feed and display it on my own page.
MagpieRSS looks good enough for me, but I have a little problem.
http://magpierss.sourceforge.net/

I want to display not only the title and description of each article,
but the thumbnail as well.
For example, I tried to do that with this feed.
http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml
Everything is alright with the title and the description, but I can't
do the thumbnail thing. What I've tried is the following:

foreach ($rss-items as $item ) {
$title = $item[title];
$url   = $item[link];
$description = $item[description];
$thumbnail = $item['media:thumbnail'];
echo a href=$url$title/a/libr;
echo $description;
echo img $thumbnail;
}

As I said before, the other things are fine, but it's not showing the
thumbnail. This is the structure:

titletxt/title
descriptiontxt/description
media:thumbnail width=X height=Y url=url/

And the following line of the php code returns blank result.
(probably because we require parameter of media:thumbnail, not
the value 'inside' it):

$thumbnail = $item['media:thumbnail'];

So I am interested in that parameter url, but I do not know how
can we get it.
Thanks in advance for any help!


[PHP] Re: Thumbnail through PHP RSS parser

2008-07-29 Thread Colin Guthrie

Lyubomir Tsvetanov wrote:

Hello, folks!

I'm trying to parse RSS feed and display it on my own page.
MagpieRSS looks good enough for me, but I have a little problem.
http://magpierss.sourceforge.net/

I want to display not only the title and description of each article,
but the thumbnail as well.
For example, I tried to do that with this feed.
http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml
Everything is alright with the title and the description, but I can't
do the thumbnail thing. What I've tried is the following:

foreach ($rss-items as $item ) {
$title = $item[title];
$url   = $item[link];
$description = $item[description];
$thumbnail = $item['media:thumbnail'];
echo a href=$url$title/a/libr;
echo $description;
echo img $thumbnail;
}

As I said before, the other things are fine, but it's not showing the
thumbnail. This is the structure:

titletxt/title
descriptiontxt/description
media:thumbnail width=X height=Y url=url/

And the following line of the php code returns blank result.
(probably because we require parameter of media:thumbnail, not
the value 'inside' it):

$thumbnail = $item['media:thumbnail'];

So I am interested in that parameter url, but I do not know how
can we get it.


You need to look at how to read the attributes of the element using 
magpie. Note that your surrounding it in a img tag just wont work as 
it does not use the standard src= attribute that an img element expects!


I've not used it but vardump() or print_r() on the $item will probably 
show you what you need to do.


Col


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



Re: [PHP] Thumbnail through PHP RSS parser

2008-07-29 Thread Philip Thompson

On Jul 29, 2008, at 6:33 AM, Lyubomir Tsvetanov wrote:


Hello, folks!

I'm trying to parse RSS feed and display it on my own page.
MagpieRSS looks good enough for me, but I have a little problem.
http://magpierss.sourceforge.net/

I want to display not only the title and description of each article,
but the thumbnail as well.
For example, I tried to do that with this feed.
http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml
Everything is alright with the title and the description, but I can't
do the thumbnail thing. What I've tried is the following:

   foreach ($rss-items as $item ) {
   $title = $item[title];
   $url   = $item[link];
   $description = $item[description];
   $thumbnail = $item['media:thumbnail'];
   echo a href=$url$title/a/libr;
   echo $description;
   echo img $thumbnail;
}

As I said before, the other things are fine, but it's not showing the
thumbnail. This is the structure:

titletxt/title
descriptiontxt/description
media:thumbnail width=X height=Y url=url/


media:thumbnail width=x height=y src=src /

Try that instead.

~Phil



And the following line of the php code returns blank result.
(probably because we require parameter of media:thumbnail, not
the value 'inside' it):

   $thumbnail = $item['media:thumbnail'];

So I am interested in that parameter url, but I do not know how
can we get it.
Thanks in advance for any help!


Personally, most of my web applications do not have to factor 13.7  
billion years of space drift in to the calculations, so PHP's rand  
function has been great for me... ~S. Johnson



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



[PHP] Please, I need help with curl and php

2008-07-29 Thread Marco Vallejo
Hi, I´m making a little application with php and curl, but I´m a newby with
curl.

Please help me with the next script.

I used to use this in order to make a connection with an specific site on
the console ms-dos (windows), how can i translate this into php code?

curl -x proxy_url:proxy_port -U proxy_user:proxy_pass --cert
cert.pem:cert_pass --cert-type PEM -k -c cookie.txt -d
txtUser=user_loguintxtPass=pass_loguin
url_requiredhttps://renat.segob.gob.mx/AppRNT/validacion/valida.php

I tried with this, but it doesn't work fine

$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEJAR, $f_path);
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_setopt($ch, CURLOPT_PROXY, $proxurl);
curl_setopt($ch,CURLOPT_PROXYPORT,$proxport);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_CAINFO, $fichero);
curl_setopt($ch, CURLOPT_PROXYUSERPWD, '.$proxyu.:.$proxyp.');
curl_setopt($ch,CURLOPT_SSLCERT,$fichero);
curl_setopt($ch,CURLOPT_SSLCERTTYPE, pem);
curl_setopt($ch,CURLOPT_SSLCERTPASSWD,$pcert);
curl_setopt($ch,CURLOPT_USERPWD,'.$usr.:.$pwd.');
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_TIMEOUT, 0);
curl_setopt($ch, CURLOPT_HEADER, 1);
$HTTP_Response1 = curl_exec($ch);


Thanks and recards


RE: [PHP] Please, I need help with curl and php

2008-07-29 Thread Wei, Alice J.

Hi, I´m making a little application with php and curl, but I´m a newby with
curl.

Please help me with the next script.

I used to use this in order to make a connection with an specific site on
the console ms-dos (windows), how can i translate this into php code?

curl -x proxy_url:proxy_port -U proxy_user:proxy_pass --cert
cert.pem:cert_pass --cert-type PEM -k -c cookie.txt -d
txtUser=user_loguintxtPass=pass_loguin
url_requiredhttps://renat.segob.gob.mx/AppRNT/validacion/valida.php

I tried with this, but it doesn't work fine

$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEJAR, $f_path);
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_setopt($ch, CURLOPT_PROXY, $proxurl);
curl_setopt($ch,CURLOPT_PROXYPORT,$proxport);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_CAINFO, $fichero);
curl_setopt($ch, CURLOPT_PROXYUSERPWD, '.$proxyu.:.$proxyp.');
curl_setopt($ch,CURLOPT_SSLCERT,$fichero);
curl_setopt($ch,CURLOPT_SSLCERTTYPE, pem);
curl_setopt($ch,CURLOPT_SSLCERTPASSWD,$pcert);
curl_setopt($ch,CURLOPT_USERPWD,'.$usr.:.$pwd.');
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_TIMEOUT, 0);
curl_setopt($ch, CURLOPT_HEADER, 1);
$HTTP_Response1 = curl_exec($ch);


Thanks and recards

Have you tried taking $HTTP_Response1 out and just execute the curl by doing 
curl_exec($ch)?
It seems to me that it is initiating, but it is not calling or executing 
anything.

This is what I have when I use curl

// grab URL and pass it to the browser
curl_exec($ch);

// close cURL resource, and free up system resources
curl_close($ch);

Hope this helps.

Alice
==
Alice Wei
MIS 2009
School of Library and Information Science
Indiana University Bloomington
[EMAIL PROTECTED]

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



Re: [PHP] PHP4 vs PHP5 classes

2008-07-29 Thread Jim Lucas

[EMAIL PROTECTED] wrote:

Maybe setting $this-max should be done in

fetchSelectData

since that's what is causing/creating your loop.



Thanks Chris, I copied the code into the fetchSelectData function and it
seems to be working fine now!
Just need to test removing the code from the constructor to make sure its
still working, and also test that php4 is still working.

I'm just concerned that the code might also be called from somewhere else.

You've cured my headache!




Don't forget that in PHP5, the constructor named has changed.  In PHP4 it 
called a method with the same name as the class.  But, in PHP5, it looks for 
__construct() instead.


I workaround that I use is this:

?php

class myClass {

  function __construct() {
  }

  function myClass() {
$this-__construct();
  }

}

?

With this type of construct, your classes will initialize the same between 
PHP4 and PHP5.


--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare


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



[PHP] XML Encoding

2008-07-29 Thread Thiago H. Pojda
Guys,

I'm building a XML in a PHP Script. Everything works fine until I add
accented (ISO-8859-1) characters into it.

As far as I can see, there's no way to change DOMDocument's encoding from
UTF-8, right?


Thanks,
-- 
Thiago Henrique Pojda


RE: [PHP] Please, I need help with curl and php

2008-07-29 Thread Wei, Alice J.

Thanks for your time

As you can see, I´m trying to connect to a web site and:
* I need to use a cert. This cert is pem type
* I go out from my net throw a proxy with an user and pass
* I need to collect cookies

And the most important, I need to catch the answer from this script.

The script that I send you has a lot of variables, but I'm replacing it with 
the real value in mi app.

the problem is that I don't know if my code is correct, and why I´m receibing 
the error message:

Error 58: unable to use client certificate (no key found or wrong pass phrase?)

I know that my password is correct, so I think that the problem is related to 
my php code .

Since I don't see the code, my guess is that there is something going on with 
the snippet regarding the error above.

There is an article online regarding API errors and talks about the same error 
you are coming across:

Unable to use client certificate (no key found or wrong pass phrase?)

You are receiving this error becuase you have the wrong path for the PEM 
file. Also make sure you upload the PEM file in ASCII format for UNIX servers.
On a UNIX server the path for the PEM file should look something like this:
$myorder[keyfile] = /home/htdocs/www/linkpoint/123456.pem;

On a WINDOWS server the path should look like this:
$myorder[keyfile] = c:\\inetpub\\wwwroot\\linkpoint\\123456.pem;

If you can not determine the path for the PEM file you can use the 
following code: (make sure the PEM file is in the same directory as your PHP 
file)
$myorder[keyfile] = realpath(123456.pem);

I hope this helps.

Alice


2008/7/29 Wei, Alice J. [EMAIL PROTECTED]mailto:[EMAIL PROTECTED]

Hi, I´m making a little application with php and curl, but I´m a newby with
curl.

Please help me with the next script.

I used to use this in order to make a connection with an specific site on
the console ms-dos (windows), how can i translate this into php code?

curl -x proxy_url:proxy_port -U proxy_user:proxy_pass --cert
cert.pem:cert_pass --cert-type PEM -k -c cookie.txt -d
txtUser=user_loguintxtPass=pass_loguin
url_requiredhttps://renat.segob.gob.mx/AppRNT/validacion/valida.php

I tried with this, but it doesn't work fine

$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEJAR, $f_path);
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_setopt($ch, CURLOPT_PROXY, $proxurl);
curl_setopt($ch,CURLOPT_PROXYPORT,$proxport);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_CAINFO, $fichero);
curl_setopt($ch, CURLOPT_PROXYUSERPWD, '.$proxyu.:.$proxyp.');
curl_setopt($ch,CURLOPT_SSLCERT,$fichero);
curl_setopt($ch,CURLOPT_SSLCERTTYPE, pem);
curl_setopt($ch,CURLOPT_SSLCERTPASSWD,$pcert);
curl_setopt($ch,CURLOPT_USERPWD,'.$usr.:.$pwd.');
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_TIMEOUT, 0);
curl_setopt($ch, CURLOPT_HEADER, 1);
$HTTP_Response1 = curl_exec($ch);


Thanks and recards

Have you tried taking $HTTP_Response1 out and just execute the curl by doing 
curl_exec($ch)?
It seems to me that it is initiating, but it is not calling or executing 
anything.

This is what I have when I use curl

// grab URL and pass it to the browser
curl_exec($ch);

// close cURL resource, and free up system resources
curl_close($ch);

Hope this helps.

Alice
==
Alice Wei
MIS 2009
School of Library and Information Science
Indiana University Bloomington
[EMAIL PROTECTED]mailto:[EMAIL PROTECTED]

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



[PHP] Php CLI Parser not working

2008-07-29 Thread JJB

We recently rebuilt a webserver and upgraded it to opensuse 10.3.
Now, when our webdev people run command line php scripts all of the
included files are being output to the terminal instead of parsed.

Can anyone make a good suggestion for what might be going on here?
My Linux admin is out today, if someone can give me a clue about what
might be the problem, then perhaps I can figure out how to fix it.

- Joel


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



[PHP] XML Encoding - with examples

2008-07-29 Thread Thiago H. Pojda
Okay,

After much iconv, headers and workarounds I figured I can't use
DOMDocument for XMLs when under ISO-8859-1 encoding without messing accented
chars.

The idea is simple: get a query result and turn into a XML. Using
mysql_fetch_object is the best way for this task.

If I just do nothing: get iso text, insert into the XML and not set the
encoding, the XML loads (w/o xml content type in header) but it's a bad
thing to do (not all browsers like this).

Anyone have any ideas why the following doesn't work or how to fix it?


The right thing to do, which doesn't work.

?php
header('Content-type: text/xml; charset = ISO-8859-1');

$unidades = listarUnidadesSetor(58,1); //returns a stdClass -
mysql_fetch_object

$doc = new DOMDocument(1.0, 'ISO-8859-1'); //setting XML Encoding to ISO
breaks in the first accented char
$doc-formatOutput = true;  //Figured this does nothing

$xml = $doc-createElement( unidades ); //root element
$doc-appendChild( $xml );

foreach ($unidades as $unidade)
{
  $valores = get_object_vars($unidade); //all object atributes (row
name/value in mysql table)

  $unidade = $doc-createElement( unidade );
  foreach ($valores as $atributo=$valor){
//$valor = iconv('ISO-8859-1','UTF-8',$valor); // iconv messes with
accented chars
$node = $doc-createElement( $atributo );
$node-appendChild(
$doc-createTextNode( $valor )
);
$unidade-appendChild( $node );
  }
  $xml-appendChild( $unidade );
}
$doc-appendChild( $xml );
echo $doc-saveXML();
?

The wrong thing, which correctly gives me the xml file with correct
encoding and everything (just built it myself as a string, no DOM functions
are used):
?php
header('Content-type: text/xml; charset = ISO-8859-1');

$unidades = listarUnidadesSetor(58,1);

$xml  = ?xml version=\1.0\ encoding=\ISO-8859-1\?\n;
$xml .= unidades\n;
foreach ($unidades as $unidade){
$xml .= unidade\n;
$valores = get_object_vars($unidade);
foreach ($valores as $atributo=$valor){
$xml .= $atributo $valor /$atributo;
}
$xml .= /unidade\n;
}
$xml .= /unidades\n;

echo $xml;
?


Regards,
-- 
Thiago Henrique Pojda


Re: [PHP] Php CLI Parser not working

2008-07-29 Thread Daniel Brown
On Tue, Jul 29, 2008 at 2:19 PM, JJB [EMAIL PROTECTED] wrote:
 We recently rebuilt a webserver and upgraded it to opensuse 10.3.
 Now, when our webdev people run command line php scripts all of the
 included files are being output to the terminal instead of parsed.

How are the scripts being run from the CLI?  As shell scripts with
this as the following line:

#!/path/to/php

-or-

#!/bin/env php

 or by using the command 'php script.php' from the command line?


What do you see when, from the command line, you issue the command
'php -v' ?

-- 
/Daniel P. Brown
Better prices on dedicated servers:
Intel 2.4GHz/60GB/512MB/2TB $49.99/mo.
Intel 3.06GHz/80GB/1GB/2TB $59.99/mo.
Dedicated servers, VPS, and hosting from $2.50/mo.

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



Re: [PHP] Php CLI Parser not working

2008-07-29 Thread Jim Lucas

JJB wrote:

We recently rebuilt a webserver and upgraded it to opensuse 10.3.
Now, when our webdev people run command line php scripts all of the
included files are being output to the terminal instead of parsed.

Can anyone make a good suggestion for what might be going on here?
My Linux admin is out today, if someone can give me a clue about what
might be the problem, then perhaps I can figure out how to fix it.

- Joel




If this is a fresh install, you might check to see of the code uses short php 
tags  '?' instead of '?php' . If this is the case, they you need to change 
the short_open_tag = Off to short_open_tag = On  in  your php.ini file.


Older versions of PHP had this On by default.  Newer versions do not.

--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare


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



Re: [PHP] XML Encoding - with examples

2008-07-29 Thread Andrew Ballard
On Tue, Jul 29, 2008 at 2:33 PM, Thiago H. Pojda [EMAIL PROTECTED] wrote:
 Okay,

 After much iconv, headers and workarounds I figured I can't use
 DOMDocument for XMLs when under ISO-8859-1 encoding without messing accented
 chars.

 The idea is simple: get a query result and turn into a XML. Using
 mysql_fetch_object is the best way for this task.

 If I just do nothing: get iso text, insert into the XML and not set the
 encoding, the XML loads (w/o xml content type in header) but it's a bad
 thing to do (not all browsers like this).

 Anyone have any ideas why the following doesn't work or how to fix it?


 The right thing to do, which doesn't work.

 ?php
 header('Content-type: text/xml; charset = ISO-8859-1');

 $unidades = listarUnidadesSetor(58,1); //returns a stdClass -
 mysql_fetch_object

 $doc = new DOMDocument(1.0, 'ISO-8859-1'); //setting XML Encoding to ISO
 breaks in the first accented char
 $doc-formatOutput = true;  //Figured this does nothing

 $xml = $doc-createElement( unidades ); //root element
 $doc-appendChild( $xml );

 foreach ($unidades as $unidade)
 {
  $valores = get_object_vars($unidade); //all object atributes (row
 name/value in mysql table)

  $unidade = $doc-createElement( unidade );
  foreach ($valores as $atributo=$valor){
 //$valor = iconv('ISO-8859-1','UTF-8',$valor); // iconv messes with
 accented chars
$node = $doc-createElement( $atributo );
$node-appendChild(
$doc-createTextNode( $valor )
);
$unidade-appendChild( $node );
  }
  $xml-appendChild( $unidade );
 }
 $doc-appendChild( $xml );
 echo $doc-saveXML();
 ?

 The wrong thing, which correctly gives me the xml file with correct
 encoding and everything (just built it myself as a string, no DOM functions
 are used):
 ?php
 header('Content-type: text/xml; charset = ISO-8859-1');

 $unidades = listarUnidadesSetor(58,1);

 $xml  = ?xml version=\1.0\ encoding=\ISO-8859-1\?\n;
 $xml .= unidades\n;
 foreach ($unidades as $unidade){
$xml .= unidade\n;
$valores = get_object_vars($unidade);
foreach ($valores as $atributo=$valor){
$xml .= $atributo $valor /$atributo;
}
$xml .= /unidade\n;
 }
 $xml .= /unidades\n;

 echo $xml;
 ?


 Regards,
 --
 Thiago Henrique Pojda


Are you sure the accented characters you are using are part of
ISO-8859-1 and not UTF-8? I don't have your data set, but I ran your
code with a list of country names some of which include accented
characters. It worked fine if I set the XML document encoding to
UTF-8. (It even worked fine if I used the iconv line you have
commented out, but I'm any XML reader that tries to use the ISO-8859-1
encoding to read the file will spit out the first character that
doesn't belong to the set.)

Is there any reason in particular that you MUST use ISO-8859-1 rather
than UTF-8? The former is a subset of the latter, so I would think
you'd save yourself the headache if you just used UTF-8 for
everything.

Andrew

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



Re: [PHP] XML Encoding

2008-07-29 Thread mike
you should want it to be utf-8 anyway.

On 7/29/08, Thiago H. Pojda [EMAIL PROTECTED] wrote:
 Guys,

 I'm building a XML in a PHP Script. Everything works fine until I add
 accented (ISO-8859-1) characters into it.

 As far as I can see, there's no way to change DOMDocument's encoding from
 UTF-8, right?


 Thanks,
 --
 Thiago Henrique Pojda


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



[PHP] foreach question

2008-07-29 Thread Jason Pruim

Hey Everyone...

So I am attempting to pull 2 random records from a MySQL database, so  
I wrote a function which I'll paste below. I had it mostly working  
with a while() statement, but I wanted to try a foreach to see if I  
could get the formatting a little bit better.


Basically... What it does is grab 2 records at random from the  
database, and display the images. What I want is something that looks  
like this: img1 VS img2


right now though... I'm at a lose to figure out why it's not returning  
any records but not throwing any errors... Any ideas what I'm missing?


?PHP
//function for pulling random pictures from the database


function random($random){

$randomQuery = SELECT * FROM `current` ORDER BY Rand() LIMIT 2;

$result = mysql_query($randomQuery);
$row[] = $result;   


foreach($row as $key = $value) {
$random[$key] = $value;

}

return $random;

}//End of function


?

Any ideas?



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



Re: [PHP] XML Encoding - with examples

2008-07-29 Thread Thiago H. Pojda
On Tue, Jul 29, 2008 at 4:20 PM, Andrew Ballard [EMAIL PROTECTED] wrote:

 On Tue, Jul 29, 2008 at 2:33 PM, Thiago H. Pojda [EMAIL PROTECTED]
 wrote:
 babling and code
  --
  Thiago Henrique Pojda
 

 Are you sure the accented characters you are using are part of
 ISO-8859-1 and not UTF-8? I don't have your data set, but I ran your
 code with a list of country names some of which include accented
 characters. It worked fine if I set the XML document encoding to
 UTF-8. (It even worked fine if I used the iconv line you have
 commented out, but I'm any XML reader that tries to use the ISO-8859-1
 encoding to read the file will spit out the first character that
 doesn't belong to the set.)


Try this word: descrição (description, in Portuguese). I couldn't get it to
show correctly in Firefox and other browsers, even after sending the proper
header.



 Is there any reason in particular that you MUST use ISO-8859-1 rather
 than UTF-8? The former is a subset of the latter, so I would think
 you'd save yourself the headache if you just used UTF-8 for
 everything.

I need to see accented characters, I don't mind how it's going to work atm.
I know UTF-8 is better, but ISO seem to suit my needs better.



 Andrew

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


Thank you for your time,
-- 
Thiago Henrique Pojda


Re: [PHP] foreach question

2008-07-29 Thread Daniel Brown
On Tue, Jul 29, 2008 at 3:25 PM, Jason Pruim [EMAIL PROTECTED] wrote:

 function random($random){

$randomQuery = SELECT * FROM `current` ORDER BY Rand() LIMIT 2;

$result = mysql_query($randomQuery);
 $row[] = $result;


 foreach($row as $key = $value) {
 $random[$key] = $value;

 }

 return $random;

 }//End of function


 ?

You're missing mysql_fetch_array(), mysql_fetch_assoc(), or
something of the like.

Example:

?php
//  code

 $result = mysql_query($randomQuery);
 $row = mysql_fetch_array($result);

 foreach($row as $k = $v) {
 $random[$k] = $v;
 }

//  code
}
?

-- 
/Daniel P. Brown
Better prices on dedicated servers:
Intel 2.4GHz/60GB/512MB/2TB $49.99/mo.
Intel 3.06GHz/80GB/1GB/2TB $59.99/mo.
Dedicated servers, VPS, and hosting from $2.50/mo.

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



Re: [PHP] foreach question

2008-07-29 Thread Micah Gersten
You cannot do this:
$row[] = $result;   

You need to loop around this:
$row = mysql_fetch_assoc($result);

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Jason Pruim wrote:
 Hey Everyone...

 So I am attempting to pull 2 random records from a MySQL database, so
 I wrote a function which I'll paste below. I had it mostly working
 with a while() statement, but I wanted to try a foreach to see if I
 could get the formatting a little bit better.

 Basically... What it does is grab 2 records at random from the
 database, and display the images. What I want is something that looks
 like this: img1 VS img2

 right now though... I'm at a lose to figure out why it's not returning
 any records but not throwing any errors... Any ideas what I'm missing?

 ?PHP
 //function for pulling random pictures from the database


 function random($random){
 
 $randomQuery = SELECT * FROM `current` ORDER BY Rand() LIMIT 2;

 $result = mysql_query($randomQuery);
 $row[] = $result;   


 foreach($row as $key = $value) {
 $random[$key] = $value;

 }

 return $random;

 }//End of function


 ?

 Any ideas?




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



Re: [PHP] foreach question

2008-07-29 Thread Jason Pruim


On Jul 29, 2008, at 3:33 PM, Daniel Brown wrote:

On Tue, Jul 29, 2008 at 3:25 PM, Jason Pruim [EMAIL PROTECTED]  
wrote:


function random($random){

  $randomQuery = SELECT * FROM `current` ORDER BY Rand() LIMIT  
2;


  $result = mysql_query($randomQuery);
$row[] = $result;


foreach($row as $key = $value) {
$random[$key] = $value;

}

return $random;

}//End of function


?


   You're missing mysql_fetch_array(), mysql_fetch_assoc(), or
something of the like.

   Example:

?php
//  code

$result = mysql_query($randomQuery);
$row = mysql_fetch_array($result);

foreach($row as $k = $v) {
$random[$k] = $v;
}

//  code
}
?




Added that, then changed how I was calling it and it works great  
now... Thanks for looking... The problem was definitely between the  
chair and the keyboard on this one.





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



Re: [PHP] XML Encoding - with examples

2008-07-29 Thread Andrew Ballard
On Tue, Jul 29, 2008 at 3:52 PM, Thiago H. Pojda [EMAIL PROTECTED] wrote:
 That's weird. I just changed it to convert everything to UTF and things
 appear ok on IE and messy in Firefox. I guess firefox isn't been nice to my
 headers after all. It keeps saying the content is in ISO.

 Thanks for your hints and your time. I'll move this to firefox list, as the
 XML loads fine in IE (everything set to UTF, even the iconv is uncommented).


Did you change the header call too? The header in your original
example was ISO too:

header('Content-type: text/xml; charset = ISO-8859-1');

It should be:

header('Content-type: text/xml; charset=UTF-8');


Andrew

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



Re: [PHP] XML Encoding - with examples

2008-07-29 Thread Thiago H. Pojda
On Tue, Jul 29, 2008 at 4:59 PM, Andrew Ballard [EMAIL PROTECTED] wrote:

 On Tue, Jul 29, 2008 at 3:52 PM, Thiago H. Pojda [EMAIL PROTECTED]
 wrote:
  That's weird. I just changed it to convert everything to UTF and things
  appear ok on IE and messy in Firefox. I guess firefox isn't been nice to
 my
  headers after all. It keeps saying the content is in ISO.
 
  Thanks for your hints and your time. I'll move this to firefox list, as
 the
  XML loads fine in IE (everything set to UTF, even the iconv is
 uncommented).
 

 Did you change the header call too? The header in your original
 example was ISO too:

 snip


 Andrew


Here's the new code. Loads fine in other viewers, but firefox still think
it's a ISO file and loads accented chars incorrecly.

?php
header('Content-type: text/xml; charset = UTF-8');

$unidades = listarUnidadesSetor(58,1);

$doc = new DOMDocument(1.0, 'UTF-8');
$doc-formatOutput = true;

$xml = $doc-createElement( unidades );
$doc-appendChild( $xml );

foreach ($unidades as $unidade)
{
  $valores = get_object_vars($unidade);
  //var_dump($atributos);
  $unidade = $doc-createElement( unidade );
  foreach ($valores as $atributo=$valor){
$valor = iconv('ISO-8859-1','UTF-8',$valor);
$node = $doc-createElement( $atributo );
$node-appendChild(
$doc-createTextNode( $valor )
);
$unidade-appendChild( $node );
  }
  $xml-appendChild( $unidade );
}

$doc-appendChild( $xml );

echo $doc-saveXML();
?

-- 
Thiago Henrique Pojda


Re: [PHP] Programming With Revision History

2008-07-29 Thread VamVan
Hello,

Think in this way:

You would be needing two tables:

first one:

content table:

contentID, contentType, revisionID --- contentID is the PK ( you can
make the UI for adding and deleting these fields)

content_revisions table

revisionID, contentID, -- revisionID is the PK

Great things start from simple thinking. You can use this model to implement
revisions. In some PHP CMS we currently have they also use serialized data
fields for each revision.

--- Thanks


[PHP] limiting the amount of emails sent at a time in a batch send

2008-07-29 Thread Richard Kurth
I want to limit these script two send 100 email and then pause for a few 
seconds and then send another 100 emails and repeat this tell it has 
sent all the emails that are dated for today. This script is runs by 
cron so it is running in the background.


How would I do this and is it the best way to do it. I am using swift 
mailer to send the mail.


I think I would use limit 100 in the query but how would I tell it to 
get the next 100.


$today = date(Y-m-d);
# Cache the Contact that will recive campain messages today
$query = SELECT emailmessages. * , contacts.* FROM emailmessages, 
contacts WHERE emailmessages.contact_id = contacts.id  AND 
emailmessages.nextmessagedate = '$today' AND contacts.emailstatus = 
'Active';  
$DB_Contact_Result = mysql_query($query);

if (!$DB_Contact_Result) {
   die('Invalid query: ' . mysql_error());
}
while ($this_row = mysql_fetch_array ($DB_Contact_Result)){

$CustomerID=$this_row[id];

//get the message for the contact
$query1 = SELECT * FROM emailcampaign where member_id = 
'$this_row[members_id]' AND campaign_id = '$this_row[emailcampaign]' AND 
day = '$this_row[email_number]';


$DB_Mail_Result =  mysql_query($query1);
if (!$DB_Mail_Result) {
   die('Invalid query: ' . mysql_error());
}
$Mail_row = mysql_fetch_array($DB_Mail_Result);
//get member stuff
$query2 = SELECT * FROM member where members_id = 
'$this_row[members_id]';


$DB_Member_Result =  mysql_query($query2);
 if (!$DB_Member_Result) {
   die('Invalid query: ' . mysql_error());
}

$subject=stripslashes($Mail_row['subject']);

$message=stripslashes($Mail_row['textmessage']);

$hmessage=stripslashes($Mail_row['htmlmessage']);

$swiftPlain = $message;
$MailFrom1=$this_row['emailaddress'];
$MailFromName1=$this_row['firstname'];

$full_name=stripslashes($this_row['firstname']) .  . 
stripslashes($this_row['lastname']);

//Create the message
$message = new Swift_Message($subject);
$message-attach(new Swift_Message_Part($swiftPlain));
$message-attach(new Swift_Message_Part($swiftHtml, text/html));
$message-setReturnPath($MailAddReplyTo);
$message-setReplyTo($MailFrom1,$MailFromName1);
//Now check if Swift actually sends it
$swift-send($message, 
$this_row['emailaddress'],$MailFrom1,$MailFromName1);


#After we send the email we need to update the database to send the next 
message

# get the next message number
$nextday=getnextday(stripslashes($this_row['emailcampaign']),stripslashes($this_row['members_id']),stripslashes($this_row['email_number']));
# get the new dates
$newdate=getnewdate(stripslashes($this_row['emailstarted']),$nextday);
#update the emailmessages
//unsubscribecode
updateemailmessages($unpass,$nextday,$newdate,stripslashes($this_row['em_id']),stripslashes($this_row['email_number']));



}//end of mail loop


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



Re: [PHP] limiting the amount of emails sent at a time in a batch send

2008-07-29 Thread Andrew Ballard
On Tue, Jul 29, 2008 at 4:52 PM, Richard Kurth
[EMAIL PROTECTED] wrote:
 I want to limit these script two send 100 email and then pause for a few
 seconds and then send another 100 emails and repeat this tell it has sent
 all the emails that are dated for today. This script is runs by cron so it
 is running in the background.

 How would I do this and is it the best way to do it. I am using swift mailer
 to send the mail.

 I think I would use limit 100 in the query but how would I tell it to get
 the next 100.

 $today = date(Y-m-d);
 # Cache the Contact that will recive campain messages today
 $query = SELECT emailmessages. * , contacts.* FROM emailmessages, contacts
 WHERE emailmessages.contact_id = contacts.id  AND
 emailmessages.nextmessagedate = '$today' AND contacts.emailstatus =
 'Active';  $DB_Contact_Result = mysql_query($query);
 if (!$DB_Contact_Result) {
   die('Invalid query: ' . mysql_error());
 }
 while ($this_row = mysql_fetch_array ($DB_Contact_Result)){

 $CustomerID=$this_row[id];

 //get the message for the contact
 $query1 = SELECT * FROM emailcampaign where member_id =
 '$this_row[members_id]' AND campaign_id = '$this_row[emailcampaign]' AND day
 = '$this_row[email_number]';

$DB_Mail_Result =  mysql_query($query1);
if (!$DB_Mail_Result) {
   die('Invalid query: ' . mysql_error());
 }
$Mail_row = mysql_fetch_array($DB_Mail_Result);
//get member stuff
$query2 = SELECT * FROM member where members_id =
 '$this_row[members_id]';

$DB_Member_Result =  mysql_query($query2);
 if (!$DB_Member_Result) {
   die('Invalid query: ' . mysql_error());
 }

 $subject=stripslashes($Mail_row['subject']);

 $message=stripslashes($Mail_row['textmessage']);

 $hmessage=stripslashes($Mail_row['htmlmessage']);

 $swiftPlain = $message;
 $MailFrom1=$this_row['emailaddress'];
 $MailFromName1=$this_row['firstname'];

 $full_name=stripslashes($this_row['firstname']) .  .
 stripslashes($this_row['lastname']);
 //Create the message
 $message = new Swift_Message($subject);
 $message-attach(new Swift_Message_Part($swiftPlain));
 $message-attach(new Swift_Message_Part($swiftHtml, text/html));
 $message-setReturnPath($MailAddReplyTo);
 $message-setReplyTo($MailFrom1,$MailFromName1);
 //Now check if Swift actually sends it
 $swift-send($message, $this_row['emailaddress'],$MailFrom1,$MailFromName1);

 #After we send the email we need to update the database to send the next
 message
 # get the next message number
 $nextday=getnextday(stripslashes($this_row['emailcampaign']),stripslashes($this_row['members_id']),stripslashes($this_row['email_number']));
 # get the new dates
 $newdate=getnewdate(stripslashes($this_row['emailstarted']),$nextday);
 #update the emailmessages
 //unsubscribecode
 updateemailmessages($unpass,$nextday,$newdate,stripslashes($this_row['em_id']),stripslashes($this_row['email_number']));



 }//end of mail loop


I've done something very similar. I have a delivery timestamp column
in the table that is initially NULL, and I set it to UTC_TIMESTAMP()
for each row as I send the message. My query looks like this then:

SELECT * FROM mail_queue WHERE delivery_timestamp IS NULL LIMIT 100.

Andrew

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



Re: [PHP] limiting the amount of emails sent at a time in a batch send

2008-07-29 Thread Richard Kurth

Andrew Ballard wrote:

On Tue, Jul 29, 2008 at 4:52 PM, Richard Kurth
[EMAIL PROTECTED] wrote:
  

I want to limit these script two send 100 email and then pause for a few
seconds and then send another 100 emails and repeat this tell it has sent
all the emails that are dated for today. This script is runs by cron so it
is running in the background.

How would I do this and is it the best way to do it. I am using swift mailer
to send the mail.

I think I would use limit 100 in the query but how would I tell it to get
the next 100.

$today = date(Y-m-d);
# Cache the Contact that will recive campain messages today
$query = SELECT emailmessages. * , contacts.* FROM emailmessages, contacts
WHERE emailmessages.contact_id = contacts.id  AND
emailmessages.nextmessagedate = '$today' AND contacts.emailstatus =
'Active';  $DB_Contact_Result = mysql_query($query);
if (!$DB_Contact_Result) {
  die('Invalid query: ' . mysql_error());
}
while ($this_row = mysql_fetch_array ($DB_Contact_Result)){

$CustomerID=$this_row[id];

//get the message for the contact
$query1 = SELECT * FROM emailcampaign where member_id =
'$this_row[members_id]' AND campaign_id = '$this_row[emailcampaign]' AND day
= '$this_row[email_number]';

   $DB_Mail_Result =  mysql_query($query1);
   if (!$DB_Mail_Result) {
  die('Invalid query: ' . mysql_error());
}
   $Mail_row = mysql_fetch_array($DB_Mail_Result);
   //get member stuff
   $query2 = SELECT * FROM member where members_id =
'$this_row[members_id]';

   $DB_Member_Result =  mysql_query($query2);
if (!$DB_Member_Result) {
  die('Invalid query: ' . mysql_error());
}

$subject=stripslashes($Mail_row['subject']);

$message=stripslashes($Mail_row['textmessage']);

$hmessage=stripslashes($Mail_row['htmlmessage']);

$swiftPlain = $message;
$MailFrom1=$this_row['emailaddress'];
$MailFromName1=$this_row['firstname'];

$full_name=stripslashes($this_row['firstname']) .  .
stripslashes($this_row['lastname']);
//Create the message
$message = new Swift_Message($subject);
$message-attach(new Swift_Message_Part($swiftPlain));
$message-attach(new Swift_Message_Part($swiftHtml, text/html));
$message-setReturnPath($MailAddReplyTo);
$message-setReplyTo($MailFrom1,$MailFromName1);
//Now check if Swift actually sends it
$swift-send($message, $this_row['emailaddress'],$MailFrom1,$MailFromName1);

#After we send the email we need to update the database to send the next
message
# get the next message number
$nextday=getnextday(stripslashes($this_row['emailcampaign']),stripslashes($this_row['members_id']),stripslashes($this_row['email_number']));
# get the new dates
$newdate=getnewdate(stripslashes($this_row['emailstarted']),$nextday);
#update the emailmessages
//unsubscribecode
updateemailmessages($unpass,$nextday,$newdate,stripslashes($this_row['em_id']),stripslashes($this_row['email_number']));



}//end of mail loop




I've done something very similar. I have a delivery timestamp column
in the table that is initially NULL, and I set it to UTC_TIMESTAMP()
for each row as I send the message. My query looks like this then:

SELECT * FROM mail_queue WHERE delivery_timestamp IS NULL LIMIT 100.

Andrew

  

Then what do you do to get the next 100 emails without sending the same ones

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



Re: [PHP] limiting the amount of emails sent at a time in a batch send

2008-07-29 Thread Micah Gersten
Here's a PEAR package that handles this:
http://pear.php.net/package/Mail_Queue/

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Richard Kurth wrote:
 I want to limit these script two send 100 email and then pause for a
 few seconds and then send another 100 emails and repeat this tell it
 has sent all the emails that are dated for today. This script is runs
 by cron so it is running in the background.

 How would I do this and is it the best way to do it. I am using swift
 mailer to send the mail.

 I think I would use limit 100 in the query but how would I tell it to
 get the next 100.

 $today = date(Y-m-d);
 # Cache the Contact that will recive campain messages today
 $query = SELECT emailmessages. * , contacts.* FROM emailmessages,
 contacts WHERE emailmessages.contact_id = contacts.id  AND
 emailmessages.nextmessagedate = '$today' AND contacts.emailstatus =
 'Active';  $DB_Contact_Result = mysql_query($query);
 if (!$DB_Contact_Result) {
die('Invalid query: ' . mysql_error());
 }
 while ($this_row = mysql_fetch_array ($DB_Contact_Result)){

 $CustomerID=$this_row[id];

 //get the message for the contact
 $query1 = SELECT * FROM emailcampaign where member_id =
 '$this_row[members_id]' AND campaign_id = '$this_row[emailcampaign]'
 AND day = '$this_row[email_number]';

 $DB_Mail_Result =  mysql_query($query1);
 if (!$DB_Mail_Result) {
die('Invalid query: ' . mysql_error());
 }
 $Mail_row = mysql_fetch_array($DB_Mail_Result);
 //get member stuff
 $query2 = SELECT * FROM member where members_id =
 '$this_row[members_id]';

 $DB_Member_Result =  mysql_query($query2);
  if (!$DB_Member_Result) {
die('Invalid query: ' . mysql_error());
 }

 $subject=stripslashes($Mail_row['subject']);

 $message=stripslashes($Mail_row['textmessage']);

 $hmessage=stripslashes($Mail_row['htmlmessage']);

 $swiftPlain = $message;
 $MailFrom1=$this_row['emailaddress'];
 $MailFromName1=$this_row['firstname'];

 $full_name=stripslashes($this_row['firstname']) .  .
 stripslashes($this_row['lastname']);
 //Create the message
 $message = new Swift_Message($subject);
 $message-attach(new Swift_Message_Part($swiftPlain));
 $message-attach(new Swift_Message_Part($swiftHtml, text/html));
 $message-setReturnPath($MailAddReplyTo);
 $message-setReplyTo($MailFrom1,$MailFromName1);
 //Now check if Swift actually sends it
 $swift-send($message,
 $this_row['emailaddress'],$MailFrom1,$MailFromName1);

 #After we send the email we need to update the database to send the
 next message
 # get the next message number
 $nextday=getnextday(stripslashes($this_row['emailcampaign']),stripslashes($this_row['members_id']),stripslashes($this_row['email_number']));

 # get the new dates
 $newdate=getnewdate(stripslashes($this_row['emailstarted']),$nextday);
 #update the emailmessages
 //unsubscribecode
 updateemailmessages($unpass,$nextday,$newdate,stripslashes($this_row['em_id']),stripslashes($this_row['email_number']));




 }//end of mail loop



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



Re: [PHP] limiting the amount of emails sent at a time in a batch send

2008-07-29 Thread Stephen

I would use a temporary table to hold all the email created in one job.

Have a status field marked as sent, waiting or open.

Have a cron job set 'x' number of open emails to waiting. Execute 
periodically.
Have a cron job to send all waiting email and update status to sent. 
Execute periodically.


Stephen

Richard Kurth wrote:
I want to limit these script two send 100 email and then pause for a 
few seconds and then send another 100 emails and repeat this tell it 
has sent all the emails that are dated for today. This script is runs 
by cron so it is running in the background.


How would I do this and is it the best way to do it. I am using swift 
mailer to send the mail.


I think I would use limit 100 in the query but how would I tell it to 
get the next 100.


$today = date(Y-m-d);
# Cache the Contact that will recive campain messages today
$query = SELECT emailmessages. * , contacts.* FROM emailmessages, 
contacts WHERE emailmessages.contact_id = contacts.id  AND 
emailmessages.nextmessagedate = '$today' AND contacts.emailstatus = 
'Active';  $DB_Contact_Result = mysql_query($query);

if (!$DB_Contact_Result) {
   die('Invalid query: ' . mysql_error());
}
while ($this_row = mysql_fetch_array ($DB_Contact_Result)){

$CustomerID=$this_row[id];

//get the message for the contact
$query1 = SELECT * FROM emailcampaign where member_id = 
'$this_row[members_id]' AND campaign_id = '$this_row[emailcampaign]' 
AND day = '$this_row[email_number]';


$DB_Mail_Result =  mysql_query($query1);
if (!$DB_Mail_Result) {
   die('Invalid query: ' . mysql_error());
}
$Mail_row = mysql_fetch_array($DB_Mail_Result);
//get member stuff
$query2 = SELECT * FROM member where members_id = 
'$this_row[members_id]';


$DB_Member_Result =  mysql_query($query2);
 if (!$DB_Member_Result) {
   die('Invalid query: ' . mysql_error());
}

$subject=stripslashes($Mail_row['subject']);

$message=stripslashes($Mail_row['textmessage']);

$hmessage=stripslashes($Mail_row['htmlmessage']);

$swiftPlain = $message;
$MailFrom1=$this_row['emailaddress'];
$MailFromName1=$this_row['firstname'];

$full_name=stripslashes($this_row['firstname']) .  . 
stripslashes($this_row['lastname']);

//Create the message
$message = new Swift_Message($subject);
$message-attach(new Swift_Message_Part($swiftPlain));
$message-attach(new Swift_Message_Part($swiftHtml, text/html));
$message-setReturnPath($MailAddReplyTo);
$message-setReplyTo($MailFrom1,$MailFromName1);
//Now check if Swift actually sends it
$swift-send($message, 
$this_row['emailaddress'],$MailFrom1,$MailFromName1);


#After we send the email we need to update the database to send the 
next message

# get the next message number
$nextday=getnextday(stripslashes($this_row['emailcampaign']),stripslashes($this_row['members_id']),stripslashes($this_row['email_number'])); 


# get the new dates
$newdate=getnewdate(stripslashes($this_row['emailstarted']),$nextday);
#update the emailmessages
//unsubscribecode
updateemailmessages($unpass,$nextday,$newdate,stripslashes($this_row['em_id']),stripslashes($this_row['email_number'])); 





}//end of mail loop





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



Re: [PHP] Why PHP4?

2008-07-29 Thread VamVan
Its because PHP got really famous with version 4.0 and many people actually
converted their CGI or other websites in to PHP 4 websites because it was
easy and cheap. But 5.0 brought too many changes like serious OOPS and
register global concepts for security, which is useful but made transition
difficult. I feel thats why PHP 4 is still supported.

Its not only the language that has changed, but also people had to upgrade
their skill set and there was some learning curve involved.

Unfortunately everyone fell in the trap of register globals which was not
dealt until php 4.3.1 as a security concept. Pear and Pecl were there but
everyone was pretty much writing all the code (reinventing the wheel) from
scratch. This brings in huge code base to change.

I liked PHP because intitially it was a procedural langauge and it resembled
C. But now with OOPS you can build powerful websites which is good.

There are many other  cases but I feel strongly this is what makes them
still support PHP 4.

Thanks


Re: [PHP] Why PHP4?

2008-07-29 Thread mike
I started using superglobals since 4.x; not even thinking about it  
from a security angle per se, but because it just makes sense to know  
the source of where your input data is coming from. I guess  
technically security is a byproduct of that thinking too.




On Jul 29, 2008, at 7:31 PM, VamVan [EMAIL PROTECTED] wrote:

Its because PHP got really famous with version 4.0 and many people  
actually converted their CGI or other websites in to PHP 4 websites  
because it was easy and cheap. But 5.0 brought too many changes like  
serious OOPS and register global concepts for security, which is  
useful but made transition difficult. I feel thats why PHP 4 is  
still supported.


Its not only the language that has changed, but also people had to  
upgrade their skill set and there was some learning curve involved.


Unfortunately everyone fell in the trap of register globals which  
was not dealt until php 4.3.1 as a security concept. Pear and Pecl  
were there but everyone was pretty much writing all the code  
(reinventing the wheel) from scratch. This brings in huge code base  
to change.


I liked PHP because intitially it was a procedural langauge and it  
resembled C. But now with OOPS you can build powerful websites which  
is good.


There are many other  cases but I feel strongly this is what makes  
them still support PHP 4.


Thanks


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



Re: [PHP] Why PHP4?

2008-07-29 Thread VamVan
I agree but not everyone think in the sameway. I have seen several big
websites that got hit because they haven't used super globals in the code
and their hosting provided would just change the PHP.ini setting and nothing
would work.

GET, POST , SESSION, REQUEST everything was all dealt as just variable.

On Tue, Jul 29, 2008 at 7:36 PM, mike [EMAIL PROTECTED] wrote:

 I started using superglobals since 4.x; not even thinking about it from a
 security angle per se, but because it just makes sense to know the source of
 where your input data is coming from. I guess technically security is a
 byproduct of that thinking too.




 On Jul 29, 2008, at 7:31 PM, VamVan [EMAIL PROTECTED] wrote:

  Its because PHP got really famous with version 4.0 and many people
 actually converted their CGI or other websites in to PHP 4 websites because
 it was easy and cheap. But 5.0 brought too many changes like serious OOPS
 and register global concepts for security, which is useful but made
 transition difficult. I feel thats why PHP 4 is still supported.

 Its not only the language that has changed, but also people had to upgrade
 their skill set and there was some learning curve involved.

 Unfortunately everyone fell in the trap of register globals which was not
 dealt until php 4.3.1 as a security concept. Pear and Pecl were there but
 everyone was pretty much writing all the code (reinventing the wheel) from
 scratch. This brings in huge code base to change.

 I liked PHP because intitially it was a procedural langauge and it
 resembled C. But now with OOPS you can build powerful websites which is
 good.

 There are many other  cases but I feel strongly this is what makes them
 still support PHP 4.

 Thanks




Re: [PHP] PHP4 vs PHP5 classes

2008-07-29 Thread Chris

 Don't forget that in PHP5, the constructor named has changed.  In PHP4
 it called a method with the same name as the class.  But, in PHP5, it
 looks for __construct() instead.

If __construct doesn't exist then it falls back to the php4 way - makes
it backwards compatible :)

-- 
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] PHP4 vs PHP5 classes

2008-07-29 Thread Jim Lucas

Chris wrote:

Don't forget that in PHP5, the constructor named has changed.  In PHP4
it called a method with the same name as the class.  But, in PHP5, it
looks for __construct() instead.


If __construct doesn't exist then it falls back to the php4 way - makes
it backwards compatible :)



But, if people want to code to php5 standards and beyond, then I would 
recommend always using the __construct() method to construct your class. 
 Then make it work in php4.  Not the other way around.


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



Re: [PHP] PHP4 vs PHP5 classes

2008-07-29 Thread Robert Cummings
On Tue, 2008-07-29 at 22:26 -0700, Jim Lucas wrote:
 Chris wrote:
  Don't forget that in PHP5, the constructor named has changed.  In PHP4
  it called a method with the same name as the class.  But, in PHP5, it
  looks for __construct() instead.
  
  If __construct doesn't exist then it falls back to the php4 way - makes
  it backwards compatible :)
  
 
 But, if people want to code to php5 standards and beyond, then I would 
 recommend always using the __construct() method to construct your class. 
   Then make it work in php4.  Not the other way around.

It's unfortunate that PHP5 decided to throw a Strict Standards exception
when you include both style constructors. For instance, I'm certain at
one point the following was recommended:

?php
class Foo
{
function __construct()
{
}

function Foo()
{
self::__construct();
}
}
?

This was perfectly compatible with PHP5 and gave precedence to the PHP5
constructor style. Somewhere along the line though PHP5 started
spouting:

Strict Standards: Redefining already defined constructor

So I just completely removed the PHP5 style constructors from my code
and use the PHP4 style since then there are no exceptions. Mark my words
though... at some point PHP will start spewing an E_DEPRECATED for PHP4
style constructor *lol*.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] limiting the amount of emails sent at a time in a batch send

2008-07-29 Thread Chris

 I've done something very similar. I have a delivery timestamp column
 in the table that is initially NULL, and I set it to UTC_TIMESTAMP()
 for each row as I send the message. My query looks like this then:

 SELECT * FROM mail_queue WHERE delivery_timestamp IS NULL LIMIT 100.

 Andrew

   
 Then what do you do to get the next 100 emails without sending the same
 ones

Re-read the reply.

After each email is sent, the timestamp is set.

The original query looks for timestamp fields that are not set.

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

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