php-general Digest 20 May 2007 12:01:09 -0000 Issue 4801

2007-05-20 Thread php-general-digest-help

php-general Digest 20 May 2007 12:01:09 - Issue 4801

Topics (messages 255238 through 255247):

Adserver programming with php
255238 by: Merlin
255239 by: Davi
255240 by: Jim Lucas
255241 by: Al
255242 by: Larry Garfield
255243 by: itoctopus

can not fork
255244 by: Rajiv Man Karmacharya

PHP Data Mining/Data Scraping
255245 by: Shannon Whitty

Marketplace Framework
255246 by: PHP Mailing List
255247 by: PHP Mailing List

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---

Hi there,

I am thinking about creating a kind of adserver which is customized for 
my needs. As I would be most confident in doing this with php, I am 
asking myself if this is the right choice or if it would be wiser to 
take a C++ aproach for example to get a higher performance just in case 
the site grows fast.
Do you guys think that a php build webserver would be able to scale and 
perform well enough for serving millions of adimpressions daily?


Thank you for any advice,

Merlin
---End Message---
---BeginMessage---
Em Sábado 19 Maio 2007 21:15, Merlin escreveu:
 I am thinking about creating a kind of adserver which is customized for
 my needs. As I would be most confident in doing this with php, I am
 asking myself if this is the right choice or if it would be wiser to
 take a C++ aproach for example to get a higher performance just in case
 the site grows fast.
 Do you guys think that a php build webserver would be able to scale and
 perform well enough for serving millions of adimpressions daily?


IIRC, AFAIK, using PHP or C or Java or C++ or anything else, your webserver 
will do all the dirty work...

If you'd portuguese skills, read [1], otherwise, I'll recomend you to build 
careful your server... And just put Web server (i.e. Apache) on it... DB 
server, mail server and other server must be in other machines...
Build careful means: use a _good_ Linux distro... If you can use Gentoo [2], 
you'll get better results...

[1] - http://archives.gentoo.org/gentoo-user-br/msg_11719.xml
[2] - www.gentoo.org

HTH


-- 
Davi Vidal
[EMAIL PROTECTED]
[EMAIL PROTECTED]
--
Religion, ideology, resources, land,
spite, love or just because...
No matter how pathetic the reason,
it's enough to start a war. 


pgpiTOQAv61sN.pgp
Description: PGP signature
---End Message---
---BeginMessage---

Merlin wrote:

Hi there,

I am thinking about creating a kind of adserver which is customized for 
my needs. As I would be most confident in doing this with php, I am 
asking myself if this is the right choice or if it would be wiser to 
take a C++ aproach for example to get a higher performance just in case 
the site grows fast.
Do you guys think that a php build webserver would be able to scale and 
perform well enough for serving millions of adimpressions daily?


Thank you for any advice,

Merlin



Just build the darn thing.

It is a simple script, if you find that performance is an issue, then 
change your approach.


You can't tell me that your site will explode in usage over night and 
you wont get the chance to change your design before things get out of hand.


--
Jim Lucas

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

Unknown
---End Message---
---BeginMessage---

Use php and get the site on the air ASAP, so it generates revenue.

You can a quickly and cheaply upgrade the hardware if the need arises.  The OS and webserver software will probably make 
a bigger difference.  Seems like I recall someone said Google and Yahoo use PHP.


Merlin wrote:

Hi there,

I am thinking about creating a kind of adserver which is customized for 
my needs. As I would be most confident in doing this with php, I am 
asking myself if this is the right choice or if it would be wiser to 
take a C++ aproach for example to get a higher performance just in case 
the site grows fast.
Do you guys think that a php build webserver would be able to scale and 
perform well enough for serving millions of adimpressions daily?


Thank you for any advice,

Merlin
---End Message---
---BeginMessage---
Google is a Python shop primarily, but Yahoo employs a good chunk of the PHP 
internals development team, like Rasmus and Sara Goleman.  They do a ton with 
PHP.

On Saturday 19 May 2007, Al wrote:
 Use php and get the site on the air ASAP, so it generates revenue.

 You can a quickly and cheaply upgrade the hardware if the need arises.  The
 OS and webserver software will probably make a bigger difference.  Seems
 like I recall someone said Google and Yahoo use PHP.

 Merlin wrote:
  Hi there,
 
  I am thinking about creating a kind of adserver which is customized for
  my needs. As I would be most 

php-general Digest 21 May 2007 01:15:29 -0000 Issue 4802

2007-05-20 Thread php-general-digest-help

php-general Digest 21 May 2007 01:15:29 - Issue 4802

Topics (messages 255248 through 255260):

Re: PHP Data Mining/Data Scraping
255248 by: Johan Holst Nielsen
255249 by: Stut
255252 by: itoctopus

Re: Marketplace Framework
255250 by: Stut
255251 by: itoctopus

