[PHP] Source code of original PHP release.

2013-05-23 Thread chris
I'm currently writing a paper on the evolution of PHP and web 
development/security as a whole.
One of the things I want to incorporate is snippets of source code to 
show how things have grown and advanced since the 90's


If anyone could help me out I would be much appreciated. All my 
attempts of trying to find it have turned up nothing :(


Cheers,
Christopher Tombleson
---
Github: https://github.com/chtombleson
Blog: http://blog.cribznetwork.com
Website: http://cribznetwork.com
Ohloh: https://www.ohloh.net/accounts/chtombleson/


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



Re: [PHP] Source code of original PHP release.

2013-05-23 Thread chris

Thank you Sir.
Just what I needed :)
I didn't even know there was a museum.

Cheers,
Christopher Tombleson

On 2013-05-24 05:02, Daniel Brown wrote:
On Thu, May 23, 2013 at 2:16 AM, chris ch...@cribznetwork.com 
wrote:

I'm currently writing a paper on the evolution of PHP and web
development/security as a whole.
One of the things I want to incorporate is snippets of source code 
to show

how things have grown and advanced since the 90's

If anyone could help me out I would be much appreciated. All my 
attempts of

trying to find it have turned up nothing :(


Everything you want (and more) regarding that is in the Museum:

http://museum.php.net/

--
/Daniel P. Brown
Network Infrastructure Manager
http://www.php.net/



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



[PHP] A little confused

2013-04-23 Thread Chris Knipe
Hi All,

$_SESSION['ExpiryDate'] = 2013-04-23;
echo date_format($_SESSION['ExpiryDate'], D, \t\h\e jS \o\f M Y);

Required Result: Mon, the 23rd of Apr 2013

I get however:  PHP Warning:  date_format() expects parameter 1 to be
DateTime, integer given in

I've had a look at the date/time function list, but I cannot seem to find
any way to convert $_SESSION['ExpiryDate'] to an DateTime??

--
Chris.



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




Re: [PHP] A little confused

2013-04-23 Thread Chris Knipe
Yes,

strtotime() does convert the $_SESSION value to a unix epoc, as expected.
However, date_format still complains that the argument is a Integer value,
instead of a DateTime.




On Tue, Apr 23, 2013 at 12:09 PM, Stuart Dallas stu...@3ft9.com wrote:

 On 23 Apr 2013, at 11:07, Chris Knipe sav...@savage.za.org wrote:

  $_SESSION['ExpiryDate'] = 2013-04-23;
  echo date_format($_SESSION['ExpiryDate'], D, \t\h\e jS \o\f M Y);
 
  Required Result: Mon, the 23rd of Apr 2013
 
  I get however:  PHP Warning:  date_format() expects parameter 1 to be
  DateTime, integer given in
 
  I've had a look at the date/time function list, but I cannot seem to find
  any way to convert $_SESSION['ExpiryDate'] to an DateTime??

 http://php.net/strtotime

 -Stuart

 --
 Stuart Dallas
 3ft9 Ltd
 http://3ft9.com/




-- 

Regards,
Chris Knipe


Re: [PHP] A little confused

2013-04-23 Thread Chris Knipe
Thanks for the replies guys - figured it out!

Using date() directly with strtotime() and the appropriate formating works
:)

date(D, \\t\h\e jS \o\\f M Y, strtotime($_SESSION['ExpiryTime']))




On Tue, Apr 23, 2013 at 12:16 PM, shiplu shiplu@gmail.com wrote:


 On Tue, Apr 23, 2013 at 4:07 PM, Chris Knipe sav...@savage.za.org wrote:

 echo date_format($_SESSION['ExpiryDate'], D, \t\h\e jS \o\f M Y);


 Why not construct DateTime object

 echo date_format(new DateTime($_SESSION['ExpiryDate']), D, \t\h\e jS \o\f
 M Y);

 Or

 $dt = new DateTime($_SESSION['ExpiryDate']);
 echo $dt-format(D, \t\h\e jS \o\f M Y);

 I personally like the later. It takes less characters to do more.






 --
 Shiplu.Mokadd.im
 ImgSign.com | A dynamic signature machine
 Innovation distinguishes between follower and leader




-- 

Regards,
Chris Knipe


[PHP] PHP fails to install on Ubuntu 12.10. What's going on?

2013-02-14 Thread Chris Bergstresser
Hi all --

   I've got a cloud server on Rackspace.  If I bring up a fresh Ubuntu
12.10 machine image, and type apt-get install php5 it seems to
install fine.  But if I then type php -version I get PHP Parse
error:  syntax error, unexpected end of file in Command line code on
line 1.

   What went wrong?  How can I fix it?

-- Chris

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



Re: [PHP] PHP fails to install on Ubuntu 12.10. What's going on?

2013-02-14 Thread Chris Bergstresser
On Thu, Feb 14, 2013 at 3:05 PM, John Iliffe john.ili...@iliffe.ca wrote:
 type php --version

 There are two - preceding the word version.

   Apparently, the version of PHP installed on 12.04 accepts
-version.  The version of PHP installed on 12.10 does not, and bombs
without giving a proper error message.
   Good to know.

-- Chris

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



[PHP] Tokyo Cabinet or Kyoto Cabinet support

2013-02-12 Thread Chris MacPherson
Hi,

Just wondering if anyone can tell me if Kyoto Cabinet support will be added
to the DBM extension in the near future at all.

I noticed this thread (
http://grokbase.com/t/php/php-internals/119yvjcjwr/tokyo-kyoto-cabinet-in-5-4)
which mentions that there has been support added but looking in the DBA
extension README file in the source code I can't see any mention of
Tokyo/Kyoto Cabinet, just the qdbm predecessor.

Cheers for any help :)

Chris


Re: [PHP] Tokyo Cabinet or Kyoto Cabinet support

2013-02-12 Thread Chris MacPherson
Ok will do, thanks for the suggestion.


On 12 February 2013 18:25, Matijn Woudt tijn...@gmail.com wrote:




 On Tue, Feb 12, 2013 at 7:06 PM, Chris MacPherson ch...@kombine.co.ukwrote:

 Hi,

 Just wondering if anyone can tell me if Kyoto Cabinet support will be
 added
 to the DBM extension in the near future at all.

 I noticed this thread (

 http://grokbase.com/t/php/php-internals/119yvjcjwr/tokyo-kyoto-cabinet-in-5-4
 )
 which mentions that there has been support added but looking in the DBA
 extension README file in the source code I can't see any mention of
 Tokyo/Kyoto Cabinet, just the qdbm predecessor.

 Cheers for any help :)

 Chris


 It's probably better to ask this question at the php-internals list. This
 is more general PHP help.

 - Matijn



Re: [PHP] Can I do this in a single match/replace?

2012-06-27 Thread Chris Testroet

On 6/27/2012 6:26 PM, Paul Halliday wrote:

I have lines that look like (I added intentional line breaks):

alert tcp $HOME_NET 1 - $EXTERNAL_NET any (msg:ET EXPLOIT NDMP
Notify Connect - Possible Backup Exec Remote Agent Recon;
flow:established,from_server; content:|00 00 05 02|; offset:16;
depth:20; content: |00 00 00 03|; offset: 28;
depth: 32; 
reference:url,www.ndmp.org/download/sdk_v4/draft-skardal-ndmp4-04.txt;
reference:url,doc.emergingthreats.net/bin/view/Main/2002068;
classtype:attempted-recon; sid:2002068; rev:8;)

So within this there are reference urls that I would like to turn into
links so that when they are rendered they can be clicked on.

Using preg_match and this pattern I can get the refs:

$pattern = '\reference:url,([^;]+;)\';

which gives me:

$matches[0] = www.ndmp.org/download/sdk_v4/draft-skardal-ndmp4-04.txt
$matches[1] = doc.emergingthreats.net/bin/view/Main/2002068

now what I would like to do is replace inline adding a href=http://;
. $matches[n] .  . $matches[n] . /a

Can this be done or do I need to say loop through matches (there can
be none or many) and do a str_replace.

Thoughts? Other ideas?

Thanks.



Look into preg_replace, with the e modifier. It allows you to run php 
code for every replace.


Chris


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



Re: [PHP] 0.0.0.0 iplong()

2012-06-05 Thread Chris Knipe
 acl allow range: 192.168.0.0/24
 acl deny range: 0.0.0.0/24

 CIDR notation allows me to utilize shorthand notation for specifying a range
 of IP's

 In those two cases any ip within 192.168.0.0 - 192.168.0.255 is allowed
 while anything else residing between 0.0.0.0 - 255.255.255.255 is denied

Na-uh.  You want 0.0.0.0/0, which is valid. 0.0.0.0/24 isn't valid.

-- 

Regards,
Chris Knipe

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



Re: [PHP] help with preg_match

2012-06-04 Thread Chris Purves
On 2012-06-03 22:37, Robert Williams wrote:
 On Jun 3, 2012, at 17:28, Chris Purvesch...@northfolk.ca  wrote:
 
 I know that the text ends 'end', but I don't know what the Something,
 something is.  I am using preg_match as follows:

 preg_match('/[^]*end/',$curl_response,$matches);

 I want to match 'end' and everything before it that is not ''.
 
 You need to match something at the beginning. Try this:
 
 preg_match('/([^]*end)/', $curl_response, $matches);
 
 Assuming a match, you can then look to $matches[1] for your content.
 

That did it.  In my case, I know that the first letter is capitalized, so I 
used:

preg_match('/[A-Z][^]*end/', $curl_response, $matches);

Thanks for your help.


-- 
Chris Purves

The eyes are the groin of the head. Dwight Schrute

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



[PHP] help with preg_match

2012-06-03 Thread Chris Purves

Hello,

I am trying to use preg_match to match something from an html file. 
Within the html file is some text that looks like:


spanSomething, something end/span

I know that the text ends 'end', but I don't know what the Something, 
something is.  I am using preg_match as follows:


preg_match('/[^]*end/',$curl_response,$matches);

I want to match 'end' and everything before it that is not ''.

The problem appears to be with the ''.  I have tried escaping (\), but 
it didn't make a difference.  The php script hangs when it tries to run 
this function.



--
Chris Purves

There's a time to think, and a time to act. And this, gentlemen, is no 
time to think. - Sheriff Bud B. Boomer


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



Re: [PHP] url string being split

2012-04-27 Thread Chris Stinemetz
On Thu, Apr 26, 2012 at 12:58 PM, Stuart Dallas stu...@3ft9.com wrote:
 On 26 Apr 2012, at 18:37, Jim Giner wrote:

 Im no expert, but why would you expose a query to the world thru the use of
 a GET?  Why not just collect the params and build the string in your code?
 That is how people hack into your database - via a re-formed query.  You're
 giving someone an open invitation.

 A query string has nothing to do with databases.

 -Stuart


I still haven't been able to find a solution. Is there anyone out
there that knows how to keep the query string intact?

Thank you,

Chris

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



Re: [PHP] url string being split

2012-04-27 Thread Chris Stinemetz
On Fri, Apr 27, 2012 at 11:09 AM, Shawn McKenzie nos...@mckenzies.net wrote:
 On 04/27/2012 10:56 AM, Chris Stinemetz wrote:
 I still haven't been able to find a solution. Is there anyone out
 there that knows how to keep the query string intact?

 Thank you,

 Chris

 urlencode($storerow['store_subject'])

 --
 Thanks!
 -Shawn
 http://www.spidean.com

Thank you. That is what I was looking for.

-Chris

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



[PHP] url string being split

2012-04-26 Thread Chris Stinemetz
Hello list,

I'm trying to pass a query string through $_GET but for some reason
the array is being split on ''. How may I avoid this so it stays
intacted?

user selection portion:

while($storerow = mysql_fetch_assoc($storesresult))
echo 'h4a href=store.php?id=' . $storerow['store_subject'] . ''
. $storerow['store_subject'] . '/a/h4 at ' . date('m-d-Y h:i:s A',
strtotime($storerow['real_time_date']));

produces url string:

http://westeng/forum/store.php?id=Wiser Communication, LLC - - Sprague Ave


print(pre.print_r($_GET,true)./pre); ## results below

Array
(
[id] = Wiser Communication, LLC -
[-_Sprague_Ave] =
)

How do I make it so the string isn't split into two elements in the
array? I want it to stay instact.

Thank you,

Chris

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



[PHP] MySQL table design

2012-03-22 Thread Chris Stinemetz
Hello List,

Is it possible to create a MySQL table with characters such as . and
[] in the column headers? If so would you explain how?

Thank you,

Chris

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



Re: [PHP] MySQL table design