inconsistency in SimpleXML
255253 by: Vesselin Kenashkov

Re: Adserver programming with php
255254 by: Colin Guthrie
255258 by: WeberSites LTD

php5 cert
255255 by: Danial Rahmanzadeh
255257 by: Larry Garfield

Re: showing source
255256 by: tedd

Re: can not fork
255259 by: Jochem Maas

Confused about handling bytes
255260 by: Joe Veldhuis

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---

Shannon Whitty wrote:

Hi,

I'm looking for a piece of software or coding that will let me post a form 
to another URL, accept the response, search it for a specific success 
string and then let me continue processing the rest of my program.


I want to accept queries on behalf of my supplier, forward it to them behind 
the scenes, accept their response and display it within my website.


Has anyone had any experience with this?  Is there a simple, basic utility 
to let me do this?


I was kind of hoping I could avoid developing it myself.


cURL should be able to help you with that :)

www.php.net/curl

--
Johan Holst Nielsen
Freelance PHP Developer - http://phpgeek.dk
---End Message---
---BeginMessage---

Shannon Whitty wrote:

Hi,

I'm looking for a piece of software or coding that will let me post a form 
to another URL, accept the response, search it for a specific success 
string and then let me continue processing the rest of my program.


I want to accept queries on behalf of my supplier, forward it to them behind 
the scenes, accept their response and display it within my website.


Has anyone had any experience with this?  Is there a simple, basic utility 
to let me do this?


I was kind of hoping I could avoid developing it myself.


http://php.net/curl

-Stut
---End Message---
---BeginMessage---
In case you have no control on the other URL, then CURL is probably your 
best solution.
Otherwise, a better way to do it is probably to interact with a web service 
installed on the other website.