2012-03-22 Thread Chris Stinemetz
On Thu, Mar 22, 2012 at 7:42 PM, Stuart Dallas stu...@3ft9.com wrote:
 On 23 Mar 2012, at 00:10, Chris Stinemetz wrote:

 Is it possible to create a MySQL table with characters such as . and
 [] in the column headers? If so would you explain how?

 Try putting the column names in backticks (`).

 BUT... whatever the reason why you want to do that, IT'S WRONG.

 Seriously, don't do it. It will cause you more problems than you think it 
 will solve, and I don't even know what problem you think it will solve.


I am just trying to preserve the source headers from the original data
I want to import into the table.

Thank you,

Chris

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



Re: [PHP] Numeric help needed

2012-01-15 Thread Chris Payne
Hi Jason,

I've tried lots of different things, including:

 echo br . round(68500, 1000) .  ROUNDED;

thinking that might be it, but i'm stumped

This is the example I was given (And have to go by):

If the loan amount is $68500.00, the insurace will be based on
$69000.00 as the amount is always rounded up to the next $1000.

Maybe i'm just looking at it wrong but i'm stumped.

Chris


On Sun, Jan 15, 2012 at 8:41 PM, Jason Pruim li...@pruimphotography.com wrote:


 Sent from my iPhone

 On Jan 15, 2012, at 8:25 PM, Christopher J Payne oxygene...@gmail.com 
 wrote:

 Hi everyone,



 I am having a hard time with a numerical problem.



 I need to round some numbers up and I've tried $round($number) and it
 doesn't work so I'm misunderstanding something.



 For example, if a user inputs 685000 I need it to round up to 69 or if
 they input 149560 I need it to round up to 15.  What is the correct way
 to do this as everything I have tried doesn't seem to affect the user
 inputted figure at all.



 Anyway help would REALLY be appreciated, I'm sure it's really simple but for
 the life of me I'm stumped on why it's not working.


 Maybe it's just a typo in your email but you put a $ infront of round() try 
 removing that and see if it helps. If not are there any error messages that 
 are showing up?


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



[PHP] Thank you all for your help

2012-01-15 Thread Chris Payne
Hi there,

A big thank you to all of you who took time to help me with my numeric
problem from earlier, it's been a huge help :-)

Chris

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



Re: [PHP] PHP 5.3.2 max_execution_time

2012-01-02 Thread Chris Tapp

On 2 Jan 2012, at 02:15, Duken Marga wrote:


If you want to upload large file, maybe you should consider maximum
uploaded size. You can change setting in php.ini on line that  
contain *

upload_max_filesize*.


Thanks, but the filesize limits are already set well above the size of  
the file. The file transfer takes place within the context of an RPC  
callback, so I think this may be a TCP transfer rather than a file  
upload.


This really does seem to be an execution time issue, as shown by the  
Apache error log entry.


Chris


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



Re: [PHP] PHP 5.3.2 max_execution_time

2012-01-02 Thread Chris Tapp

On 2 Jan 2012, at 13:53, Matijn Woudt wrote:

On Mon, Jan 2, 2012 at 10:21 AM, Chris Tapp  
opensou...@keylevel.com wrote:


This really does seem to be an execution time issue, as shown by  
the Apache

error log entry.

Chris



Are you sure you've checked every possible place for Apache config
files? Most distro's have /etc/apache2/httpd.conf, but also
/etc/apache2/conf.d/* and the ones for each virtual host (mine are at
/etc/apache2/sites-enabled/*). You can also set php settings in
.htaccess files.


Yes, I don't think there is anything I haven't checked. The  
configuration under CentOS 6 is more the 'old way' - i.e. a conf/ and  
conf.d/. All the php configuration is in /etc/php.ini with conf.d/ 
php.conf enabling Apache php support.


Dokuwiki is installed as a virtual host located at /usr/share/ 
dokuwiki. If I create a php file in that directory that runs  
php_info(), then the output that's produced shows max_execution_time  
(global and local) as 120 seconds.


Chris


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



Re: [PHP] PHP 5.3.2 max_execution_time

2012-01-02 Thread Chris Tapp

On 2 Jan 2012, at 16:19, Matijn Woudt wrote:


It is also possible to set the max execution time in PHP with
set_time_limit() function, maybe one of the scripts does that? Look at
the apache log at which file the timeout occurs, that might give you a
clue.


Thanks Matijn, I've found a set_time_limit( 30 ) call in a file  
related to the transfer that looks like the root of the problem :-)


Thanks for the help.

Chris



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



[PHP] PHP 5.3.2 max_execution_time

2012-01-01 Thread Chris Tapp
I've got a Dokuwiki installation that is producing Apache errors  
saying that the maximum execution time of 30 seconds has been exceeded.


So, I went and changed max_execution_time in php.ini expecting that  
this would solve the problem (which is due to large files taking a  
while to upload over an ADSL connection). However, the error log still  
reports that the old 30 second value is in use, even though Apache has  
been restarted.


phpinfo() for the same site reports max_execution_time as 120 seconds,  
so it seems as if the change to php.ini has been detected as expected.  
Is there another setting that I need to consider? max_input_time is  
already set to 60 seconds and there are no local 'php_value' Apache  
configuration items fighting the ones in php.ini.


PHP version is 5.3.2 and is running under a CentOS 6.0 system.

Chris Tapp

opensou...@keylevel.com
www.keylevel.com




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



Re: [PHP] dev to production server

2011-09-07 Thread Chris Stinemetz

 By local, do you mean a local dedicated box, or an everyday use box?

It is an everyday use box.


 The checklist varies quite a bit depending on the results.

 Also, is your site to be served by standard port 80 traffic? Does your 
 Internet host allow inbound port 80?

Yes it will be served by standard port 80 traffic and yes my Internet
host allows inbound port 80.

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



Re: [PHP] dev to production server

2011-09-07 Thread Chris Stinemetz
On Wed, Sep 7, 2011 at 6:23 AM, James Yerge ja...@nixsecurity.org wrote:
 On 09/07/2011 12:24 AM, Chris Stinemetz wrote:

 Does anyone have a procedure or know of any tutorials that explain how
 to take a mac/apache/php/mysql dev environment and converting it to
 production environment?

 Basically I want to host my own web site on my local machine now that
 I have finished developing it.

 Thanks in advance!


 I'm not familiar with MAC, however, there are projects out there that
 provide everything you need, for the most part. Look up XAMPP, I used to use
 this in the past before I setup my own personal server.

 http://www.apachefriends.org/en/xampp-macosx.html

 This should provide you with an environment necessary for development and
 production. I currently run Arch Linux on my personal server and have
 installed Apache, PHP, MySQL and so on via the package manager. For my
 dev/prod process, I'm using Boilerplate, which provides a default HTML5/CSS3
 template. However, the nice thing about it is, they've also provided a small
 build process using ANT. I've modified the ANT build script to my needs and
 simply build my production environment using that, keeping my dev code in
 tact and readable :) They've integrated the YUI Compressor into their build
 process is simply minifies all CSS and JavaScript.

 Anyway, enough about that, just an example of what can be done. There's
 always the option of compiling everything from source as well :)

 James


Thank you James. I appreciate your advise.

Chris

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



[PHP] dev to production server

2011-09-06 Thread Chris Stinemetz
Does anyone have a procedure or know of any tutorials that explain how
to take a mac/apache/php/mysql dev environment and converting it to
production environment?

Basically I want to host my own web site on my local machine now that
I have finished developing it.

Thanks in advance!

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



[PHP] socket_bind to an ssl:// address

2011-09-04 Thread Chris Bowler

Hi ive been using this no problems

$sourceip = 'xx.xx.xx.xx'; //IP to bind
$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_bind($sock, $sourceip);
socket_connect($sock, 'dac.nic.uk', 3043);

But I need to connect to ssl://epp.nominet.org.uk:700 and this fails as 
it does not understand the ssl:// part.


I tried to do this using streams ,

if (function_exists('stream_context_create')  
function_exists('stream_socket_client'))

$socket_options = array('socket' = array('bindto' = 'xx.xx.xx.xx')
$socket_context = stream_context_create($socket_options)
$socket = stream_socket_client('ssl://epp.nominet.org.uk:700', $errno,
$errstr, 30, STREAM_CLIENT_CONNECT, $socket_context);

but whenever I connect the remote connection still see's me as my 
servers main IP rather then then IP im trying to bind.






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



Re: [PHP] Dealing with multiple form submissions

2011-08-24 Thread Chris Stinemetz




On Aug 24, 2011, at 3:46 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote:

 
 
 Mike Mackintosh mike.mackint...@angrystatic.com wrote:
 
 
 
 On Aug 24, 2011, at 11:52, John Black s...@network-technologies.org
 wrote:
 
 On 08/24/2011 03:04 AM, Jason Pruim wrote:
 Wondering what everyone does to prevent multiple form submissions?
 My form is simply getting emailed to my email, and it redirects to a
 success page when submitted...
 Would it be as simple as doing something with the cache control?
 Basically I'm trying to avoid someone submitting a form... Then hitting
 back, and submitting again, then hitting back I think you get the
 idea...
 What do you all do?
 Jason Pruim
 
 
 Hi,
 I am using $_SESSION for this. Set a value on the initial page, a
 timestamp is a good choice, then validate the value on the receiving
 script and clear the value.
 
 I like to use a timestamp because it will allow you to deny a comment
 which took too long to submit.
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 I've always tended to stay away from session for that, as when the
 browser closes/restarts, the page is accessible again.
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 I solved this issue with timestamps stored in the db with the submission. 
 With each submission, I took all the info that should make it uniqueish, and 
 checked if it was near another one. A time limit of 10th seconds worked out 
 well. The reason I had the problem was because we were triggering a counter 
 on an account from get data (which the browser can request in a way that 
 looks like multiple submissions). We should have used post, which didn't have 
 this problem though really.
 
 Will you please show an example of using this timestamp methodology?

Thank you

 

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



Re: [PHP] chained select with ajax

2011-08-14 Thread Chris Stinemetz
I was able to figure it out. Discovered the very useful tool firebug!

Thanks,

Chris

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



[PHP] form validation

2011-08-12 Thread Chris Stinemetz
I have a select menu created by a foreach loop. I am trying to
validate that there was a selection made before it is submitted to the
database. But I am not doing something correctly.

select name=market class=ajax
onchange=javascript:get(this.parentNode);
option value=Choose.../option
?php   
foreach($market_prefix as $key = $value)
{
$selected = '';
if($value == $market)
{
$selected = 'selected';
}
echo 'option value=', htmlspecialchars($value), ' ', $selected,
'', htmlspecialchars($market_name[$key]), '/option';
}
?
/select

I am using the folling on the posted page.

if (! array_key_exists($_POST['market'], $market_name))
{
echo You did not select a market.;
}

Thank you,

Chris

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



[PHP] form handling

2011-08-11 Thread Chris Stinemetz
I have two forms on the same php script. Is it possible to submit both
forms to the same action=processform.php with a single submit
button?

If so would you give me examples on how to handle this?

I will also continue searching google.

Thank you,

Chris

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



Re: [PHP] form handling

2011-08-11 Thread Chris Stinemetz

 If the two forms call the same script that's fine.  If not, that will work
 too.  Just realize that the inputs from one form will NOT be returned to the
 script when the submit is used from the other form.


Jim,

This is what I am trying to do. One submit button for both forms going
to the same destination.

The only reason I am doing this is because I can't figure out why my
ajax for my select menus is altering my tinyMCE textarea box.

Ultimately if I can figure out how to control the ajax within the div
container as I showed in a previous email I would be able to just use
one form. any ideas??

Thanks,

Chris

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



Re: [PHP] form handling

2011-08-11 Thread Chris Stinemetz
 Chris,
 By definition, a 'submit' button submits a form.  Not 2 forms.  Each form
 has to have it's own form. It is not feasible to submit two forms - since
 the conversation from your client pc is going to be garbled even if you
 could (JS?) do the second submit.  One transactiion is going to answer your
 client and then the other is going to wipe it out with its respone.

 I don't think you have ot separate your forms becuase they are in separate
 divs.  I could be wrong - never tried it.



I didn't think it was possible either. I will play around with the div
container and ajax some more tonight. Hope I will be able to figure it
out. Is it possible to place a div within the form to only affect the
select tags?

Thanks,

Chris

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



Re: [PHP] form handling

2011-08-11 Thread Chris Stinemetz

 I would bet it's the quotes screwing up the js. Can / are you escaping that 
 variable when ajaxing it back?

 Bastien Koert
 905-904-0334


I found a way to make the ajax work with one form. I removed the table
and the ajax worked just fine. Aparently you can't embed div
containers within a table without affecting the whole table. At least
that is what I found out tonight. Please correct me if I am wrong.

Chris

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



[PHP] text insertion

2011-08-10 Thread Chris Stinemetz
How do I preserve text formatting when text is inserted into a database table?

For example: I am using a textarea to allow users to leave comments
into the database and I am using:

' . mysql_real_escape_string($_POST['store_comments']) . ',   to
prevent SQL injection;

But when I call the data with php from the database the format it was
inserted is not preserved. Is there a way to make sure when a user
adds new paragraphs or indentation it will be preserved?

Thank you,

Chris

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



Re: [PHP] text insertion

2011-08-10 Thread Chris Stinemetz
 Are you sure its not preserved? When you output text in a browser, by default 
 its output as html, not plain text. Html ignores extraneous whitespace, and 
 doesn't use a monospaced font, so formatting text into columns in a textarea 
 won't work either. Look at the html source code to see what is actually being 
 output.

Thanks Ashley

Source is showing indentation and new paragaraphs just as I inserted
the text. How can I get HTML output to show same format?


Chris

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



Re: [PHP] text insertion

2011-08-10 Thread Chris Stinemetz

    Use HTML 'pre' tags:

        pre?php echo $your_content; ?/pre


I just tried that and that puts all the text on a single line.


echo 'tr class=topic-post
td class=user-poststrong' . $posts_row['first_name'] . ' ' .
$posts_row['last_name'] . ' ' . date('m-d-Y h:iA',
strtotime($posts_row['store_date'])) . '/strong/td
/tr
tr class=visit
td class=post-contentBroad Band test results:/strong ' .
$posts_row['store_tptest'] . 'br/br/pre'
.$posts_row['store_comments'] . '/pre/td
/tr';

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



Re: [PHP] text insertion

2011-08-10 Thread Chris Stinemetz
No luck. Thanks.

On Aug 10, 2011 4:17 PM, hdede...@videotron.ca wrote:

 how about

 echo nl2br($your_content);




 - Original Message -
 From: Chris Stinemetz chrisstinem...@gmail.com
 Date: Wednesday, August 10, 2011 5:09 pm
 Subject: Re: [PHP] text insertion
 To: Daniel P. Brown daniel.br...@parasane.net
 Cc: Ashley Sheridan a...@ashleysheridan.co.uk, PHP General 
php-general@lists.php.net

  
  Use HTML 'pre' tags:
  
  pre?php echo $your_content; ?/pre
  
 
  I just tried that and that puts all the text on a single line.
 
 
  echo 'tr class=topic-post
  td class=user-poststrong' . $posts_row['first_name']
  . ' ' .
  $posts_row['last_name'] . ' ' . date('m-d-Y h:iA',
  strtotime($posts_row['store_date'])) . '/strong/td
  /tr
  tr class=visit
  td class=post-contentBroad Band test results:/strong
  ' .
  $posts_row['store_tptest'] . 'br/br/pre'
  .$posts_row['store_comments'] . '/pre/td
  /tr';
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 


Re: [PHP] Problem with inserting numbers...

2011-08-10 Thread Chris Stinemetz

 basically all I'm trying to do is generate the last 4 digits starting at  
 and going up to . for testing purposes I'm just echoing back but will 
 eventually insert the complete number back into the database as a 7 digit 
 string.

 The error I'm getting is:

 Fatal error: Maximum execution time of 30 seconds exceeded in 
 /home/pruimpho/public_html/jason/dev/clients/flewid/Phone/config/phoneareacodes.php
  on line25


I'm not sure the to while loops is the best control structure.

Why not try the following and see if it gets you the results you want?

__untested__

while($row = mysql_fetch_assoc($result)) {
if ($num != 1)  $padnum = number_pad($num, 4)
{
echo $row['areacode'] . - . $row['prefix'] . - . $padnum . BR;
$num++;
}

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



[PHP] concatenating

2011-08-10 Thread Chris Stinemetz
Is it possible to concatenate a string and an element from a
mysql_fetch_assoc array? I haven't had much luck searching google.

Such as concatenating results with ' . $posts_row['store_tptest'] .
' so that if there are no elements returned nothing will be displayed?

Thank you,

Chris

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



Re: [PHP] pass text variables to next page

2011-08-09 Thread Chris Stinemetz
Thank you Tamara.

Not sure if I am doing it right. It looks like the last single quote
is being escaped.

When I dump the query I get:

SELECT store_id, store_subject FROM stores WHERE store_subject =
'Bella Roe 4980 Roe Blvd\'


I am thinking maybe I have too many single quotes some where, but I
can't find it.

echo 'h4a href=store.php?id=' . $storerow['store_subject'] . ''
. $storerow['store_subject'] . '/a/h4 at ' . date('m-d-Y',
strtotime($storerow['store_date']));


The query:

$sql = SELECT store_id, store_subject
FROM stores
WHERE store_subject = ' . mysql_real_escape_string($_GET['id'].');


Thank you,

Chris

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



[PHP] form hidden value

2011-08-08 Thread Chris Stinemetz
I'm trying to pass a hidden value with my form submission. Not sure what I
am doing woring, but the value is not being passed.

Query is___

$query = SELECT id, store_name FROM store_list WHERE store_type =
'$type' AND id_market = '$market'   ;
$result = mysql_query($query) or die(report($query,__LINE__ ,__FILE__));


while($row = mysql_fetch_array($result))
{
$store_name[] = $row['store_name'];
$id[] = $row['id'];

}
sort($store_name);
}



Form portion is

input type=hidden name=id value=?php echo '$id[]';?

Any help is greatly appreciated. Thank you.


[PHP] pass text variables to next page

2011-08-08 Thread Chris Stinemetz
I am trying to pass text strings from on page to a next to populate
the queries on the passed to page.

The only way I can get the query to work is if I am able to put single
ticks around the string to make it literal, but I can't seem to figure
out how to do it for the following line of code.

echo 'h3a href=store.php?id=' . $row['store_name'] . '' .
$row['store_name'] . '/abr /h3' . $row['store_type'];

When i do a dump the query and
print(pre.print_r($_GET,true)./pre);

I get the following respectively:


SELECT store_id, store_subject FROM stores WHERE store_subject = Loma
Vista 8712 Blue Ridge BlvdThe topic could not be displayed, please try
again later.You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the right syntax to
use near 'Vista 8712 Blue Ridge Blvd' at line 3

The PHP code for the query is:



Array
(
[id] = Loma Vista 8712 Blue Ridge Blvd
)

$sql = SELECT store_id, store_subject
 FROM stores
 WHERE store_subject =  . mysql_real_escape_string($_GET['id']);

The query works fine When I run the command in console and place ''
around  Loma Vista 8712 Blue Ridge Blvd

Thank you,

Chris

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



Re: [PHP] control structure

2011-08-04 Thread Chris Stinemetz

        // This part makes no sense they are not logged in and they have a
 level of 1 or 2 ?

Yes. It might not be the best approach, but I am assigning the user a
value: 1, 2, or 3 while they create an account. This will limit what
they will be able to post. For example I only want users with user
level of 1 or 2 to be able to complete the form in this script. Hence,
the control structure I am trying to include.

        // And you was missing a Pipe after false. It will cause the If
 statement to fail.

Thanks for pointing this out. I quess I have been staring at the
computer way too long!

Chris

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



[PHP] PHP frameworks

2011-07-21 Thread Chris Stinemetz
Hello all,

I am thinking about venturing into PHP frameworks, but I would like to
get advice on what the correct selection would be for someone that is
about intermediate in PHP knowledge.

Thank you,

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



[PHP] default option

2011-07-18 Thread Chris Stinemetz
Hello,

I am building some select menu's dynamically from a mysql database and
am courous how to give the menu a default option Choose.

Below is what I have so far for one of my menu's.

Thank you in advace.

select name=market id=market
onchange=javascript:get(this.parentNode);
?php
foreach($market_prefix as $key = $value)
{
$selected = '';
if($value == $market)
{
$selected = 'selected';
}
echo(option value=$value $selected
$value : $market_name[$key]);
}
?
/select

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



Re: [PHP] default option

2011-07-18 Thread Chris Stinemetz
Thank you Stuart. That did the trick.

On Mon, Jul 18, 2011 at 10:38 PM, Stuart Dallas stu...@3ft9.com wrote:
 On Tue, Jul 19, 2011 at 4:28 AM, Chris Stinemetz chrisstinem...@gmail.com
 wrote:

 Hello,

 I am building some select menu's dynamically from a mysql database and
 am courous how to give the menu a default option Choose.

 Below is what I have so far for one of my menu's.

 Thank you in advace.

                    select name=market id=market
 onchange=javascript:get(this.parentNode);
                    ?php
                        foreach($market_prefix as $key = $value)
                            {
                            $selected = '';
                            if($value == $market)
                            {
                            $selected = 'selected';
                            }
                            echo(option value=$value $selected
 $value : $market_name[$key]);
                            }
                            ?
                    /select

 Just add it as the first option. If none of the options have the selected
 attribute, the first option will be the selected one.
 I'd also recommend you escape the variables you're outputting, on the off
 chance they contain HTML-like code.
 select name=market id=market onchange=if (this.value != '') {
 javascript:get(this.parentNode); }
   option value=Choose.../option
 ?php
   foreach($market_prefix as $key = $value)
   {
     $selected = '';
     if ($value == $market)
     {
       $selected = 'selected';
     }
     echo 'option value=', htmlspecialchars($value), ' ', $selected, '',
 htmlspecialchars($value.' : '.$market_name[$key]), '/option';
   }
 ?
 /select
 -Stuart

 --
 Stuart Dallas
 3ft9 Ltd
 http://3ft9.com/

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



[PHP] chained select with ajax

2011-07-17 Thread Chris Stinemetz
This is a [Cross-post] I didn't receive any feedback from phpdb list.
Hope fully there is someone out there that may offer some advice why
my code isn't working correctly.

Thanks all.

I am trying to create a cascading seletct with 3 menu choices.
For some reason my third select menu is not populating. It doesn't
seem like my ajax is correctly sending $_post values to the final
query in my PHP class I built.
By the time I make it to the final third select menu there are no choices.

Hopefully someone can find something I missed in the following code snippits.

Any help is greatly appreciated.

Please excuse the incorrect indentions. For some reason gmail changes it.

Thanks,

Chris

ajax code...

   script
   $(document).ready(function(){
   $(select#type).attr(disabled,disabled);
   $(select#store).attr(disabled,disabled);
   $(select#market).change(function(){
   $(select#type).attr(disabled,disabled);
   $(select#type).html(optionplease wait.../option);
   var id = $(select#market option:selected).attr('value');
   $.post(select_type.php, {id:id}, function(data){
   $(select#type).removeAttr(disabled);
   $(select#type).html(data);
   });
   });

   $(select#type).change(function(){
   $(select#store).attr(disabled,disabled);
   $(select#store).html(optionplease
wait.../option);
   var id = $(select#type option:selected).attr('value');
   $.post(select_store.php, {id:id}, function(data){
   $(select#store).removeAttr(disabled);
   $(select#store).html(data);
   });
   });




   $(form#select_form).submit(function(){
   var market = $(select#market option:selected).attr('value');
   var type = $(select#type option:selected).attr('value');
   var store = $(select#store
option:selected).attr('value');
   if(market0  type0  store0)
   {
   var market = $(select#market option:selected).html();
   var type = $(select#type
option:selected).html();
   var store = $(select#store
option:selected).html();
   $(#result).html('your choices were: '+market +' ,
'+type +' and '+store);
   }
   else
   {
   $(#result).html(you must choose three options!);
   }
   return false;
   });
   });
   /script


php class for populating select menus

?php
class SelectList
{
   protected $conn;
   public function __construct()
   {
   $this-DbConnect();
   }
   protected function DbConnect()
   {
   include db_config.php;
   $this-conn =
mysql_connect($host,$user,$password) OR die(Unable
to connect to the database);
   mysql_select_db($db,$this-conn) OR die(can
not select the database $db);
   return TRUE;
   }
   public function ShowMarket()
   {
   $sql = SELECT DISTINCT id_markets FROM store_list;
   $res = mysql_query($sql,$this-conn);
   $market = 'option value=0market.../option';
   while($row = mysql_fetch_array($res))
   {
   $market .= 'option value=' .
$row['id'] . '' .
$row['id_markets'] . '/option';
   }
   return $market;
   }

   public function ShowType()
   {
   $sql = SELECT DISTINCT store_type FROM store_list;
   $res = mysql_query($sql,$this-conn);
   $type = 'option value=0store type.../option';
   while($row = mysql_fetch_array($res))
   {
   $type .= 'option value=' . $row['id'] . '' .
$row['store_type'] . '/option';
   }
   return $type;
   }

   public function ShowStore()
   {
   $sql = SELECT store_name FROM store_list WHERE
id_markets=$_POST[id] AND store_type=$_POST[id];
   $res = mysql_query($sql,$this-conn);
   $Store = 'option value=0stores.../option';
   while($row = mysql_fetch_array($res))
   {
   $Store .= 'option value=' . $row['id'] . '' .
$row['store_name'] . '/option';
   }
   return $Store;
   }
}

$opt = new SelectList();

?

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



Re: [PHP] A Question On Web Graphics

2011-07-12 Thread Chris Stinemetz

   Also I have successfully experimented with Apache and PHP but have not yet
 identified graphics applications for this venue either! Ideas?


You may want to look into PHP:GD

link to manual: http://php.net/manual/en/book.image.php


HTH,

Chris

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



[PHP] PHP control structure

2011-07-12 Thread Chris Stinemetz
Hey all,

I would like to add an if statement to the following function so that
the value 1 is assigned corporate and the value is 2 assign
standard to it.  Would you show me an example on adding it to the
below function? If there is a better way to reassign the value please
share.

Thank you,

Chris

public function ShowType()
{
$sql = SELECT DISTINCT store_type FROM store_list WHERE
id_markets=$_POST[id];
$res = mysql_query($sql,$this-conn);
$Type = 'option value=0store type.../option';
while($row = mysql_fetch_array($res))
{
$Type .= 'option value=' . $row['id_store'] . 
'' .
$row['store_type'] . '/option';
}
return $Type;
}

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



Re: [PHP] Linking A C Program Example to PHP

2011-07-11 Thread Chris Stinemetz
On Sun, Jul 10, 2011 at 4:56 PM, Thomas Dineen tdin...@ix.netcom.com wrote:
 Gentle People:


   Please Help!

   I am attempting to link a C Program example to PHP using the
 tutorial shown at the link below:
 http://voloreport.com/making-a-c-extension-for-php-in-11-easy-steps

   Everything worked fine up through step 9 in the tutorial:

   Now the problem:

   The example works fine from the command line with either of the
 commands shown below:

 php test.php
 php -c /etc/apache2/php.ini test.php

   But the example will NOT work via the web browser on my Apache 2
 (2.2.17) / PHP (5.3.5) Web Server!


Have you looked into apache error log?

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



Re: RES: [PHP] Installing PHP

2011-07-04 Thread Chris Stinemetz
Jim,

What is your server root set up too? I would put the apache configuration
back to the way it was and then place php script with phpinfo() function in
it. Try to run it and see if that works.

HTH,

Chris
On Jul 4, 2011 8:14 AM, Alejandro Michelin Salomon (Hotmail) 
amichel...@hotmail.com wrote:
 Jim:
 In my Windows the install adds the lines :

 #BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
 PHPIniDir C:\PHP\
 LoadModule php5_module C:\PHP\php5apache2_2.dll

 AddHandler application/x-httpd-php .php
 #END PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL

 Where is the apache version that you install?

 I have the apache 2.2.17

 This  php5apache2.dll  is for the version 2.0.x
 And this  php5apache2_2.dll  for the version 2.2.x

 Maybe the dll files is in the brong version.

 Alejandro M.S.

 -Mensagem original-
 De: Jim Giner [mailto:jim.gi...@albanyhandball.com]
 Enviada em: segunda-feira, 4 de julho de 2011 09:40
 Para: php-general@lists.php.net
 Assunto: [PHP] Installing PHP

 Hi all,
 (Hopefully I posted this in a place that can/will help me)

 I got curious about running php / apache on my own laptop in order to help
 my devl process, instead of writing, uploading and testing on my site.

 Found a nice pair of docs from thesitewizard.com that appeared to be
 pretty well-written instructions on installing each of these systems. btw-
 I'm running XpSp2. Chose the Apache 2.0 and PHP 5.2 (thread-safe?) per the
 recommendations.

 Went thru all instructions step-by-step, testing all the way. Apache
 works - PHP doesn't. When I bring up IE and type in localhost I get the
 default apache page as I was told I should see. When I type
 localhost/test.php I get a windows dialog asking what program should run
 the php script.

 In debugging I went to a cmd windows and ran c:\php\php-cgi test.php and
 got the expected result from my script - so PHP works.

 End result - they each work separately, but php is not working under
apache.

 As part of the docs instructions I added the following code to the apache
 conf file:

 1 - I chose the configure apache to run php as an apache module.
 2 - added LoadModule php5_module c:/php/php5apache2.dll as last one of
 those lines
 3 - added AddType application/x-httpd-php .php as the last of those
lines
 4 - added PHPIniDir c:/php as the last line of the conf file.

 Upon adding these lines apache will no longer restart. In fact adding any
 ONE of these lines breaks Apache.

 Ideas welcome.

 And for those who still love the USofA, Happy Independence Day!





 --
 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] Re: Installing PHP

2011-07-04 Thread Chris Stinemetz
What is your document root set to in your httpd.conf file? By default it should 
be htdocs subdirectory in apache program files.

Sent from my iPod

On Jul 4, 2011, at 12:10 PM, Jim Giner jim.gi...@albanyhandball.com wrote:

 Shawn,
 I added my php folder to the path but no change.
 
 Shawn McKenzie nos...@mckenzies.net wrote in message 
 news:4e11e7e7.6010...@mckenzies.net...
 
 
 You may need to add c:\php\ to the Windows path so that the Apache mod
 can find other files it may need. If you have mysql or other extensions
 enabled in php.ini, then they may be looking for another dll that is
 located in the php dir.
 
 
 
 -- 
 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] Installing PHP

2011-07-04 Thread Chris Stinemetz
On Mon, Jul 4, 2011 at 8:13 AM, Alejandro Michelin Salomon (Hotmail)
amichel...@hotmail.com wrote:
 Jim:
 In my Windows the install adds the lines :

 #BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
 PHPIniDir C:\PHP\
 LoadModule php5_module C:\PHP\php5apache2_2.dll

 AddHandler application/x-httpd-php .php
 #END PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL

 Where is the apache version that you install?

 I have the apache 2.2.17

 This  php5apache2.dll  is for the version 2.0.x
 And this  php5apache2_2.dll  for the version 2.2.x

 Maybe the dll files is in the brong version.

 Alejandro M.S.


Jim,

Alejandro makes a valid point. There is a naming convention change
from apache 2.0. to 2.2 for the dll file. I know in your original post
you specified that you loaded 2.0, but you may want to double check.
Since 2.2 requires php5apache2_2.dll to work correctly.

Just a thought,

Chris

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




Re: [PHP] Re: [PHP-DB] Re: radio form submission

2011-06-24 Thread Chris Stinemetz
That worked perfectly!

Thank you,

Chris

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



Re: [PHP] Re: [PHP-DB] Re: radio form submission

2011-06-24 Thread Chris Stinemetz
 radio select validation 

What I am doing wrong?

I want to make sure a radio button is selected, but my current code
allows insertion even when radio button isn't selected.

My code is:

//Generating radio buttons for store type with 
array
echo 'Store type:br /br /';
$choices = array('corporate' = 
'Cricket owned | ',
 
'premier' = 'Premier dealer');
 
foreach ($choices as $key = $choice) {

 echo input type='radio' name='store_type' value='$key'/
$choice \n;
}
//Validate the radio button submission
if 
(!array_key_exists($_POST['store_type'], $choices)) {

echo You must select a valid choice.;
}


Thanks

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



Re: [PHP] php hide menu

2011-06-07 Thread Chris Stinemetz
 If you do require the value from the first menu to be passed to the select
 statements for the other menus let me know I will explain how that is done,
 it is a little more complex.


I would like to pass the value from the prior menu to the next. Would
you please show me how to handle this?

Thank you,

Chris

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



[PHP] php hide menu

2011-06-06 Thread Chris Stinemetz
I have three drop down menus in my form. How do I make it so the
second and third menus are only visible once the prior menu was
selected?

Below is the first two drop down menus.

Thanks in advance.

// Generating first menu using array.
$markets = array('MCI' = 'Kansas City',
  'STL' = 'ST. Louis',
  'ICT' = 'Wichita',
  'OMA' = 'Omaha',
  'LIN' = 'Lincoln');
echo select name='term'option value=''Choose Market/option\n;
foreach ($markets as $key = $market) {
echo option value='$key'$market/option\n;
}
echo /select;

// This will evaluate to TRUE so the text will be printed.
if (isset($markets)) {
echo This var is set so I will print.;
}



// Then, later, validating the menu
if (! array_key_exists($_POST['Market'], $choices)) {
echo You must select a market.;
}

$query=SELECT cell_sect FROM sector_list order by cell_sect;

$result = mysql_query ($query);
echo select name='cat'option value=''Choose Cell Sector/option;
// printing the list box select command

while($cellSect=mysql_fetch_array($result)){//Array or records stored
in $cellSect
echo option value=$cellSect[cell_sect]$cellSect[cell_sect]/option;
/* Option values are added by looping through the array */
}
echo /select;// Closing of list box

// This will evaluate to TRUE so the text will be printed.
if (isset($cellSect)) {
echo This var is set so I will print.;
}

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



[PHP] PHP delete confirmation

2011-04-28 Thread Chris Stinemetz
I have been trying to figure out how to add delete confirmation for
the bellow snippet of code. I would prefer not to use javascript. Can
anyone offer any advise on how to right the delete confirmation in
PHP?

Thank you in advance.

P.S. I apologize for the indention. For some reason gmail messes it up.

?php
   // loop through results of database query, displaying them in the table
   while($row = mysql_fetch_array( $result )) {

// echo out the contents of each row into a table
   echo tr;
   echo 'td' . $row['Name'] . '/td';
   echo 'td' . $row['Date'] . '/td';
   echo 'td' . $row['StoreInfo'] . '/td';
   echo 'td' . $row['Address'] . '/td';
   echo 'td' . $row['Type'] . '/td';
   echo 'td' . $row['EngTech'] . '/td';
   echo 'td' . $row['StoreManager'] . '/td';
   echo 'td' . $row['BBtime'] . '/td';
   echo 'td' . $row['BBup'] . '/td';
   echo 'td' . $row['BBdown'] . '/td';
   echo 'td' . $row['SiteSect'] . '/td';
   echo 'td' . $row['VoiceCall'] . '/td';
   echo 'td' . $row['Comments'] . '/td';
   echo 'tda href=edit.php?id=' . $row['id']
.'Edit/a/td';
   echo 'tda href=delete.php?id=' . $row['id']
.'Delete/a/td';
   echo /tr;
   }

   // close table
   echo /table;
?

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



[PHP] LDAP, Active Directory, and permissions

2010-11-30 Thread Chris Knipe
Hi,

I've found various sources and are successfully manipulating Active
Directory from PHP on our Domain Controller - frankly, things works much
better than I expected :)

I have now reached the point where I need to set permissions on objects in
Active Directory, i.e. to restrict read permissions to certain OUs and
objects within the directory (mainly related to Exchange stuff).

Is there anything in PHP which can be used to set permissions on AD
objects?  I haven't found any reference to doing this anywhere, so I thought
I'd give it a chance here... If not, then I suppose I'll have to code some
..NET application to act as a gateway between the PHP interface and Active
Directory, but naturally I would like to do as much as possible from within
PHP itself.

Many thanks,


-- 

Regards,
Chris Knipe


RE: [PHP] LDAP, Active Directory, and permissions

2010-11-30 Thread Chris Knipe
Hi,

 Chris,
 
 1) Shouldn't the OU security permissions be set within the AD itself?
 2) If the above is done, then the user account that's being authenticated
 shouldn't be able to access privileged information.

1) Not sure.  The permissions I'm after is similar to that of NTFS
permissions on the file system.  Essentially, it is a way to restrict an
application to read certain OU's or Objects completely, making it invisible.
FYI... http://technet.microsoft.com/en-us/library/cc785913(WS.10).aspx

2) This is completely irrelevant to authentication.  See point 1 above.
 
 Just curious, are you using phpldapadmin?

A modified version of adLDAP, http://adldap.sourceforge.net/

Regards,
Chris.



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



Re: [PHP] My truth comes out [1]

2010-10-21 Thread chris h
settype looks like a no-go for this; per the php docs...
http://php.net/manual/en/function.settype.php
--
$bar = true;   // boolean
settype($bar, string);  // $bar is now 1 (string)
--


I think using a conditional here is the best (only?) way.

$bool = (strtolower($string)=='true')? true: false;

and if the default should be true...

$bool = (strtolower($string)=='false')? false: true;

If you you're going to use it a lot then wrap it in a function.


Also, (as was stated) preg_ is overkill here. php has a lot of nifty string
functions that should be taken advantage of before jumping onto regex.

Chris.


On Thu, Oct 21, 2010 at 6:01 AM, a...@ashleysheridan.co.uk 
a...@ashleysheridan.co.uk wrote:

 That's as bad as an if!

 What about using settype() on the string? I've not tested it, but it looks
 like it should do the trick.

 Thanks,
 Ash
 http://www.ashleysheridan.co.uk

 - Reply message -
 From: Russell Dias rus...@gmail.com
 Date: Thu, Oct 21, 2010 10:51
 Subject: [PHP] My truth comes out [1]
 To: php-general@lists.php.net

 preg_match(/false/i, $string) ? false : true;



 On Thu, Oct 21, 2010 at 7:39 PM, Gary php-gene...@garydjones.name wrote:
  Is there any nice way to convert a string containing either TRUE or
  FALSE to a bool with the appropriate value? I know I can just if
  (strcmp... but, as the song goes on to say ...ugly, so ugly, it's
 ugly[1]
 
  Footnotes:
  [1]  Mask, Henry Rollins
 
  --
  Gary
 
 
  --
  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] Execute a php page and don't wait for it to finish

2010-10-19 Thread chris h
What about simply having the script trip a flag that another background
script checks every 60 seconds or so?

Once a minutes a background script checks to see if it needs to preform any
tasks.
When a user hits a certain page it does an ajax request to trip this flag
and immediately returns.
The next time the background script checks if it needs to do anything, it
sees the tripped flag and preforms the relevant database copy - or whatever
:-)


Chris.

On Tue, Oct 19, 2010 at 9:20 AM, Ferdi ferdinan...@printo.in wrote:

 Hi List,

 I have a php page that updates data from one database to another when it is
 run.
 My query is, how can I trigger the execution of this update page from
 another php / javascript without the calling page having to wait for the
 update page to finish?
 Basically, I think the update page needs to use:
 ignore_user_abort(1);
 set_time_limit(0); // I don't think the script will take more than 1 min.

 At the other end I found this:
 1)

 http://www.mindraven.com/blog/php/run-a-php-script-in-the-background-using-ajax/
 2) On that page a user suggested using *pclose(popen(‘/usr/bin/php
 /path/to/something.php  /dev/null ’, ‘r’)*
 **However, I need this to be usable on windows servers also.
 3) Finally, would pcntl_exec, pcntl_fork, exec or something be useful for
 me?

 Which of the above 3 options is the better one?
 Other suggestions are welcome :)

 Thanks and Regards,
 Ferdi



Re: [PHP] require_once

2010-10-19 Thread chris h

  I'm having a problem including files using Zend Framework. I have in a
 controller file this


Jim why not use the Zend autoloader?


Chris.


Re: [PHP] require_once

2010-10-19 Thread chris h
I see!

Yes using an autoloader typically requires following a naming convention for
your classes (though you can get around it by defining your own naming
rules).  I didn't care for it much at first, but it's nice that class names
are explicit (less confusion when you have several) and not worrying about
requiring all your files is a plus.


Chris.

On Tue, Oct 19, 2010 at 10:00 AM, jim jbw2...@earthlink.net wrote:

  I am following an example. Also, doesn't that require the class name to be
 something like models_members?

 Jim


 On 10/19/2010 09:40 AM, chris h wrote:

   I'm having a problem including files using Zend Framework. I have in a
 controller file this


  Jim why not use the Zend autoloader?


  Chris.





Re: [PHP] simple class constructor

2010-10-19 Thread chris h
Can you paste the index page's code here?  If the page is going blank
there's probably an error (syntax, bad file path, etc).  If you have access
you can turn error reporting on so you can actually see the error - or
better yet check the php error log file.  Settings for both of these are in
the php.ini file, though sometimes they can be overridden by apache
directives (depending on the setup).

http://php.net/manual/en/ini.core.php


Chris.


On Tue, Oct 19, 2010 at 4:12 PM, David McGlone da...@dmcentral.net wrote:

 Hi everyone,

 I've been really good at googling to find my answers, but this time my
 method isn't working for me.

 I have created a very simple class and a constructor hoping to get a
 much better understanding of how to work with them. The code works, but
 because it's very simple, I'm not sure that the way  I'm trying to
 access it is possible.

 All I'm trying to do is access the class from outside the function.
 (is that how to describe it?)

 For instance I have this simple code:

 class simpleConstructer {

 function __construct() {
echo running the constructor;
 }
 }

 $test=new simpleConstructer();


 Basically I want to learn how I can (if it's possible with this simple
 code) is display the output on a different page.

 I tried putting the line: $test=new simpleConstructer(); on the index
 page and including the page the class is on, but it causes the index
 page to go blank.

 The thought of a session crossed my mind, but I'm pretty confident at my
 level to know I don't need a session.

 Could someone point me in the right direction or give me some pointers,
 advice?

 --
 Blessings
 David M.


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




Re: [PHP] simple class constructor

2010-10-19 Thread chris h
Also wanted to point out that you can check the error reporting level and
log file location (really all of the php's settings) by calling   phpinfo();
 in your code.

?php

phpinfo();


?


Chris.



On Tue, Oct 19, 2010 at 4:54 PM, chris h chris...@gmail.com wrote:


 Can you paste the index page's code here?  If the page is going blank
 there's probably an error (syntax, bad file path, etc).  If you have access
 you can turn error reporting on so you can actually see the error - or
 better yet check the php error log file.  Settings for both of these are in
 the php.ini file, though sometimes they can be overridden by apache
 directives (depending on the setup).

 http://php.net/manual/en/ini.core.php


 Chris.


 On Tue, Oct 19, 2010 at 4:12 PM, David McGlone da...@dmcentral.netwrote:

 Hi everyone,

 I've been really good at googling to find my answers, but this time my
 method isn't working for me.

 I have created a very simple class and a constructor hoping to get a
 much better understanding of how to work with them. The code works, but
 because it's very simple, I'm not sure that the way  I'm trying to
 access it is possible.

 All I'm trying to do is access the class from outside the function.
 (is that how to describe it?)

 For instance I have this simple code:

 class simpleConstructer {

 function __construct() {
echo running the constructor;
 }
 }

 $test=new simpleConstructer();


 Basically I want to learn how I can (if it's possible with this simple
 code) is display the output on a different page.

 I tried putting the line: $test=new simpleConstructer(); on the index
 page and including the page the class is on, but it causes the index
 page to go blank.

 The thought of a session crossed my mind, but I'm pretty confident at my
 level to know I don't need a session.

 Could someone point me in the right direction or give me some pointers,
 advice?

 --
 Blessings
 David M.


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





Re: [PHP] Buffering output to allow headers late in code?

2010-10-14 Thread chris h


 I'm working through my class on PHP and I tried to put information from my
 sign-on process in the navbar. This didn't work well, since I had to reload
 the page to see it as the navbar was constructed earlier in the code than
 the signon process. (Hard to explain, as we are building a dynamic web
 page with lots of include files to fill in the main contnt portion of the
 page.)


I don't know if this will be much help, but I try to do all the controller /
model work before I mess with the view side.  So the controller starts off
with the ball, then he and the model pass it between each other a few times
until the controller finally hands it over to the view, who does her magic
and makes the score! ... Perhaps that analogy went to far.

At any rate!  Ideally the sign-on task would be done before any tasks that
would use sign-on data. Additionally, the layout of your page should
not necessarily dictate the order of any tasks (i.e. the sign-on box being
below the welcome box should not mean that the sign-on task gets done before
the welcome task).


Hope that helps!
Chris.


Re: [PHP] floored by floor()

2010-10-14 Thread chris h
floor(32703) is different then floor(327.03 * 100).  The former is an int,
while the later is a float.  Read those links that were sent :)


Chris.


On Thu, Oct 14, 2010 at 2:14 AM, Glen Fuller glenmful...@shaw.ca wrote:

 On 10/13/2010 10:48 PM, Mattias Thorslund wrote:

 Hi List,

 I'm having a problem with the behavior of the floor() function:

 echo floor(327.03 * 100).\n; //prints 32702 and not 32703!!

 Sanity check:
 var_dump(327.03 * 100); //prints float(32703) as expected

 Any ideas why this happens, and how to work around it?

 Thanks,

 Mattias



 Wouldn't that be equivalent to floor(32703), and since 32703 is the nearest
 integer to 32703 it returns it?

 Glen Fuller



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




Re: [PHP] Text messaging from the web

2010-10-14 Thread chris h

 You can send a text message via email:

Verizon: 10digitphonenum...@vtext.com
ATT: 10digitphonenum...@txt.att.net
Sprint: 10digitphonenum...@messaging.sprintpcs.com
T-Mobile: 10digitphonenum...@tmomail.net
Nextel: 10digitphonenum...@messaging.nextel.com
Cingular: 10digitphonenum...@cingularme.com
Virgin Mobile: 10digitphonenum...@vmobl.com
Alltel: 10digitphonenum...@message.alltel.com
CellularOne: 10digitphonenum...@mobile.celloneusa.com
Omnipoint: 10digitphonenum...@omnipointpcs.com
Qwest: 10digitphonenum...@qwestmp.com


Larry, it seems like this method would only be useful if you knew the
carrier of a specific number.  Do you know of a way to determine that?


Chris.


Re: [PHP] Re: Buffering output to allow headers late in code?

2010-10-14 Thread chris h


 Then someone said that using buffering was a bad idea and I should disable
 it.


I think it leads to poor habits like calling controller methods out of the
view (essentially what you are wanting to use it for). Using it like that is
asking for spaghetti code that's hard to maintain, scale, and train new
developers on.  I'd imagine it also adds overhead, though I don't know how
much - my guess is negligible.

OB can be a great tool, but it shouldn't be a hack to get around sloppy
architecture.

Just my 2 cents :)
Chris.


Re: [PHP] class object vs array for db table model

2010-10-12 Thread chris h
On Tue, Oct 12, 2010 at 2:38 AM, Tommy Pham tommy...@gmail.com wrote:

 Hi everyone,

 It's been a couple years since I've did a project in PHP.  The current
 project I'm working on is for PHP 5.3 and I noticed a performance issue.
  Is
 it just me or is there a BIG difference in performance between class object
 vs array for PHP 5.3?  Below is the sample:

 class MyTable
 {
private $_id; // int
private $_name; // varchar
private $_description; // text

public  function __construct() {}

public function getId()
{
return $this-_id;
}
public function getName()
{
return $this-_name;
}
public function getDescription()
{
return $this-_description;
}

public function setId($id)
{
$this-_id = $id;
}
public function setName($name)
{
$this-_name = $name;
}
public function setDescription($description)
{
$this-_description = $description;
}
 }

 $my_table = array ('id' = 'id value', 'name' = 'name value',
 'description'
 = 'long description text');

 The above are representations for my table as class and as array,
 respectively.  The only difference is how I represent the results from db:

 1) as class object
 $list = array();
 while ($row = $db-fetch($result))
 {
$my_table = new MyTable();
$my_table-setId($row['id']);
$my_table-setName($row['name']);
$my_table-setDescription($row['description']);

$list[$my_table-getId()] = $my_table;
 }

 2) as table
 $list = array();
 while ($row = $db-fetch($result))
 {
$my_table['id'] = $row['id'];
$my_table['name'] = $row['name'];
$my_table['description'] = $row['description'];

$list[$my_table['id'] = $my_table;
 }

 The performance difference I get is about 1.4 seconds with the array in the
 lead!!!  Does anyone have the same problem?

 Thanks,
 Tommy

 PS: The above executed in 4.2 sec and 1.8 sec (on average) respectively w/o
 actually showing the results to html, while my ASP.NET project executes it
 and displays in html in about 2 seconds for all 3684 rows, using class
 similar to the MyTable.  All codes, PHP  ASP.NET C#, access the same
 MySQL
 DB on the same development box.


When you are adding a row as an object you are calling 4 user
functions: MyTable::__construct(), MyTable::setId(),
MyTable::setName(),
and MyTable::setDescription().  This adds some overhead for sure, so you
might want to think about passing the row array into the construct and doing
away with the setters (at least for the initial instantiations).

Something like this...

-
public  function __construct($dataArray=null)
{
  foreach ((array)$dataArray as $rowKey = $rowValue)
  {
$this-$rowKey = $rowValue;
  }
}
==OR==
public  function __construct($dataArray=null)
{
  // maybe add casting here as well?
  $this-_id  = isset($dataArray['id'])?
  $dataArray['id']: null;
  $this-_name = isset($dataArray['name'])?
$dataArray['name']: null;
  $this-_description  = isset($dataArray['description'])?
 $dataArray['description']: null;

}
==And instantiate like this==
$list = array();
while ($row = $db-fetch($result))
{
  // I also changed setting the $list's key with $row['id'] instead of
using the MyTable getter.
  $list[$row['id']] = new MyTable($row);
}
---

I don't know how much faster that will run for you (if at all) but using
your method you were calling 5 user functions per result set from the db
(that's the construct, the getter to set the $list key, and 1 for each of
the 3 properties of the result) for a total of 18,420 user function calls.
 With my method I'm calling 1 user function (the construct) for each set,
for a total of 3,684 calls.  Of course a down-side is that if there's any
logic in your setters then that needs to be replicated in your construct.

Another method is to use a single object for all 3684 records.  Perhaps you
can use the built in Iterator interface which lets your class's objects be
used as if they were an array for the purposes of foreach loops.
http://php.net/manual/en/language.oop5.iterations.php
You would set a pointer to the record you wish to use, and your getters and
setters would key off that element of the master array.  This should be a
fast solution, while still giving you the power of encapsulation, getters
and setters.


Hope that helps!
Chris.


Re: [PHP] class object vs array for db table model

2010-10-12 Thread chris h
hehe that's pretty funny; also funny oversight of mine in regards to
isset()... so I guess we're both comedians today?  ;-)

Glad you got that worked out Tommy!

Chris.


On Tue, Oct 12, 2010 at 8:46 AM, Tommy Pham tommy...@gmail.com wrote:

 On Tue, Oct 12, 2010 at 4:45 AM, chris h chris...@gmail.com wrote:
 

 snip

 
 
  When you are adding a row as an object you are calling 4 user
  functions: MyTable::__construct(), MyTable::setId(), MyTable::setName(),
 and
  MyTable::setDescription().  This adds some overhead for sure, so you
 might
  want to think about passing the row array into the construct and doing
 away
  with the setters (at least for the initial instantiations).
  Something like this...
  -
  public  function __construct($dataArray=null)
  {
foreach ((array)$dataArray as $rowKey = $rowValue)
{
  $this-$rowKey = $rowValue;
}
  }
  ==OR==
  public  function __construct($dataArray=null)
  {
// maybe add casting here as well?
$this-_id  = isset($dataArray['id'])?
$dataArray['id']: null;
$this-_name = isset($dataArray['name'])?
  $dataArray['name']: null;
$this-_description  = isset($dataArray['description'])?
   $dataArray['description']: null;
  }
  ==And instantiate like this==
  $list = array();
  while ($row = $db-fetch($result))
  {
// I also changed setting the $list's key with $row['id'] instead of
  using the MyTable getter.
$list[$row['id']] = new MyTable($row);
  }
  ---
  I don't know how much faster that will run for you (if at all) but using
  your method you were calling 5 user functions per result set from the db
  (that's the construct, the getter to set the $list key, and 1 for each of
  the 3 properties of the result) for a total of 18,420 user function
 calls.
   With my method I'm calling 1 user function (the construct) for each set,
  for a total of 3,684 calls.  Of course a down-side is that if there's any
  logic in your setters then that needs to be replicated in your construct.
  Another method is to use a single object for all 3684 records.  Perhaps
 you
  can use the built in Iterator interface which lets your class's objects
 be
  used as if they were an array for the purposes of foreach loops.
  http://php.net/manual/en/language.oop5.iterations.php
  You would set a pointer to the record you wish to use, and your getters
 and
  setters would key off that element of the master array.  This should be a
  fast solution, while still giving you the power of encapsulation, getters
  and setters.
 
  Hope that helps!
  Chris.
 

 Hi Chris,

 Thanks for the reply.  The sample I made is just for simplicity and
 comparison.  As for function calling 'get's, I think the speed would
 come out to be same in your sample since you're doing isset()
 checking.  My actual class is more sophisticated having the psuedo
 overloading as you mentioned.  The class is generated from a PHP class
 builder - to save on typing - I made a long time ago with some minor
 update.

 Anyway, I was frustrated as to why my code took so long to execute and
 had to dig deep.  As it turns out, I had xdebug loaded with all
 options on ... lol.  Removed the extension and all is good in the
 world.  The script runs in less than 150ms :D!!!

 Thanks,
 Tommy

 PS:  This is what I get for not coding in PHP so long ...



Re: [PHP] Array / form processing

2010-10-07 Thread chris h
$_SESSION['life_coaching_order'][$product][$gift]['quantity'] =
$_SESSION['life_coaching_order'][$product][$gift]['quantity'] + 1;
===

...

===
foreach ($_SESSION['life_coaching_order'] AS $coaching_fee_theme_reference
= $value ) {
===


In this example $value would be an array. To test if it is a gift or not you
would do this from within the foreach loop:

//gift
if ( isset($value[1])  isset($value[1]['quantity']) )
{
  $gift_quantity = $value[1]['quantity'];
}

//personal use
if ( isset($value[2])  isset($value[2]['quantity']) )
{
  $personal_quantity = $value[2]['quantity'];
}


Technically the above IF's are optional, but they are proper syntax.

I don't know how you are with OOP, but you may have more luck using objects
instead of a complex array.

Chris H.


On Thu, Oct 7, 2010 at 3:35 PM, Ron Piggott
ron.pigg...@actsministries.orgwrote:


 I am writing a custom shopping cart that eventually the cart will be
 uploaded to PayPal for payment.  I need to be able to include the option
 that the purchase is a gift certificate.



 At present my add to cart function goes like this:

 ===
 # Gift Certificate: 1 is a gift; 2 is personal use

 if ( $gift_certificate == yes ) {
$gift = 1;
 } else {
$gift = 2;
 }

 $_SESSION['life_coaching_order'][$product][$gift]['quantity'] =
 $_SESSION['life_coaching_order'][$product][$gift]['quantity'] + 1;
 ===

 Now I need to display the shopping cart contents.  I want to do this
 through an array as the contents of the shopping cart are in a session
 variable.  I start displaying the shopping cart contents by a FOREACH
 loop:

 ===
 foreach ($_SESSION['life_coaching_order'] AS $coaching_fee_theme_reference
 = $value ) {
 ===

 What I need help with is that I don't know how to test the value of $gift
 in the above array if it is a 1 or 2 (which symbolizes this is a gift
 certificate).

 I have something like this in mind:
 if ( $_SESSION['life_coaching_order'] == 2 ) {

 But I don't know how to access all the components of the array while I am
 going through the FOREACH loop.

 By using a 1 or 2 I have made gift certificates their own product.  If
 you a better method I could use please provide me with this feedback.

 Ron

 The Verse of the Day
 Encouragement from God's Word
 www.TheVerseOfTheDay.info


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




Re: [PHP] Array / form processing

2010-10-07 Thread chris h
input type=submit name=submit value=Remove class=place_order/

I don't know what the context is like, but you may be better off just using
an entire form here with hidden fields. i.e.

form target=... action=...
 input type=hidden name=submit value=Remove /
 input type=hidden name=product_so value=1234 /
 input type=submit value=Remove class=place_order/
/form


Without knowing what else is going on in your page, and how the request is
being handled on the server, it's kind of hard to give exact advice. :)

Chris H.


Re: [PHP] Re: Continuance of the struggle (trying to understand)

2010-10-05 Thread chris h
If I paste the script into a web page

What do you mean by paste the script into a web page?  Can you tell us
exactly what you are doing when you do that?


Chris.



On Tue, Oct 5, 2010 at 7:54 AM, Col Day colind...@aol.com wrote:

 Hi Shreyas,

 Ok, as far as I can tell the script should show This is an HTML line
 reflecting that I am seeing the HTML part of the script followed by This is
 a PHP line to show that PHP is installed and working fine.

 If I view the script directly in IE by going to
 http://localhost/phptest.php I get the output:


 This is an HTML line

 This is a PHP line

 followed by a large and detailed list of the PHP install which includes
 things like compiler language etc.

 If I paste the script into a web page then all that is displayed is

 This is an HTML line.

 Nothing else whatsoever.

 I am fairly confused. I've tried a couple of different web page creators
 (Webplus 10 and Web page maker) and get the same result.

 Sorry if I sound extremely naive but it's bugging me now and I want to
 understand.

 Cheers

 Shreyas Agasthya shreya...@gmail.com wrote in message
 news:aanlkti=4ke1stf8tan7+ecjo-ux5cj=t9-0qctcfk...@mail.gmail.com...

  Col,

 Can you let us know what exactly you see when you say
 http://localhost:/phptest.php
 ?


 Regards,
 Shreyas

 On Tue, Oct 5, 2010 at 4:20 PM, Col Day colind...@aol.com wrote:


 Col Day colind...@aol.com wrote in message
 news:23.81.45586.2820b...@pb1.pair.com...

  Hi all,


 After my escapades with the real basics and realizing my laptop wasn't
 logged on as Administrator, I now am trying to work out why this script
 works sometimes but not others.

  html
  head
  titlePHP Test/title
  /head
  body
  pThis is an HTML line
  ?php
 echo pThis is a PHP line/p;
 phpinfo();
  ?
  /body
  /html

 If I save this as phptest.php and open IE pointing it to
 localhost/phptest.php it works fine. Get both lines of text followed by
 the
 pages of gumpf about php.

 However if I paste this into a



  That was weird!

 I was saying, If I paste this into a webpage I only get the HTML line
 as
 before.

 Anyone have any ideas?

 PHP is obviously working as is apache. Just don't understand why they
 don't
 show up in web pages.

 Cheers again all!

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




 --
 Regards,
 Shreyas Agasthya



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




Re: [PHP] which one is faster

2010-10-05 Thread chris h
Benchmark and find out! :)

What are you using this for? Unless you are doing something crazy it
probably doesn't matter, and you should pick whichever you feel looks nicer
/ is easier to code in / etc.

Chris H.

On Tue, Oct 5, 2010 at 3:23 PM, saeed ahmed saeed@gmail.com wrote:

 $a = 'hey';
 $b = 'done';

 $c = $a.$b;
 $c = $a$b;

 which one is faster for echo $c.



Re: [PHP] which one is faster

2010-10-05 Thread chris h
Saeed here's a quick (and dirty) test I ran:


$tests = 100;

$start = microtime(true);
for ($i=0; $i$tests; $i++) {

  $a = md5( rand() );
  $b = md5( rand() );

  $c = $a.$b;
}
var_dump( By concat op:\t. (microtime(true) - $start) );


$start = microtime(true);
for ($i=0; $i$tests; $i++) {

  $a = md5( rand() );
  $b = md5( rand() );

  $c = $a$b;
}
var_dump( By string:\t\t. (microtime(true) - $start) );


Sample results:
string(30) By concat op: 2.1713118553162
string(27) By string: 2.2525599002838

string(30) By concat op: 2.2123351097107
string(27) By string: 2.2798750400543

string(29) By concat op: 2.1521489620209
string(27) By string: 2.2470209598541

string(29) By concat op: 2.1347990036011
string(27) By string: 2.1982681751251


I would say that under virtually all cases that difference is less
then negligible.

Chris H.

On Tue, Oct 5, 2010 at 3:35 PM, Ashley Sheridan 
a...@ashleysheridan.co.ukwrote:

  On Tue, 2010-10-05 at 15:28 -0400, chris h wrote:

 Benchmark and find out! :)

 What are you using this for? Unless you are doing something crazy it
 probably doesn't matter, and you should pick whichever you feel looks nicer
 / is easier to code in / etc.

 Chris H.

 On Tue, Oct 5, 2010 at 3:23 PM, saeed ahmed saeed@gmail.com wrote:

  $a = 'hey';
  $b = 'done';
 
  $c = $a.$b;
  $c = $a$b;
 
  which one is faster for echo $c.
 


 As far as I'm aware, the first of the two will be faster, but only just. As
 Saeed mentioned, the difference will be negligible, and unless you plan to
 run a line like that in a loop or something hundreds of thousands of times,
 you probably won't notice any difference.
   Thanks,
 Ash
 http://www.ashleysheridan.co.uk





Re: [PHP] which one is faster

2010-10-05 Thread chris h
On Tue, Oct 5, 2010 at 3:53 PM, Ashley Sheridan 
a...@ashleysheridan.co.ukwrote:

 On Tue, 2010-10-05 at 15:46 -0400, Steve Staples wrote:

  On Tue, 2010-10-05 at 20:35 +0100, Ashley Sheridan wrote:
   On Tue, 2010-10-05 at 15:28 -0400, chris h wrote:
  
Benchmark and find out! :)
   
What are you using this for? Unless you are doing something crazy it
probably doesn't matter, and you should pick whichever you feel looks
 nicer
/ is easier to code in / etc.
   
Chris H.
   
On Tue, Oct 5, 2010 at 3:23 PM, saeed ahmed saeed@gmail.com
 wrote:
   
 $a = 'hey';
 $b = 'done';

 $c = $a.$b;
 $c = $a$b;

 which one is faster for echo $c.

  
  
   As far as I'm aware, the first of the two will be faster, but only
 just.
   As Saeed mentioned, the difference will be negligible, and unless you
   plan to run a line like that in a loop or something hundreds of
   thousands of times, you probably won't notice any difference.
   Thanks,
   Ash
   http://www.ashleysheridan.co.uk
  
  
 
 
  to be proper, shouldn't it technically be
  $c = {$a}{$b};
 
  ??
 
  Steve.
 
 


 It doesn't have to use the braces. The braces only tell PHP exactly
 where to stop parsing the current variable name. The following examples
 wouldn't work without them:

 $var = 'hello ';
 $arr = array('msg 1'='hello','msg 2'='world');

 echo {$var}world;
 echo {$arr['msg 1']}{$arr['msg 2']};

 Without the braces, in the first example PHP would look for a variable
 called $varworld, and in the second it would be looking for a simple
 scaler called $arr, not the array value you wanted.

 Thanks,
 Ash
 http://www.ashleysheridan.co.uk



Just to add in here, they are also required when calling an object's
properties, if - ready for this? - that object is itself a property of
another object.

so while this would work,

$circle-circumference

this would NOT work

$circle-circumference-inches

The later would be injecting the $circle-circumference property, followed
by string literal -inches.  So to get it to work you would need to use
curlys.

{$circle-circumference-inches}


Chris H.


Re: [PHP] Variable (Class instantiation) collision

2010-10-05 Thread chris h
Just to clarify, both packages are instantiating and calling their
respective database classes from the $db var, which is in the global scope.
Is this correct?

This is why I hate the global scope, I hate it, I hate it!

On Tue, Oct 5, 2010 at 3:47 PM, Brian Smither bhsmit...@gmail.com wrote:

 I am running into a variable collision. The project I'm developing is NOT
 guaranteed to be operating on PHP5. Any solution I find should (hopefully)
 be able to run on PHP4 (yes, I know PHP4 is deprecated).

 I am building a bridge between two third-party applications. Both
 instantiate their respective database class assigning it to $db and I cannot
 change that.

 So, I am interested in solutions to this.

 I found a reference to a Packager class and will be looking at it shortly.



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




Re: [PHP] which one is faster

2010-10-05 Thread chris h
On Tue, Oct 5, 2010 at 3:58 PM, Steve Staples sstap...@mnsi.net wrote:

 On Tue, 2010-10-05 at 20:53 +0100, Ashley Sheridan wrote:
  On Tue, 2010-10-05 at 15:46 -0400, Steve Staples wrote:
 
   On Tue, 2010-10-05 at 20:35 +0100, Ashley Sheridan wrote:
On Tue, 2010-10-05 at 15:28 -0400, chris h wrote:
   
 Benchmark and find out! :)

 What are you using this for? Unless you are doing something crazy
 it
 probably doesn't matter, and you should pick whichever you feel
 looks nicer
 / is easier to code in / etc.

 Chris H.

 On Tue, Oct 5, 2010 at 3:23 PM, saeed ahmed saeed@gmail.com
 wrote:

  $a = 'hey';
  $b = 'done';
 
  $c = $a.$b;
  $c = $a$b;
 
  which one is faster for echo $c.
 
   
   
As far as I'm aware, the first of the two will be faster, but only
 just.
As Saeed mentioned, the difference will be negligible, and unless you
plan to run a line like that in a loop or something hundreds of
thousands of times, you probably won't notice any difference.
Thanks,
Ash
http://www.ashleysheridan.co.uk
   
   
  
  
   to be proper, shouldn't it technically be
   $c = {$a}{$b};
  
   ??
  
   Steve.
  
  
 
 
  It doesn't have to use the braces. The braces only tell PHP exactly
  where to stop parsing the current variable name. The following examples
  wouldn't work without them:
 
  $var = 'hello ';
  $arr = array('msg 1'='hello','msg 2'='world');
 
  echo {$var}world;
  echo {$arr['msg 1']}{$arr['msg 2']};
 
  Without the braces, in the first example PHP would look for a variable
  called $varworld, and in the second it would be looking for a simple
  scaler called $arr, not the array value you wanted.
 
  Thanks,
  Ash
  http://www.ashleysheridan.co.uk
 
 
 Ash:

 I understand what the {} does, but just like in HTML, it is more proper
 to use lower case for the attributes/elements, and use  (double quotes)
 when wrapping the attributes... but is it not REQUIRED to write it in
 that manner... just like it is not required to wrap the variables in {}
 when inside the ...

 that's just me, I tend to try and do that every time...

 Steve.



Unlike HTML, PHP interpretation doesn't have various browsers to contend
with. And even if it was not proper I have a doubt that not using {} would
become deprecated anytime soon.

Also laziness is a trait of a good programmer! :)
http://c2.com/cgi/wiki?LazinessImpatienceHubris

Chris H.


Re: [PHP] Variable (Class instantiation) collision

2010-10-05 Thread chris h
Short of refactoring ApplicationB, can you set it up as a SOAP/REST service
that AppA calls?


On Tue, Oct 5, 2010 at 5:02 PM, Brian Smither bhsmit...@gmail.com wrote:


 Just to clarify, both packages are instantiating and calling their
 respective classes from the $db var, which is in the global scope.
 Is this correct?

 I would say yes to the way you are asking. Take the following two
 applications. The four respective statements are in each their respective
 script.

 Application A:
 ?php
 class foo {}
 $db = new foo();
 $outA = barA();
 function barA() { global $db; include(Application B); }
 ?

 Application B:
 ?php
 class bar {}
 $db = new bar();
 $outB = barB();
 function barB() { global $db; }
 ?

 The bridge project is operating in A and include()'ing the script that is B
 (as I have not found an API for B). $db in B is colliding with $db in A.



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




[PHP] PHPExcel with large files (27,000+ rows)

2010-10-04 Thread chris h
I'm currently working on a project that requires the parsing of excel files.
 Basically the user uploads an excel file, and then a script needs to save a
row in a Postgres database for each row in the excel file.  The issue we are
having is that when we task PHPExcel with parsing an excel file with, say
27k rows, it explodes with a memory error.  I've read up on the PHPExcel
forums and we've tried cell caching as well as ReadDataOnly, they do not
seem to be sufficient.

Does anyone here know of a way to do this? Surely there is a way to parse a
large excel file with PHP.  This is also NOT an on-demand service.  That is,
when someone uploads a file they get a task_id which allows them to check
the status of their excel file.  So the solution does not need to be a fast
one!


Thanks,
Chris.


Re: [PHP] PHPExcel with large files (27,000+ rows)

2010-10-04 Thread chris h
Thanks Jessen/Marc, though the user provided format can be in xls, xlsx, or
csv.  So i need a solution to support all formats.

Thanks for the ideas shiplu I'll get with the team and see if there's
anything there we aren't trying.


Chris.


On Mon, Oct 4, 2010 at 3:01 PM, shiplu shiplu@gmail.com wrote:

 On Tue, Oct 5, 2010 at 12:39 AM, chris h chris...@gmail.com wrote:
  I'm currently working on a project that requires the parsing of excel
 files.
   Basically the user uploads an excel file, and then a script needs to
 save a
  row in a Postgres database for each row in the excel file.  The issue we
 are
  having is that when we task PHPExcel with parsing an excel file with, say
  27k rows, it explodes with a memory error.  I've read up on the PHPExcel
  forums and we've tried cell caching as well as ReadDataOnly, they do not
  seem to be sufficient.
 
  Does anyone here know of a way to do this? Surely there is a way to parse
 a
  large excel file with PHP.  This is also NOT an on-demand service.  That
 is,
  when someone uploads a file they get a task_id which allows them to check
  the status of their excel file.  So the solution does not need to be a
 fast
  one!
 
 
  Thanks,
  Chris.
 

 1. Remove any variable that contains big object if its not necessary.
 2. Use unset when applicable
 3. Read chunk by chunk.
 4. Profile it to find the exact place where you are wasting memory.
 Optimizing that little portion of code can improve memory performance.

 --
 Shiplu Mokadd.im
 My talks, http://talk.cmyweb.net
 Follow me, http://twitter.com/shiplu
 SUST Programmers, http://groups.google.com/group/p2psust
 Innovation distinguishes bet ... ... (ask Steve Jobs the rest)



Re: [PHP] Syntax Error

2010-10-03 Thread chris h
On Sun, Oct 3, 2010 at 12:47 PM, Gary gp...@paulgdesigns.com wrote:

 I have just created a registration page using Webassist, and I am getting a
 syntax error that I am not understanding.  Anyone be able to point me in
 the
 right direction?

 You have an error in your SQL syntax; check the manual that corresponds to
 your MySQL server version for the right syntax to use near ' NULL, NULL)'
 at
 line 1

 This is the code (I have not modified it)

 ?php require_once('Connections/local.php'); ?
 ?php
 if (!function_exists(GetSQLValueString)) {
 function GetSQLValueString($theValue, $theType, $theDefinedValue = ,
 $theNotDefinedValue = )
 {
 $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

 $theValue = function_exists(mysql_real_escape_string) ?
 mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

 switch ($theType) {
 case text:
 $theValue = ($theValue != ) ? ' . $theValue . ' : NULL;
 break;
 case long:
 case int:
 $theValue = ($theValue != ) ? intval($theValue) : NULL;
 break;
 case double:
 $theValue = ($theValue != ) ? ' . doubleval($theValue) . ' : NULL;
 break;
 case date:
 $theValue = ($theValue != ) ? ' . $theValue . ' : NULL;
 break;
 case defined:
 $theValue = ($theValue != ) ? $theDefinedValue : $theNotDefinedValue;
 break;
 }
 return $theValue;
 }
 }
 ?
 ?php
 // *** Redirect if username exists
 $MM_flag=MM_insert;
 if (isset($_POST[$MM_flag])) {
 $MM_dupKeyRedirect=;
 $loginUsername = $_POST['id'];
 $LoginRS__query = SELECT id FROM family WHERE id=' . $loginUsername .
 ';
 mysql_select_db($database_local, $local);
 $LoginRS=mysql_query($LoginRS__query, $local) or die(mysql_error());
 $loginFoundUser = mysql_num_rows($LoginRS);

 //if there is a row in the database, the username was found - can not add
 the requested username
 if($loginFoundUser){
 $MM_qsChar = ?;
 //append the username to the redirect page
 if (substr_count($MM_dupKeyRedirect,?) =1) $MM_qsChar = ;
 $MM_dupKeyRedirect = $MM_dupKeyRedirect . $MM_qsChar
 .requsername=.$loginUsername;
 header (Location: $MM_dupKeyRedirect);
 exit;
 }
 }
 ?
 ?php
 $editFormAction = $_SERVER['PHP_SELF'];
 if (isset($_SERVER['QUERY_STRING'])) {
 $editFormAction .= ? . htmlentities($_SERVER['QUERY_STRING']);
 }

 ?
 ?php
 if ((isset($_POST[MM_insert]))  ($_POST[MM_insert] ==
 WAATKRegistrationForm)) {
 $insertSQL = sprintf(INSERT INTO family (firstname, lastname, email,
 password, relationship, story, image, ip, submitted) VALUES (%s, %s, %s,
 %s,
 %s, %s, %s, %s, %s),
 GetSQLValueString($_POST['firstname'], text),
 GetSQLValueString($_POST['lastname'], text),
 GetSQLValueString($_POST['email'], text),
 GetSQLValueString($_POST['password'], text),
 GetSQLValueString($_POST['relationship'], text),
 GetSQLValueString($_POST['story'], text),
 GetSQLValueString($_POST['image'], ), GetSQLValueString($_POST['ip'],
 text), GetSQLValueString($_POST['submitted'], date));

 mysql_select_db($database_local, $local);
 $Result1 = mysql_query($insertSQL, $local) or die(mysql_error());

 $insertGoTo = family_LogIn.php;
 if (isset($_SERVER['QUERY_STRING'])) {
 $insertGoTo .= (strpos($insertGoTo, '?')) ?  : ?;
 $insertGoTo .= $_SERVER['QUERY_STRING'];
 }
 header(sprintf(Location: %s, $insertGoTo));
 }
 ?

 Thanks again for the help.

 Gary



 __ Information from ESET Smart Security, version of virus signature
 database 5499 (20101003) __

 The message was checked by ESET Smart Security.

 http://www.eset.com





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



MySQL is not liking a query.  It looks to be this one:

$insertSQL = sprintf(INSERT INTO family (firstname, lastname, email,
password, relationship, story, image, ip, submitted) VALUES (%s, %s, %s, %s,
%s, %s, %s, %s, %s),

I would echo or log $insertSQL just before you pass it to mysql_query() and
see if the SQL syntax looks right.


Chris.


Re: [PHP] Little Parsing help...

2010-10-02 Thread chris h
Don,

How far along are you?  To get started something like this may work for
you...

preg_match_all('/[A-G]{1}#?/', $line, $matches);

That SHOULD return each note of the line (you can retrieve them via the
$matches array), given that there are no other upper-case characters that
are not notes. Also this assumes that $line has exactly one line in it. :)

If you get that working, perhaps you can setup something using the
preg_replace method?
http://php.net/manual/en/function.preg-replace.php


Another option is to use the str_replace function.
http://us3.php.net/manual/en/function.str-replace.php


I gotta run (else I would type some more) but let me know if you want any
advice on using those!

Chris.


On Fri, Oct 1, 2010 at 11:20 AM, Don Wieland d...@pointmade.net wrote:

 The logic I need is pretty straight forward, but I am having a hard time
 replicating it using PHP functions. I will try to break it down to it's
 simplest form:

 I have a field that has several lines of text. Chords and Song Lyrics.

 The Chord lines begin with an asterisk * and end with the line break.
 This is the string I want to parse. Lines with no asterisk at the beginning
 are ignored.

 Based on 3 arrays of NOTES, I want SUBSTITUTE the text (based on exact text
 character patterns - just NOTES not the chord type) of the lines in my field
 that start with an asterisk *.

 original_chord_array = A, A#, B, C, C#, D, D#, E, F, F#, G, G#
 transpose_up_array = A#, B, C, C#, D, D#, E, F, F#, G, G#, A
 transpose_down_array = G#, A, A#, B, C, C#, D, D#, E, F, F#, G

 It is important that it only effects EXACT strings.  Notes will always be
 capitalized and chord types will be lower case. Maybe we can use that
 characteristic to better identify what to change. Here are some examples of
 chords:

 A
 Asus7
 Csus add9
 Dmaj7
 F#m7
 G#
 C#dim no3

 When I transpose UP these chords, just the NOTE should change:

 A#
 A#sus7
 C#sus add9
 D#maj7
 Gm7
 A
 Ddim no3

 When I transpose DOWN these chords, just the NOTE should change:

 G#
 G#sus7
 Bsus add9
 C#maj7
 Fm7
 G
 Cdim no3

 I am working on a function, but still not producing the proper results.
 Hopefully this break down is more clear and someone will bail me out ;-)

 Thanks again for the feedback.

 Don


 On Oct 1, 2010, at 7:02 AM, Richard Quadling wrote:

  Changing the NormalKeyID and using that ID with NoteSequenceNumber
 should give you the new note to play.

 I think.



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




Re: [PHP] Scraping Multiple sites

2010-10-02 Thread chris h
On Sat, Oct 2, 2010 at 9:03 PM, Russell Dias rus...@gmail.com wrote:

 I'm currently stuck on a little problem. I'm using cURL in conjunction
 with DOMDocument and Xpath to scrape data from a couple of websites.
 Please note that is only for personal and educational purposes.

 Right now I have 5 independent scripts (that traverse through 5
 websites) that run via a cron tab every 12 hours. However, as you may
 have guessed this is a scalability nightmare. If my list of websites
 to scrape grows I have to create another independent script and run it
 via cron.

 My knowledge of OOP is fairly basic as I have just gotten started with
 it. However, could anyone perhaps suggest a design pattern that would
 suit my needs? My solution would be to create an abstract class for
 the web crawler and then simply extend it per website I add on.
 However, as I said my experience with OOP is almost non-existant
 therefore I have no idea how this would scale. I want this 'crawler'
 to be one application which can run via one cron rather than having n
 amount of scripts for each websites and having to manually create a
 cron each time.

 Or does anyone have any experience with this sort thing and could
 maybe offer some advice?

 I'm not limited to using PHP either, however due to hosting
 constraints Python would most likely be my only other alternative.

 Any help would be appreciated.

 Cheers,
 Russell

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



Are the sites that you are crawling so different as to justify
maintaining separate chunks of code for each one?  I would try to avoid
having any code specific to a site, otherwise scaling your application to
support even a hundred sites would involve overlapping hundreds of points of
functionality and be a logistical nightmare.  Unless you're simply wanting
to do this for educational reasons...

My suggestion would be to attempt to create an application that can craw all
the sites, without specifics for each one.  You could fire it with a single
cron job, and give it a list of the urls you want it to hit.  It can crawl
one url, record the findings, move to the next, repeat.


Chris.


Re: [PHP] Array question

2010-09-25 Thread chris h
Mike,

$results[] will automatically push a value unto the end of an array.

So doing this...
--
$magic = array();
$magic[] = 'a';
$magic[] = 'b';
$magic[] = 'c';
-

is exactly this same as doing this...
--
$normal = array();
$normal[0] = 'a';
$normal[1] = 'b';
$normal[2] = 'c';
-

And yes, in your example $results[] would be equivalent to $results[$j]


For more reference:
http://www.php.net/manual/en/language.types.array.php


Chris H.


On Sat, Sep 25, 2010 at 4:31 PM, MikeB mpbr...@gmail.com wrote:

 I have the following code:

 $query = SELECT * FROM classics;
 $result = mysql_query($query);

 if (!$result) die (Database access failed:  . mysql_error());
 $rows = mysql_num_rows($result);

 for ($j = 0 ; $j  $rows ; ++$j)
 {
$results[] = mysql_fetch_array($result);
 }

 mysql_close($db_server);

 My question, in the loop, why does tha author use:

 $results[] = mysql_fetch_array($result);

 instead of (as I would expect):

 $results[$j] = mysql_fetch_array($result);?

 What PHP magic is at work here?

 Thanks.


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




Re: [PHP] Re: Copying an Object

2010-09-24 Thread chris h
On Fri, Sep 24, 2010 at 8:35 AM, Peter Lind peter.e.l...@gmail.com wrote:

 On 24 September 2010 14:22, Bob McConnell r...@cbord.com wrote:
  From: David Hutto
 
  On Fri, Sep 24, 2010 at 4:09 AM, Gary php-gene...@garydjones.name
 wrote:
  Daniel Kolbo wrote:
 
  Say you have two classes: human and male.  Further, say male extends
  human.  Let's say you have a human object.  Then later you want to
 make
  that human object a male object.  This seems to be a pretty reasonable
  thing to request of our objects.
 
  I don't think any human can change gender without major surgery, but I
  don't know if you just chose your example badly or whether you really
  think objects should be able to mutate into other types of object
  without some kind of special treatment.
 
  But it would work in something like makehuman, where you start with a
 neuter
  form and scale one way or the other for physical features. If I
  remember correctly,
  we're' all xx until you become xy(genetically speaking).
 
  This is one of the details that really bothers me about OOP. It makes it
 impossible to implement some very reasonable scenarios. 80% of the time,
 when a patron is added to a system, we don't know which gender they are.
 More than 50% of the time, we will never know, since the client doesn't keep
 track of it. But the rest of them will be assigned sometime after they were
 added. i.e. the gender assignment comes from a secondary source that is not
 available at the time the patron is entered.
 

 If you can't handle that, it's not the fault of OOP but your lack of
 programming skills in OOP I'd say (and I mean no disrespect there, I'm
 just pretty sure your scenario can be handled very easily in OOP).

 And no, I have no urge to defend OOP in PHP, I just see this entire
 thread as a complete non-starter: if the language doesn't let you do
 something in a particular way, how about you stop, take a breather,
 then ask if perhaps there's a better way in the language to do what
 you want done? That would normally be a much more productive and
 intelligent response than either a) pressing on in the face of failure
 or b) complaining about your specific needs and how the language fails
 to meet them.

 Regards
 Peter

 --
 hype
 WWW: http://plphp.dk / http://plind.dk
 LinkedIn: http://www.linkedin.com/in/plind
 BeWelcome/Couchsurfing: Fake51
 Twitter: http://twitter.com/kafe15
 /hype




I think pages 17-19 of the GoF covers exactly this:

Object composition is an alternative to inheritance. ... Any [composed]
object can be replaced at run-time by another as long as it has the same
type.

I would look into object composition or just read the GoF.


Re: [PHP] Re: Copying an Object

2010-09-24 Thread chris h
Gang of Four

http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612

An excellent book on OOP.

Chris H.


On Fri, Sep 24, 2010 at 9:34 AM, Bob McConnell r...@cbord.com wrote:

 From: chris h

  On Fri, Sep 24, 2010 at 8:35 AM, Peter Lind peter.e.l...@gmail.com
 wrote:
 
On 24 September 2010 14:22, Bob McConnell r...@cbord.com wrote:
 From: David Hutto

 On Fri, Sep 24, 2010 at 4:09 AM, Gary
 php-gene...@garydjones.name wrote:
 Daniel Kolbo wrote:

 Say you have two classes: human and male.  Further, say
 male extends
 human.  Let's say you have a human object.  Then later you
 want to make
 that human object a male object.  This seems to be a pretty
 reasonable
 thing to request of our objects.

 I don't think any human can change gender without major
 surgery, but I
 don't know if you just chose your example badly or whether
 you really
 think objects should be able to mutate into other types of
 object
 without some kind of special treatment.

 But it would work in something like makehuman, where you
 start with a neuter
 form and scale one way or the other for physical features. If
 I
 remember correctly,
 we're' all xx until you become xy(genetically speaking).

 This is one of the details that really bothers me about OOP.
 It makes
  it impossible to implement some very reasonable scenarios. 80% of the
 time,
  when a patron is added to a system, we don't know which gender they
 are.
  More than 50% of the time, we will never know, since the client
 doesn't keep
  track of it. But the rest of them will be assigned sometime after they
 were
  added. i.e. the gender assignment comes from a secondary source that
 is not
  available at the time the patron is entered.

If you can't handle that, it's not the fault of OOP but your
 lack of
programming skills in OOP I'd say (and I mean no disrespect
 there, I'm
just pretty sure your scenario can be handled very easily in
 OOP).
 
And no, I have no urge to defend OOP in PHP, I just see this
 entire
thread as a complete non-starter: if the language doesn't let
 you do
something in a particular way, how about you stop, take a
 breather,
then ask if perhaps there's a better way in the language to do
 what
you want done? That would normally be a much more productive and
intelligent response than either a) pressing on in the face of
 failure
or b) complaining about your specific needs and how the language
 fails
to meet them.
 
  I think pages 17-19 of the GoF covers exactly this:
 
  Object composition is an alternative to inheritance. ... Any
  [composed] object can be replaced at run-time by another as long
  as it has the same type.
 
  I would look into object composition or just read the GoF.

 GoF?

 Bob McConnell

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




Re: [PHP] if/elseif being treated as if/if

2010-09-24 Thread chris h
Andy I see no reason why both echo's would fire; unless this block of code
gets executed multiple times.  can we see more of the code?

Chris H.


On Fri, Sep 24, 2010 at 1:50 PM, Andy McKenzie amckenz...@gmail.com wrote:

 Hey folks,

  Here's the deal.  I have the following code:

 if($col_vals[$i][$val['column']] == $search_result[0][$col])
  { echo ' selected=selected'; }
 elseif($val['default'] == $col_vals[$i][$val['column']])
  { echo ' selected=selected'; }

  It's supposed to check whether there's a value in the db
 ($search_result[0][$col]) that matches the current column value, and
 if not, check whether the default matches it.  It does that, sort of.
 In fact, both statements trigger, which I would have said wasn't
 possible.

  So the question is:  what causes both parts of an if/elseif
 statement to trigger?  As far as I can see my punctuation is correct,
 and I've confirmed through debugging statements that all the values
 are what I expect, so how do I make the elseif stop acting like
 another if?  Or, alternatively, have I just misunderstood all this
 time what the if/elseif statement does?

 Thanks,
  Alex

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




Re: [PHP] Copying an Object

2010-09-22 Thread chris h
You could create a method of class B that takes an object of class A as a
parameter and copies each property line by line (or method of class A that
takes an object of class B...).  If you don't want to add a method you could
just do the same thing, but procedurally.  The issue with this (aside from
being bad oop) is that you can't copy private properties unless you have all
the required getters and setters.  The issue with both of these is that it's
ugly, high maintenance code.

There is the iterator class, extending from which would allow you iterate
through all of your properties in a foreach, but if you don't want to add a
new method then you likely don't want to add a parent class.

I don't care for any of these options, but as far as I know there's no
internal PHP mechanism to to copy all the properties from one object to
another object of a different class - please correct me if I'm wrong.  Is it
possible that there's a more elegant solution to your problem that does not
include a mass copy of all an object's properties? (e.g. using statics like
Mr Bungle suggested or perhaps some nifty design pattern?)


Chris H.




On Wed, Sep 22, 2010 at 7:35 AM, Daniel Kolbo kolb0...@umn.edu wrote:

 Hello PHPers,

 I have:

 class A {
...code
 }

 class B extends A {
...code
 }

 $a = new A();

 $b = new B();

 I would like to get all of the properties of $a into $b by value.  Class
 A extends 3 other classes.  I would like a way to not have to manage a
 'copy' method in B if A or one of the subclasses of A change.

 I was reading about clone, but this doesn't really seem to help me in
 this situation.

 How can I copy $a into $b?

 Thanks,
 dK
 `


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




Re: [PHP] Adjusting Session Times

2010-09-14 Thread chris h
 My thought is to adjust the session expiration in the table based on the
 client currently logged in.


I don't know if there's a better way, but I would probably just do that.
 The expiration would be set to whatever the client's preference is, and
default to 8 hours if he doesn't have one.  You may want to set some checks
to ensure that the client's preference is within a specific range (e.g.
between 30 minutes and 16 hours).


Chris.


Re: [PHP] 1984 (Big Brother)

2010-09-13 Thread chris h
On Mon, Sep 13, 2010 at 5:09 PM, Daevid Vincent dae...@daevid.com wrote:



  -Original Message-
  From: tedd [mailto:t...@sperling.com]
  Sent: Sunday, September 12, 2010 9:32 AM
  To: PHP-General list
  Subject: [PHP] 1984 (Big Brother)
 
  Hi gang:
 
  I have a client who wants his employees' access to their online
  business database restricted to only times when he is logged on.
  (Don't ask why)
 
  In other words, when the boss is not logged on, then his employees
  cannot access the business database in any fashion whatsoever
  including checking to see if the boss is logged on, or not. No access
  whatsoever!
 
  Normally, I would just set up a field in the database and have that
  set to yes or no as to if the employees could access the
  database, or not. But in this case, the boss does not want even that
  type of access to the database permitted. Repeat -- No access
  whatsoever!
 
  I was thinking of the boss' script writing to a file that
  accomplished the yes or no thing, but if the boss did not log off
  properly then the file would remain in the yes state allowing
  employees undesired access. That would not be acceptable.
 
  So, what methods would you suggest?
 
  Cheers,
 
  tedd

 You sure know how to pick'em Tedd.

 This is the second whacky client you've posted about on the list...

 This guy sounds like a real control-freak (read: tool).

 One other thing I'll throw out is the use of a crontab to start/stop mysql
 during boss's hours. I don't have a complete solution for you as I just
 don't care enough about helping this Dbag lord over his employees like
 that, but I suspect you could have /etc/init.d/mysql start or stop at
 some pre-determined times like 8am - noon. Then noon till 5pm. Or
 something.

 RDBMS are not really designed to be turned on and off like that.

 Another option is to maybe use M$ Access instead (which does have a
 multi-user mode). Use ODBC to connect via PHP to it. So then he would start
 up the DB when he likes and shut it down when he likes. (note that a logout
 of Windows will NOT prevent the ODBC connection as it is a service -- as
 God intended RDBMS to be)
 http://www.configure-all.com/php_access.php

 This guy is making me angry just thinking about it!

 d



Yes I've been following this post purely in the hope that someone gets Tedd
is explain the client's logic on this one.  It's one thing for a layman to
have this kind of requirement, but another entirely for them to STILL have
it after an explanation.  I mean part of consulting is to tell the client
when they're wrong, for someone to not heed that when they are paying for
the advice is mind boggling. *sigh* if only everyone were perfect like me...
 :p

Hey lets pay someone to consult us on a subject that we're ignorant of.
Great idea! And when he makes a suggestion we can totally ignore him! SQL -
Shmeequal


Rant aside; I would defer the logistics to the client.  He wants the DB to
shutdown when he's not in the office? Ok no problem - not what it was
designed to do, but no problem!

How would you like the system to be aware of rather or not you're in the
office? It can assume you are between these hours; You can log into a screen
that unlocked it, but then you have to logout; we can put a motion detector
in your office; ... etc.

This would put the consequences of the system off on the client. Because if
this system works then there will be consequences and you'll look like a
jerk  :-)