-- 
itoctopus - http://www.itoctopus.com
Shannon Whitty [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Hi,

 I'm looking for a piece of software or coding that will let me post a form 
 to another URL, accept the response, search it for a specific success 
 string and then let me continue processing the rest of my program.

 I want to accept queries on behalf of my supplier, forward it to them 
 behind the scenes, accept their response and display it within my website.

 Has anyone had any experience with this?  Is there a simple, basic utility 
 to let me do this?

 I was kind of hoping I could avoid developing it myself.

 Thanks
 Shannon 
---End Message---
---BeginMessage---

PHP Mailing List wrote:

Is there any PHP's framework for developing a marketplace site ?


Not totally sure what you mean by a marketplace site, but if you mean 
an ecommerce site (online shop) then please search the list archives - 
this topic comes up a lot here and has been discussed at length.


-Stut
---End Message---
---BeginMessage---
Try osCommerce

-- 
itoctopus - http://www.itoctopus.com
PHP Mailing List [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Hi All,

 Is there any PHP's framework for developing a marketplace site ?

 Regards,

 Dino 
---End Message---
---BeginMessage---

Hello everybody,

An year ago I was playing with the SimpleXML in php and found some issues
and abandoned php5 for a year. Now I'm back to it and I found that the
issius are still there.

Here is the first one - how one can find does a SimpleXMLElement has child
nodes?
Here is an example:

$str = 'rootnodesubnode/subnode/rootnode';
$x = new SimpleXMLElement($str);

if($x-subnode-children())
   print 'yes';
   else
   print 'no';
-
will print 'no';

If the
$str='rootnodesubnodenewnode/newnode/subnode/rootnode';
it will print yes.
But the same will happen if the subnode has an attribute like:
$str = 'rootnodesubnode id=2/subnode/rootnode';

But if we use foreach($x-subnode-children() as $key=$value)
in the latter example we will not get anything.
I think is wrong the children() method to return object when there are no
child objects and the node has attributes.

The workaround I use is to extend the SimpleXMLElement

class SimpleXMLElement2 extends SimpleXMLElement
{
public function has_children()
   {
   foreach($this-children() as $node)
   return true;
   return false;
   }

}
--
And then we can 

[PHP] Re: Adserver programming with php

2007-05-20 Thread itoctopus
My approach would be to build now using the fastest way and get the thing up 
 running, and then see if the needs arise to build the application using a 
somehow slower way.

-- 
itoctopus - http://www.itoctopus.com
Merlin [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Hi there,

 I am thinking about creating a kind of adserver which is customized for my 
 needs. As I would be most confident in doing this with php, I am asking 
 myself if this is the right choice or if it would be wiser to take a C++ 
 aproach for example to get a higher performance just in case the site 
 grows fast.
 Do you guys think that a php build webserver would be able to scale and 
 perform well enough for serving millions of adimpressions daily?

 Thank you for any advice,

 Merlin 

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



[PHP] can not fork

2007-05-20 Thread Rajiv Man Karmacharya
php-general@lists.php.net

while trying to use exec('IECapt.exe ' . escapeshellarg($website_url) . ' ' . 
escapeshellarg($cached_filename)); i get the following error

Warning: exec() [function.exec]: Unable to fork [IECapt.exe 
http://www.nepalnews.com.np; 
C:/Inetpub/wwwroot/5531ed95934bee318939d9270b2db620.png] ...

This piece of code is from 
http://www.zubrag.com/scripts/website-thumbnail-generator.php

I couldn't figure out why this Unable to fork is occuring. I search php.net as 
well and it says, it might be related to permission issues.

I'm using winxp and iis.

I hope someone would help me with this.

Regards
Rajiv

[PHP] PHP Data Mining/Data Scraping

2007-05-20 Thread Shannon Whitty
Hi,

I'm looking for a piece of software or coding that will let me post a form 
to another URL, accept the response, search it for a specific success 
string and then let me continue processing the rest of my program.

I want to accept queries on behalf of my supplier, forward it to them behind 
the scenes, accept their response and display it within my website.

Has anyone had any experience with this?  Is there a simple, basic utility 
to let me do this?

I was kind of hoping I could avoid developing it myself.

Thanks
Shannon 

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



[PHP] Marketplace Framework

2007-05-20 Thread PHP Mailing List

Hi All,

Is there any PHP's framework for developing a marketplace site ?

Regards,

Dino

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



[PHP] Marketplace Framework

2007-05-20 Thread PHP Mailing List

Hi All,

Is there any PHP's framework for developing a marketplace site ?

Regards,

Dino

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



[PHP] Re: PHP Data Mining/Data Scraping

2007-05-20 Thread Johan Holst Nielsen

Shannon Whitty wrote:

Hi,

I'm looking for a piece of software or coding that will let me post a form 
to another URL, accept the response, search it for a specific success 
string and then let me continue processing the rest of my program.


I want to accept queries on behalf of my supplier, forward it to them behind 
the scenes, accept their response and display it within my website.


Has anyone had any experience with this?  Is there a simple, basic utility 
to let me do this?


I was kind of hoping I could avoid developing it myself.


cURL should be able to help you with that :)

www.php.net/curl

--
Johan Holst Nielsen
Freelance PHP Developer - http://phpgeek.dk

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



Re: [PHP] PHP Data Mining/Data Scraping

2007-05-20 Thread Stut

Shannon Whitty wrote:

Hi,

I'm looking for a piece of software or coding that will let me post a form 
to another URL, accept the response, search it for a specific success 
string and then let me continue processing the rest of my program.


I want to accept queries on behalf of my supplier, forward it to them behind 
the scenes, accept their response and display it within my website.


Has anyone had any experience with this?  Is there a simple, basic utility 
to let me do this?


I was kind of hoping I could avoid developing it myself.


http://php.net/curl

-Stut

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



Re: [PHP] Marketplace Framework

2007-05-20 Thread Stut

PHP Mailing List wrote:

Is there any PHP's framework for developing a marketplace site ?


Not totally sure what you mean by a marketplace site, but if you mean 
an ecommerce site (online shop) then please search the list archives - 
this topic comes up a lot here and has been discussed at length.


-Stut

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



[PHP] Re: Marketplace Framework

2007-05-20 Thread itoctopus
Try osCommerce

-- 
itoctopus - http://www.itoctopus.com
PHP Mailing List [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Hi All,

 Is there any PHP's framework for developing a marketplace site ?

 Regards,

 Dino 

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



[PHP] Re: PHP Data Mining/Data Scraping

2007-05-20 Thread itoctopus
In case you have no control on the other URL, then CURL is probably your 
best solution.
Otherwise, a better way to do it is probably to interact with a web service 
installed on the other website.

-- 
itoctopus - http://www.itoctopus.com
Shannon Whitty [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Hi,

 I'm looking for a piece of software or coding that will let me post a form 
 to another URL, accept the response, search it for a specific success 
 string and then let me continue processing the rest of my program.

 I want to accept queries on behalf of my supplier, forward it to them 
 behind the scenes, accept their response and display it within my website.

 Has anyone had any experience with this?  Is there a simple, basic utility 
 to let me do this?

 I was kind of hoping I could avoid developing it myself.

 Thanks
 Shannon 

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



[PHP] inconsistency in SimpleXML

2007-05-20 Thread Vesselin Kenashkov

Hello everybody,

An year ago I was playing with the SimpleXML in php and found some issues
and abandoned php5 for a year. Now I'm back to it and I found that the
issius are still there.

Here is the first one - how one can find does a SimpleXMLElement has child
nodes?
Here is an example:

$str = 'rootnodesubnode/subnode/rootnode';
$x = new SimpleXMLElement($str);

if($x-subnode-children())
   print 'yes';
   else
   print 'no';
-
will print 'no';

If the
$str='rootnodesubnodenewnode/newnode/subnode/rootnode';
it will print yes.
But the same will happen if the subnode has an attribute like:
$str = 'rootnodesubnode id=2/subnode/rootnode';

But if we use foreach($x-subnode-children() as $key=$value)
in the latter example we will not get anything.
I think is wrong the children() method to return object when there are no
child objects and the node has attributes.

The workaround I use is to extend the SimpleXMLElement

class SimpleXMLElement2 extends SimpleXMLElement
{
public function has_children()
   {
   foreach($this-children() as $node)
   return true;
   return false;
   }

}
--
And then we can check with if($x-subnode-has_children())



Issue #2:
Xpath on nodes.
Let we have the example:
-
$str =
'rootnodelevel1_node1level2_node1/level2_node1/level1_node1level1_node2/level1_node2/rootnode';
$x = new SimpleXMLElement($str);

$r1 = $x-xpath('/*');
print $r1[0]-getName();//prints rootnode

$r2 = $x-level1_node1[0]-xpath('/*');
print $r2[0]-getName();//prints rootnode

$z = clone $x-level1_node1[0];
$r3 = $z-xpath('/*');
print $r3[0]-getName();//prints rootnode

//print $z-getName();//ok
--
I personally think that the xpath must be evaluated against the node which
method is called, not always against the rootnode.
So in the second example I would expect it to return level1_node1, and
especially in the thirds example.
Even in the third example the xpath is evaluated against the original XML
structure, not the subnode (level1_node1).
I think this is incorrect and leads to a confusion - for example we can pass
a node to a function like:

function do_something($node)
   {
   //print $node-getName();//prints correct - the name of the supplied
node - level1_node1
   $r1 = $node-xpath('/*');
   print $r1[0]-getName();
   }

do_something(clone $x-level1_node1[0]);

The do_something function is not aware at all about the full xml structure
and one could think that the expression will be evaluated just against the
supplied node, but it is not that the case.
And I do not have a workaround for that for the moment.
Any comments, solutions, and opinions about that SimpleXML functionality are
welcome.

Vesselin Kenashkov


[PHP] Re: Adserver programming with php

2007-05-20 Thread Colin Guthrie
Merlin wrote:
 Hi there,
 
 I am thinking about creating a kind of adserver which is customized for
 my needs. As I would be most confident in doing this with php, I am
 asking myself if this is the right choice or if it would be wiser to
 take a C++ aproach for example to get a higher performance just in case
 the site grows fast.
 Do you guys think that a php build webserver would be able to scale and
 perform well enough for serving millions of adimpressions daily?

Depending on your needs and the license etc. you could take a look at
phpadsnew or (after quick google) OpenAds as it is now called:

http://www.openads.org/

Perhaps customising that code will save you some time?

Col.

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



[PHP] php5 cert

2007-05-20 Thread Danial Rahmanzadeh

are volcan exams really harder than actual php5 exam as phparch asserted?


Re: [PHP] Re: showing source

2007-05-20 Thread tedd

At 12:16 PM +0200 5/18/07, Christian Haensel wrote:

Why don't you use:
highlight_file(__FILE__) ?


OMG

I have been coding that thing for MONTHS now... 
just to get syntax highlighting for my tutorial 
blog... maybe I shouldn't write tutorials... 
maybe I should rather read them *g*


Thanks for this short, but awesome answer :o) I 
wasn't the one asking the question, but 
nonetheless you have just wrecked my weekend :oP 
If I could kick my own rear end, I would do 
so´for the next two days...


Cheers mate, and have a great weekend!

Chris


Chris:

There might come a time where you do not want to 
show ALL of the inter-workings of your script, if 
so, then please review this:


http://sperling.com/a/show-code/

Cheers,

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] php5 cert

2007-05-20 Thread Larry Garfield
Actually I found the real exam harder than the test exam.  It may have just 
been the question set I ended up with, but it was a lot more nitpicky on 
details that I rarely use in my work.

On Sunday 20 May 2007, Danial Rahmanzadeh wrote:
 are volcan exams really harder than actual php5 exam as phparch asserted?


-- 
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]   ICQ: 6817012

If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it.  -- Thomas 
Jefferson

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



RE: [PHP] Adserver programming with php

2007-05-20 Thread WeberSites LTD
Not sure why you would want to build something from scratch when you can use

Openads : http://www.openads.org/

berber 

-Original Message-
From: Merlin [mailto:[EMAIL PROTECTED] 
Sent: Sunday, May 20, 2007 2:16 AM
To: php-general@lists.php.net
Subject: [PHP] Adserver programming with php

Hi there,

I am thinking about creating a kind of adserver which is customized for my
needs. As I would be most confident in doing this with php, I am asking
myself if this is the right choice or if it would be wiser to take a C++
aproach for example to get a higher performance just in case the site grows
fast.
Do you guys think that a php build webserver would be able to scale and
perform well enough for serving millions of adimpressions daily?

Thank you for any advice,

Merlin

--
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] can not fork

2007-05-20 Thread Jochem Maas
Rajiv Man Karmacharya wrote:
 php-general@lists.php.net
 
 while trying to use exec('IECapt.exe ' . escapeshellarg($website_url) . ' ' . 
 escapeshellarg($cached_filename)); i get the following error
 
 Warning: exec() [function.exec]: Unable to fork [IECapt.exe 
 http://www.nepalnews.com.np; 
 C:/Inetpub/wwwroot/5531ed95934bee318939d9270b2db620.png] ...
 
 This piece of code is from 
 http://www.zubrag.com/scripts/website-thumbnail-generator.php
 
 I couldn't figure out why this Unable to fork is occuring. I search php.net 
 as well and it says, it might be related to permission issues.
 
 I'm using winxp and iis.
 
 I hope someone would help me with this.

probably permissions is the problem - i.e. IIS doesn't have the right to run a 
shell and/or the binary in question.

BUT who cares ... you shouldn't be using exec() in a script that's evoked via a 
webserver if you can really help it.

it seems you have a binary that takes a url and makes a visual snapshot of the 
resulting webpage as seen in IE, I
would suggest that you run a background task that regularly updates a cache of 
such images using the exec() technique
given above (maybe using a database as a source of urls to check) and then have 
you web scripts use the cached data
as needed.

otherwise your off into the dark woods of windows/IIS permissions (can't help 
you there I'm afraid)

 
 Regards
 Rajiv

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



[PHP] Confused about handling bytes

2007-05-20 Thread Joe Veldhuis
While I'm sure this is a stupid question and the solution will be 
obvious to everyone here, this is confusing me.


I'm trying to control a device over a serial port using a PHP script, 
and one of the things I need to do is read a 26-byte string from an 
EEPROM, using a command that returns two bytes at a time, and write 
similar strings using a similar command. For example, to read the first 
two bytes of one such string beginning at address 0x484, I would send:


04 84 00 00 BB

Here's the code I've written so far:

$string = 1; //which of 200 strings I want to read
$base = pack(H*,dechex((($string-1)*hexdec(0x1a))+hexdec(0x484))); 
//calculate the base address of the string (the first starts at 0x484)

for($i=0;$i  13;$i++) { //iterate 13 times (26 bytes / 2 bytes at a time)
dio_write($serial,$base.\x00\x00\xbb,5); //send the command
$output[] = dio_read($serial,1);  // read first byte
$output[] = dio_read($serial,1); // read second byte
$base = pack(H*,dechex(hexdec(bin2hex($base))+2)); //increment address
}

There are two things wrong with this. First, the final line isn't doing 
what it's supposed to. Instead of adding 2 to the value of $base each 
time, It's producing a pattern like this:


0x484, 0x486, 0x73, 0x73, 0x73, 0x488, 0x48a, 0x48c, 0x48e, 0x490, 0x74, 
0x74, 0x74


Second, the format of $base doesn't seem to be handled correctly in line 
4 of the above code. Given a value of 0x484, this line should write the 
bytes 04 84, but it is obviously not doing so, given the response I 
get from the device (it sends FF FF instead of the expected value at 
that address, which I get when I remove the variable and manually 
specify the address).


What are the solutions to these problems?

Thanks,
-Joe Veldhuis

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



[PHP] Uploading Files Should I use MySQL or Server for storage?

2007-05-20 Thread [EMAIL PROTECTED]

I am in the process of adding a part to my website which would include
pictures, pdf files, txt files, and excel files.  The files sizes
could be anywhere on average of 100k to 2mb.  Do you think I should be
uploading the files to a MySQL database or to my server?

I have head that there are pros and cons to both, but have never
really received a definitive answer that helps much.  I appreciate all
your opinions on the pros and cons of both.

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



Re: [PHP] Uploading Files Should I use MySQL or Server for storage?

2007-05-20 Thread Richard Davey
Hi benc11,

Monday, May 21, 2007, 2:16:19 AM, you wrote:

 I am in the process of adding a part to my website which would include
 pictures, pdf files, txt files, and excel files.  The files sizes
 could be anywhere on average of 100k to 2mb.  Do you think I should be
 uploading the files to a MySQL database or to my server?

 I have head that there are pros and cons to both, but have never
 really received a definitive answer that helps much.  I appreciate all
 your opinions on the pros and cons of both.

This isn't a 'one size fits all' question. The pros and cons are
specific only to your site. How many uploads are you going to be
dealing with, at what frequency, at what growth rate? Are they going
to be massively downloaded too?

There generally are far less 'pros' for storing binary files in MySQL
than you'd think. The only real benefit imho is that they are then
filesystem / platform agnostic.

There are plenty of 'cons' however. Just think of the server overhead
involved in your PHP script talking to MySQL, MySQL sending back the
entire file to PHP (using memory / cpu bandwidth), then you've got to
blast that file out to the end user. Repeat this X however much
traffic you get and you're performing pointless exercises over and
over when the web server could just serve the file directly.

Only you can answer your question really.

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.corephp.co.uk

Never trust a computer you can't throw out of a window

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



Re: [PHP] Uploading Files Should I use MySQL or Server for storage?

2007-05-20 Thread [EMAIL PROTECTED]

Thanks Rich.  The files are not going to be downloaded all that often
and the overall traffic is relatively low.  However, as with probably
everyone I am hoping and expecting big increases in traffic.  I
currently run most of my site off LAMP.  My main concerns as you
mentioned is using memory/CPU bandwidth.  There will probably be far
more files stored than accessed.  Hope this helps everyone else with
their opinions.

On 5/20/07, Richard Davey [EMAIL PROTECTED] wrote:

Hi benc11,

Monday, May 21, 2007, 2:16:19 AM, you wrote:

 I am in the process of adding a part to my website which would include
 pictures, pdf files, txt files, and excel files.  The files sizes
 could be anywhere on average of 100k to 2mb.  Do you think I should be
 uploading the files to a MySQL database or to my server?

 I have head that there are pros and cons to both, but have never
 really received a definitive answer that helps much.  I appreciate all
 your opinions on the pros and cons of both.

This isn't a 'one size fits all' question. The pros and cons are
specific only to your site. How many uploads are you going to be
dealing with, at what frequency, at what growth rate? Are they going
to be massively downloaded too?

There generally are far less 'pros' for storing binary files in MySQL
than you'd think. The only real benefit imho is that they are then
filesystem / platform agnostic.

There are plenty of 'cons' however. Just think of the server overhead
involved in your PHP script talking to MySQL, MySQL sending back the
entire file to PHP (using memory / cpu bandwidth), then you've got to
blast that file out to the end user. Repeat this X however much
traffic you get and you're performing pointless exercises over and
over when the web server could just serve the file directly.

Only you can answer your question really.

Cheers,

Rich
--
Zend Certified Engineer
http://www.corephp.co.uk

Never trust a computer you can't throw out of a window

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





--
**
The content of this e-mail message and any attachments are
confidential and may be legally privileged, intended solely for the
addressee. If you are not the intended recipient, be advised that any
use, dissemination, distribution, or copying of this e-mail is
strictly prohibited. If you receive this message in error, please
notify the sender immediately by reply email and destroy the message
and its attachments.
*

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



Re: [PHP] Uploading Files Should I use MySQL or Server for storage?

2007-05-20 Thread Greg Donald

On 5/20/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

I am in the process of adding a part to my website which would include
pictures, pdf files, txt files, and excel files.  The files sizes
could be anywhere on average of 100k to 2mb.  Do you think I should be
uploading the files to a MySQL database or to my server?



http://www.zend.com/zend/trick/tricks-sept-2001.php?id=342

[snip]
cuts performance by approximately a third
[/snip]


--
Greg Donald
http://destiney.com/

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



Re: [PHP] Random SELECT SQL list

2007-05-20 Thread Eduardo Vizcarra
Hi Larry,Paul,Zoltán

Thanks for your messages, adding ORDER BY RAND () worked just fine

:)
Eduardo
Larry Garfield [EMAIL PROTECTED] escribió en el mensaje 
news:[EMAIL PROTECTED]
 On Wednesday 16 May 2007, Eduardo Vizcarra wrote:
 Hi

 I would like to know if a SELECT SQL query list of records can be 
 unsorted.
 SELECT statement retrieves a list of records from a certain table 
 starting
 from record # 1 till record #N and when publishing the records, this is 
 how
 it is presented, in a sequential way, is there any way to not present 
 them
 in a sequential way ? e.g. if a user accesses a web page then he will see
 record #3 and then #7 and so on, another user accesses the same web page
 and he might see record #8 and then record#2. etc

 any experience on how to do this ?

 This is really an SQL question, but it's quite easy.  Assuming MySQL:

 $result = mysql_query(SELECT * FROM foo WHERE bar='baz' ORDER BY 
 RAND());
 // Do stuff here.

 -- 
 Larry Garfield AIM: LOLG42
 [EMAIL PROTECTED] ICQ: 6817012

 If nature has made any one thing less susceptible than all others of
 exclusive property, it is the action of the thinking power called an idea,
 which an individual may exclusively possess as long as he keeps it to
 himself; but the moment it is divulged, it forces itself into the 
 possession
 of every one, and the receiver cannot dispossess himself of it.  --  
 Thomas
 Jefferson 

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



[PHP] Re: Uploading Files Should I use MySQL or Server for storage?

2007-05-20 Thread itoctopus
I have tried both, and I tell you that I really felt that the filesystem is 
a more convenient way of doing it.

-- 
itoctopus - http://www.itoctopus.com
[EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
I am in the process of adding a part to my website which would include
 pictures, pdf files, txt files, and excel files.  The files sizes
 could be anywhere on average of 100k to 2mb.  Do you think I should be
 uploading the files to a MySQL database or to my server?

 I have head that there are pros and cons to both, but have never
 really received a definitive answer that helps much.  I appreciate all
 your opinions on the pros and cons of both. 

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



Re: [PHP] Uploading Files Should I use MySQL or Server for storage?

2007-05-20 Thread Robert Cummings
On Sun, 2007-05-20 at 20:35 -0500, Greg Donald wrote:
 On 5/20/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
  I am in the process of adding a part to my website which would include
  pictures, pdf files, txt files, and excel files.  The files sizes
  could be anywhere on average of 100k to 2mb.  Do you think I should be
  uploading the files to a MySQL database or to my server?
 
 
 http://www.zend.com/zend/trick/tricks-sept-2001.php?id=342
 
 [snip]
 cuts performance by approximately a third
 [/snip]

Sure, if you use database file storage in the naive way described in the
document. But I'm quite certain a database stored binary file dispensed
to multiple servers that keep a locally cached copy for subsequent
requests beats NFS retrieval hands down. Sure, you could do the same
caching with the NFS file but then the solution is quite likely just as
good as the database storage solution. So the 1/3 performance penalty is
for the naive solution.

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] Uploading Files Should I use MySQL or Server for storage?

2007-05-20 Thread Larry Garfield
A well-optimized and load balanced database-based setup will beat a badly 
configured file system setup, sure.  But will it beat a well-optimized and 
load balanced file system setup?  I would be very surprised.

Really, it comes down to this, assuming you know what you're doing either way.  
Using a database and PHP access script will add overhead to the process.  
Period.  There's extra script execution time, database connection time, 
database read time, and pass-through time.  Plus memory overhead on all of 
those, and coding/debugging time and effort.  What you get in return is more 
places to programmatically control and log things; access-controls for 
whether or not a user is authorized to see a file, potentially more detailed 
access logs than you can get from simple apache logs, etc.  

Sometimes that trade-off will be worth it for whatever it is you're doing.  
Most of the time, it probably won't be.  Decide based on what it is you're 
doing.

On Sunday 20 May 2007, Robert Cummings wrote:
 On Sun, 2007-05-20 at 20:35 -0500, Greg Donald wrote:
  On 5/20/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
   I am in the process of adding a part to my website which would include
   pictures, pdf files, txt files, and excel files.  The files sizes
   could be anywhere on average of 100k to 2mb.  Do you think I should be
   uploading the files to a MySQL database or to my server?
 
  http://www.zend.com/zend/trick/tricks-sept-2001.php?id=342
 
  [snip]
  cuts performance by approximately a third
  [/snip]

 Sure, if you use database file storage in the naive way described in the
 document. But I'm quite certain a database stored binary file dispensed
 to multiple servers that keep a locally cached copy for subsequent
 requests beats NFS retrieval hands down. Sure, you could do the same
 caching with the NFS file but then the solution is quite likely just as
 good as the database storage solution. So the 1/3 performance penalty is
 for the naive solution.

 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.  |

 `'


-- 
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]   ICQ: 6817012

If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it.  -- Thomas 
Jefferson

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



Re: [PHP] Uploading Files Should I use MySQL or Server for storage?

2007-05-20 Thread Robert Cummings
On Sun, 2007-05-20 at 23:11 -0500, Larry Garfield wrote:
 A well-optimized and load balanced database-based setup will beat a badly 
 configured file system setup, sure.  But will it beat a well-optimized and 
 load balanced file system setup?  I would be very surprised.
 
 Really, it comes down to this, assuming you know what you're doing either 
 way.  
 Using a database and PHP access script will add overhead to the process.  
 Period.  There's extra script execution time, database connection time, 
 database read time, and pass-through time.  Plus memory overhead on all of 
 those, and coding/debugging time and effort.  What you get in return is more 
 places to programmatically control and log things; access-controls for 
 whether or not a user is authorized to see a file, potentially more detailed 
 access logs than you can get from simple apache logs, etc.  
 
 Sometimes that trade-off will be worth it for whatever it is you're doing.  
 Most of the time, it probably won't be.  Decide based on what it is you're 
 doing.

Yep, I never said database was necessarily superior, only that anyone
with any skill whatsoever isn't going to be hammered by a 1/3
performance penalty for using the database. As you said... it all
depends on what you're doing. As for all the penalties you mentioned
above, you may be incurring these anyways if you have any kind of
logical control of the files since you probably have to hit the database
for file access permissions, or meta information, etc, etc.

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] Re: Confused about how exactly to output image using imagepng function [SOLVED]

2007-05-20 Thread Dave M G

Robert,  Zoltan, Stephen, Tijnema,

Thank you for your responses.

I did take some code off of the internet, but I had to modify it to work 
within the context of my general system.


The explanations offered here have helped me achieve that.

Thank you all for your insight and help.

--
Dave M G
Ubuntu Feisty 7.04
Kernel 2.6.20-15-386

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



Re: [PHP] Uploading Files Should I use MySQL or Server for storage?

2007-05-20 Thread Larry Garfield
On Sunday 20 May 2007, Robert Cummings wrote:
 On Sun, 2007-05-20 at 23:11 -0500, Larry Garfield wrote:
  A well-optimized and load balanced database-based setup will beat a badly
  configured file system setup, sure.  But will it beat a well-optimized
  and load balanced file system setup?  I would be very surprised.
 
  Really, it comes down to this, assuming you know what you're doing either
  way. Using a database and PHP access script will add overhead to the
  process. Period.  There's extra script execution time, database
  connection time, database read time, and pass-through time.  Plus memory
  overhead on all of those, and coding/debugging time and effort.  What you
  get in return is more places to programmatically control and log things;
  access-controls for whether or not a user is authorized to see a file,
  potentially more detailed access logs than you can get from simple apache
  logs, etc.
 
  Sometimes that trade-off will be worth it for whatever it is you're
  doing. Most of the time, it probably won't be.  Decide based on what it
  is you're doing.

 Yep, I never said database was necessarily superior, only that anyone
 with any skill whatsoever isn't going to be hammered by a 1/3
 performance penalty for using the database. As you said... it all
 depends on what you're doing. As for all the penalties you mentioned
 above, you may be incurring these anyways if you have any kind of
 logical control of the files since you probably have to hit the database
 for file access permissions, or meta information, etc, etc.

On the request to generate the link, yes.  But in the browser if it's given, 
say, an image URL, it has to make a new HTTP request back to the server to 
get whatever that URL is.  If that URL is a PHP script that returns an image 
out of a database it will be slower than if it's a URL to a file sitting on 
disk.  That's where the performance loss is.  Whether or not that's a 
worthwhile trade-off is a case-by-case question.

-- 
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]   ICQ: 6817012

If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it.  -- Thomas 
Jefferson

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



Re: [PHP] Confused about handling bytes

2007-05-20 Thread Tom Rogers
Hi,

Monday, May 21, 2007, 10:50:27 AM, you wrote:
JV While I'm sure this is a stupid question and the solution will be 
JV obvious to everyone here, this is confusing me.

JV I'm trying to control a device over a serial port using a PHP script, 
JV and one of the things I need to do is read a 26-byte string from an 
JV EEPROM, using a command that returns two bytes at a time, and write 
JV similar strings using a similar command. For example, to read the first
JV two bytes of one such string beginning at address 0x484, I would send:

JV 04 84 00 00 BB

JV Here's the code I've written so far:

JV $string = 1; //which of 200 strings I want to read
JV $base = pack(H*,dechex((($string-1)*hexdec(0x1a))+hexdec(0x484))); 
JV //calculate the base address of the string (the first starts at 0x484)
JV for($i=0;$i  13;$i++) { //iterate 13 times (26 bytes / 2 bytes at a time)
JV dio_write($serial,$base.\x00\x00\xbb,5); //send the command
JV $output[] = dio_read($serial,1);  // read first byte
JV $output[] = dio_read($serial,1); // read second byte
JV $base = pack(H*,dechex(hexdec(bin2hex($base))+2)); //increment address
JV }

JV There are two things wrong with this. First, the final line isn't doing
JV what it's supposed to. Instead of adding 2 to the value of $base each 
JV time, It's producing a pattern like this:

JV 0x484, 0x486, 0x73, 0x73, 0x73, 0x488, 0x48a, 0x48c, 0x48e, 0x490, 0x74,
JV 0x74, 0x74

JV Second, the format of $base doesn't seem to be handled correctly in line
JV 4 of the above code. Given a value of 0x484, this line should write the
JV bytes 04 84, but it is obviously not doing so, given the response I 
JV get from the device (it sends FF FF instead of the expected value at
JV that address, which I get when I remove the variable and manually 
JV specify the address).

JV What are the solutions to these problems?

JV Thanks,
JV -Joe Veldhuis


Do your packing after all the calculations:

?php
$output = array();
$string = 1;
for(
  $i=0, $base = (($string-1) * 26) + 0x484; 
  $i  26;
  $i++, $base += 2)
{
$binarydata = pack(nc*, $base, 0, 0, 0xBB);
dio_write($serial,$k=strlen($binarydata),5); //send the command
$output[] = dio_read($serial,1);  // read first byte
$output[] = dio_read($serial,1); // read second byte
}

-- 
regards,
Tom

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