Btw, are there no cron / batch jobs that need to run over night?



Chris


Re: [PHP] newbie question about code

2010-09-10 Thread chris h
I would check this out to give you a decent understanding of php's oop.

http://php.net/manual/en/language.oop5.php


Chris.


On Fri, Sep 10, 2010 at 2:27 PM, Adam Williams
adam_willi...@bellsouth.netwrote:

 I'm looking at someone's code to learn and I'm relatively new to
 programming.  In the code I see commands like:

 $code-do_command();

 I'm not really sure what that means.  How would that look in procedural
 style programming?  do_command($code); or something else?


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



Re: [PHP] Zend framework

2010-09-10 Thread chris h
Thanks for the info everyone, this is pretty much what I was expecting to
hear about it.  I think I'll probably stick to using it as a toolkit.



Thanks,
Chris.



On Fri, Sep 10, 2010 at 3:01 PM, Daevid Vincent dae...@daevid.com wrote:

 Sorry wrong thread. Damnit. I meant that link for the guy that didn't know
 what the - was for...

  -Original Message-
  From: Daevid Vincent [mailto:dae...@daevid.com]
  Sent: Friday, September 10, 2010 12:01 PM
  To: 'David Harkness'
  Cc: 'PHP-General'
  Subject: RE: [PHP] Zend framework
 
  http://www.php.net/manual/en/language.oop5.basic.php
 
   -Original Message-
   From: David Harkness [mailto:davi...@highgearmedia.com]
   Sent: Friday, September 10, 2010 10:59 AM
   To: rquadl...@googlemail.com
   Cc: chris h; PHP-General
   Subject: Re: [PHP] Zend framework
  
   We use part of Zend MVC (the dispatcher, controllers, and
   view scripts) here
   and a lot of the other facilities such as the autoloader,
   config, etc. and
   are very happy so far. As long as you design your application
   with an eye
   toward portability, you won't be tied to ZF. For example, put
   all of your
   business logic in model classes instead of the controllers
   themselves. That
   way if you ever need to move to a new presentation layer or
   use the business
   logic outside it (e.g. in SOAP or RPC messages), you'll be ready.
  
   David
  
 


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




[PHP] Zend framework

2010-09-09 Thread chris h
Hello all,

I'm starting a new project and I'm thinking about building it on Zend
framework and possibly Zend server.  I've only used the framework slightly
and I've never really used Zend server.  That being said I hear that the
framework is pretty decent to work with.  I want something that is strict
and uses OOP  MVC well, and I hear it does; though I also have the
impression that it's slow and bloated...

Anyways, I was curious if any of you have some general advice / good things
/ horror stories on the Zend framework?


Thanks,
Chris.


Re: [PHP] Reformat array result.

2010-09-08 Thread chris h
Paul,

How are you matching the records in the event count array to the ones in
the timestamp array?

Is it safe to say that:
$timestamp[ $i ] corresponds to $eventCount[ $i ]?

If so, you could just iterate through the timestamp array; on each iteration
create a record in a new array that holds the timestamp and whatever the
corresponding eventCount record is.  Something like:


$newTimeArray = array();

foreach ($timestamps as $i = $singleTimestamp) {

  $newTimeArray[ $i ] = array(
'timestamp' = $singleTimestamp,
'count' = $eventCounts[ $i ]
  );

}


Now if $timestamp[ $i ] does NOT correspond to $eventCount[ $i ] then I
think we'll need you to explain how that relationship works, unless I missed
something :)


Chris.


On Wed, Sep 8, 2010 at 1:02 PM, Paul Halliday paul.halli...@gmail.comwrote:

 I have been starting at this problem blankly for a couple hours now.
 Hopefully someone can help.

 I have a query that returns an event count grouped by hour:

 timestamp:
 Array ( [0] = 2010-09-08 03 [1] = 2010-09-08 04 [2] = 2010-09-08 05
 [3] = 2010-09-08 06 [4] = 2010-09-08 07 [5] = 2010-09-08 08 [6] =
 2010-09-08 09 [7] = 2010-09-08 10 [8] = 2010-09-08 11 [9] =
 2010-09-08 12 [10] = 2010-09-08 13 [11] = 2010-09-08 14 [12] =
 2010-09-08 15 [13] = 2010-09-08 16 ) 24

 event count:
 Array ( [0] = 1731 [1] = 885 [2] = 544 [3] = 668 [4] = 748 [5] =
 754 [6] = 933 [7] = 2422 [8] = 6713 [9] = 31925 [10] = 18827 [11]
 = 16743 [12] = 16875 [13] = 11775 )

 Lets say that coming into this, I knew that the query spanned 36 hours
 and started at 01:00. How can I manipulate the resulting array to
 contain the missing time stamps and a value of 0.

 The effect I am shooting for looks like this:

 http://www.pintumbler.org/example.png

 So 0  -  23 will be static and I just walk through the array and
 populate those. If we hit 23, start a new row and continue. The matrix
 will always be the same though.

 I think I know what needs to happen, I just cant come up with the logic.

 Any push in the right direction would be appreciated.
 --
 Paul Halliday
 Ideation | Individualization | Learner | Achiever | Analytical
 http://www.pintumbler.org

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




Re: [PHP] Hi

2010-09-06 Thread chris h
You can check the extension of the uploaded file
http://www.php.net/manual/en/features.file-upload.post-method.php


But to be sure that it's truly a zip file you could actually open the file
with php's zip function.
http://php.net/manual/en/ref.zip.php


Chris.


On Mon, Sep 6, 2010 at 9:46 AM, Jordan Jovanov jovanovj...@gmail.comwrote:

 Hi All

 I need me a little help.
 I create scripte for upload file is work very good but the problem is next:
 I neet to upload only .zip file i need to disable some user to shoise to
 upload another file Extensions.

 Can somebody help me.

 Thanks a lot.

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




  1   2   3   4   5   6   7   8   9   10   >