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

--

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] Source code of original PHP release.

2013-05-22 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] 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  wrote:

>
> On Tue, Apr 23, 2013 at 4:07 PM, Chris Knipe  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


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

> On 23 Apr 2013, at 11:07, "Chris Knipe"  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


[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] 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  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] 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] 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  wrote:

>
>
>
> On Tue, Feb 12, 2013 at 7:06 PM, Chris MacPherson wrote:
>
>> 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
>


[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] 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 "http://";
. $matches[n] . ">" . $matches[n] . ""

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 Purves"  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:


Something, something end

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 Fri, Apr 27, 2012 at 11:09 AM, Shawn McKenzie  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



Re: [PHP] url string being split

2012-04-27 Thread Chris Stinemetz
On Thu, Apr 26, 2012 at 12:58 PM, Stuart Dallas  wrote:
> On 26 Apr 2012, at 18:37, Jim Giner wrote:
>
>> I"m 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



[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 ''
. $storerow['store_subject'] . ' 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("".print_r($_GET,true).""); ## 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



Re: [PHP] MySQL table design

2012-03-22 Thread Chris Stinemetz
On Thu, Mar 22, 2012 at 7:42 PM, Stuart Dallas  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



[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



[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] Numeric help needed

2012-01-15 Thread Chris Payne
Hi Jason,

I've tried lots of different things, including:

 echo "" . 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  wrote:
>
>
> Sent from my iPhone
>
> On Jan 15, 2012, at 8:25 PM, "Christopher J Payne"  
> 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



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



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



[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
On Wed, Sep 7, 2011 at 6:23 AM, James Yerge  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



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



[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  wrote:

> 
> 
> Mike Mackintosh  wrote:
> 
>> 
>> 
>> On Aug 24, 2011, at 11:52, John Black 
>> 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.


Choose...
 $value)
{
$selected = '';
if($value == $market)
{
$selected = 'selected';
}
echo '', htmlspecialchars($market_name[$key]), '';
}
?>


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



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



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



[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



[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] 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 . "";
$num++;
}

-- 
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,  wrote:
>
> how about
>
> echo nl2br($your_content);
>
>
>
>
> - Original Message -
> From: Chris Stinemetz 
> Date: Wednesday, August 10, 2011 5:09 pm
> Subject: Re: [PHP] text insertion
> To: "Daniel P. Brown" 
> Cc: Ashley Sheridan , PHP General <
php-general@lists.php.net>
>
> > >
> > >Use HTML 'pre' tags:
> > >
> > >
> > >
> >
> > I just tried that and that puts all the text on a single line.
> >
> >
> > echo '
> > ' . $posts_row['first_name']
> > . ' ' .
> > $posts_row['last_name'] . ' ' . date('m-d-Y h:iA',
> > strtotime($posts_row['store_date'])) . '
> > 
> > 
> > Broad Band test results:
> > ' .
> > $posts_row['store_tptest'] . ''
> > .$posts_row['store_comments'] . '
> > ';
> >
> > --
> > 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:
>
>        
>

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


echo '
' . $posts_row['first_name'] . ' ' .
$posts_row['last_name'] . ' ' . date('m-d-Y h:iA',
strtotime($posts_row['store_date'])) . '


Broad Band test results: ' .
$posts_row['store_tptest'] . ''
.$posts_row['store_comments'] . '
';

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



[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] 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 ''
. $storerow['store_subject'] . ' 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] 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 '' .
$row['store_name'] . '' . $row['store_type'];

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

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



[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



Any help is greatly appreciated. Thank you.


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



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  wrote:
> On Tue, Jul 19, 2011 at 4:28 AM, Chris Stinemetz 
> 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.
>>
>>                    > onchange="javascript:get(this.parentNode);">
>>                    >                        foreach($market_prefix as $key => $value)
>>                            {
>>                            $selected = '';
>>                            if($value == $market)
>>                            {
>>                            $selected = 'selected';
>>                            }
>>                            echo("> >$value : $market_name[$key]");
>>                            }
>>                            ?>
>>                    
>
> 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.
> 
>   Choose...
>    foreach($market_prefix as $key => $value)
>   {
>     $selected = '';
>     if ($value == $market)
>     {
>       $selected = 'selected';
>     }
>     echo '',
> htmlspecialchars($value.' : '.$market_name[$key]), '';
>   }
> ?>
> 
> -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] 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.


 $value)
{
$selected = '';
if($value == $market)
{
$selected = 'selected';
}
echo("$value : $market_name[$key]");
}
?>


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

   
   $(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("<option>please 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("<option>please
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(market>0 && type>0 && store>0)
   {
   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;
   });
   });
   


php class for populating select menus

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 = 'market...';
   while($row = mysql_fetch_array($res))
   {
   $market .= '' .
$row['id_markets'] . '';
   }
   return $market;
   }

   public function ShowType()
   {
   $sql = "SELECT DISTINCT store_type FROM store_list";
   $res = mysql_query($sql,$this->conn);
   $type = 'store type...';
   while($row = mysql_fetch_array($res))
   {
   $type .= '' .
$row['store_type'] . '';
   }
   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 = 'stores...';
   while($row = mysql_fetch_array($res))
   {
   $Store .= '' .
$row['store_name'] . '';
   }
   return $Store;
   }
}

$opt = new SelectList();

?>

-- 
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 = 'store type...';
while($row = mysql_fetch_array($res))
{
$Type .= '' .
$row['store_type'] . '';
}
return $Type;
}

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



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

2011-07-04 Thread Chris Stinemetz
On Mon, Jul 4, 2011 at 8:13 AM, Alejandro Michelin Salomon (Hotmail)
 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: 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"  wrote:

> Shawn,
> I added my php folder to the path but no change.
> 
> "Shawn McKenzie"  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: 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: [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:';
$choices = array('corporate' => 
'Cricket owned | ',
 
'premier' => 'Premier dealer');
 
foreach ($choices as $key => $choice) {

 echo "
$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] 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] 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 "Choose Market\n";
foreach ($markets as $key => $market) {
echo "$market\n";
}
echo "";

// 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 "Choose Cell Sector";
// printing the list box select command

while($cellSect=mysql_fetch_array($result)){//Array or records stored
in $cellSect
echo "$cellSect[cell_sect]";
/* Option values are added by looping through the array */
}
echo "";// 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.

";
   echo '' . $row['Name'] . '';
   echo '' . $row['Date'] . '';
   echo '' . $row['StoreInfo'] . '';
   echo '' . $row['Address'] . '';
   echo '' . $row['Type'] . '';
   echo '' . $row['EngTech'] . '';
   echo '' . $row['StoreManager'] . '';
   echo '' . $row['BBtime'] . '';
   echo '' . $row['BBup'] . '';
   echo '' . $row['BBdown'] . '';
   echo '' . $row['SiteSect'] . '';
   echo '' . $row['VoiceCall'] . '';
   echo '' . $row['Comments'] . '';
   echo 'Edit';
   echo 'Delete';
   echo "";
   }

   // close table>
   echo "";
?>

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



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



[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] "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" 
> Date: Thu, Oct 21, 2010 10:51
> Subject: [PHP] "My truth comes out" [1]
> To: 
>
> preg_match("/false/i", $string) ? false : true;
>
>
>
> On Thu, Oct 21, 2010 at 7:39 PM, Gary  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] 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.




Chris.



On Tue, Oct 19, 2010 at 4:54 PM, chris h  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 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
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  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] 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  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] 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] 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  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] 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] Text messaging from the web

2010-10-14 Thread chris h
>
> You can send a text message via email:
>
>Verizon: 10digitphonenum...@vtext.com
>AT&T: 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] 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  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] 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] 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  wrote:

> On Tue, Oct 12, 2010 at 4:45 AM, chris h  wrote:
> >
>
> 
>
> >
> >
> > 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] 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  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] Array / form processing

2010-10-07 Thread chris h


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.


 
 
 



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] 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
wrote:

>
> 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: RES: [PHP] Class mysqli not found

2010-10-06 Thread chris h
Are you doing phpinfo() off the CLI or via apache mod?  Is it the same way
you are running the actual script that's calling on mysqli?

On Wed, Oct 6, 2010 at 4:58 PM, sueandant wrote:

> phpinfo() includes mysqli in its detailed output:
>
> mysqli
> MysqlI Support enabled
> Client API library version  mysqlnd 5.0.7-dev - 091210 - $Revision:
> 300533 $
> Active Persistent Links  0
> Inactive Persistent Links  0
> Active Links  0
>
> Directive Local Value Master Value
> mysqli.allow_local_infile On On
> mysqli.allow_persistent On On
> mysqli.default_host no value no value
> mysqli.default_port 3306 3306
> mysqli.default_pw no value no value
> mysqli.default_socket no value no value
> mysqli.default_user no value no value
> mysqli.max_links Unlimited Unlimited
> mysqli.max_persistent Unlimited Unlimited
> mysqli.reconnect Off Off
>
> - Original Message - From: "Simon J Welsh" 
> To: "Alejandro Michelin Salomon" 
> Cc: "'sueandant'" ; <
> php-general@lists.php.net>
> Sent: Wednesday, October 06, 2010 9:43 PM
> Subject: Re: RES: [PHP] Class mysqli not found
>
>
>
> http://php.net/manual/en/class.mysqli.php definitely says MySQLi is a
> class.
>
> It looks like PHP was complied without MySQLi support. Does running a
> phpinfo() show the MySQLi module?
> On 7/10/2010, at 9:33 AM, Alejandro Michelin Salomon wrote:
>
>  Sueandant :
>>
>> mysqli is set of functions not a class. The name to connect is
>> mysqli_connect
>> /**
>> *
>> *
>> * @version $Id$
>> * @copyright 2010
>> */
>> $mysqli = mysqli_connect ("localhost", "root", "woodcote", "testDB");
>>
>> if (mysqli_connect_errno()) {
>> printf("Connect failed: %s\n", mysqli_connect_error());
>> exit();
>> } else {
>> printf("Host information: %s\n", mysqli_get_host_info($mysqli));
>> }
>>
>>
>> Try adodb lib for php ( http://adodb.sourceforge.net/ ), is great layer
>> on top of php db functions.
>>
>> Alejandro M.S.
>>
>> -Mensagem original-
>> De: sueandant [mailto:hollandsath...@tiscali.co.uk]
>> Enviada em: quarta-feira, 6 de outubro de 2010 17:27
>> Para: sstap...@mnsi.net
>> Cc: PHP
>> Assunto: Re: [PHP] Class mysqli not found
>>
>> Thanks Steve.   Here's the php file:
>>
>> >
>> /**
>> *
>> *
>> * @version $Id$
>> * @copyright 2010
>> */
>> $mysqli = new mysqli("localhost", "root", "woodcote", "testDB");
>>
>> if (mysqli_connect_errno()) {
>> printf("Connect failed: %s\n", mysqli_connect_error());
>> exit();
>> } else {
>> printf("Host information: %s\n", mysqli_get_host_info($mysqli));
>> }
>>
>> ?>
>>
>> When I run this small program I get a Fatal Error: Class mysqli not found
>> error message.
>>
>>
>> - Original Message - From: "Steve Staples" 
>> To: "sueandant" 
>> Cc: "PHP" 
>> Sent: Wednesday, October 06, 2010 9:09 PM
>> Subject: Re: [PHP] Class mysqli not found
>>
>>
>>  On Wed, 2010-10-06 at 21:00 +0100, sueandant wrote:
>>>
 I'm still fighting a losing battle in my attempts to get PHP speak to
 mysqli.   I can access MySql via the prompt. Apache and PHP are
 installed
 and working.   In Apache's config file PHPIniDir is set to "C:\php",
 which is where I unzipped the binary download files, and set LoadModule
 php5_module C:\php\php5apache2_2.dll.   In php.ini I have uncommented
 the
 mysql.dll and mysqli.dll extensions and set extension_dir =
 "C:\php\ext\".   I have edited the environment variables to include
 C:\php  and C:php\ext.

 I am running Vista Home Premium 32 bit with SP2, Apache 2.2, PHP 5.3.3
 and MySql Server 5.1.

 What have I missed?

>>>
>>> How are you connecting to the mysql?  What does your connection string
>>> look like from your php file?  Can you cut and paste it here for us to
>>> trouble shoot (if it is the apache->php->mysql connection problem)
>>>
>>>
>>> Steve
>>>
>>>
>>
>> --
>> 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
>>
>>
> ---
> Simon Welsh
> Admin of http://simon.geek.nz/
>
> Who said Microsoft never created a bug-free program? The blue screen never,
> ever crashes!
>
> http://www.thinkgeek.com/brain/gimme.cgi?wid=81d520e5e
>
>
>
>
>
> --
> 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] Class mysqli not found

2010-10-06 Thread chris h
mysqli is set of functions not a class. The name to connect is
mysqli_connect


mysqli can be used as either a set of functions ( mysqli_connect(..) ) OR it
can be used an an object ( new mysqli(...) ).  When used as an object you
just use the various functions as methods.

http://www.php.net/manual/en/mysqli.connect.php


Chris.


On Wed, Oct 6, 2010 at 4:33 PM, Alejandro Michelin Salomon <
amichel...@hotmail.com> wrote:

> Sueandant :
>
> mysqli is set of functions not a class. The name to connect is
> mysqli_connect
> /**
>  *
>  *
>  * @version $Id$
>  * @copyright 2010
>  */
> $mysqli = mysqli_connect ("localhost", "root", "woodcote", "testDB");
>
> if (mysqli_connect_errno()) {
>  printf("Connect failed: %s\n", mysqli_connect_error());
>  exit();
> } else {
>  printf("Host information: %s\n", mysqli_get_host_info($mysqli));
> }
>
>
> Try adodb lib for php ( http://adodb.sourceforge.net/ ), is great layer on
> top of php db functions.
>
> Alejandro M.S.
>
> -Mensagem original-
> De: sueandant [mailto:hollandsath...@tiscali.co.uk]
> Enviada em: quarta-feira, 6 de outubro de 2010 17:27
> Para: sstap...@mnsi.net
> Cc: PHP
> Assunto: Re: [PHP] Class mysqli not found
>
> Thanks Steve.   Here's the php file:
>
> 
> /**
>  *
>  *
>  * @version $Id$
>  * @copyright 2010
>  */
> $mysqli = new mysqli("localhost", "root", "woodcote", "testDB");
>
> if (mysqli_connect_errno()) {
>  printf("Connect failed: %s\n", mysqli_connect_error());
>  exit();
> } else {
>  printf("Host information: %s\n", mysqli_get_host_info($mysqli));
> }
>
> ?>
>
> When I run this small program I get a Fatal Error: Class mysqli not found
> error message.
>
>
> - Original Message -
> From: "Steve Staples" 
> To: "sueandant" 
> Cc: "PHP" 
> Sent: Wednesday, October 06, 2010 9:09 PM
> Subject: Re: [PHP] Class mysqli not found
>
>
> > On Wed, 2010-10-06 at 21:00 +0100, sueandant wrote:
> >> I'm still fighting a losing battle in my attempts to get PHP speak to
> >> mysqli.   I can access MySql via the prompt. Apache and PHP are
> installed
> >> and working.   In Apache's config file PHPIniDir is set to "C:\php",
> >> which is where I unzipped the binary download files, and set LoadModule
> >> php5_module C:\php\php5apache2_2.dll.   In php.ini I have uncommented
> the
> >> mysql.dll and mysqli.dll extensions and set extension_dir =
> >> "C:\php\ext\".   I have edited the environment variables to include
> >> C:\php  and C:php\ext.
> >>
> >> I am running Vista Home Premium 32 bit with SP2, Apache 2.2, PHP 5.3.3
> >> and MySql Server 5.1.
> >>
> >> What have I missed?
> >
> > How are you connecting to the mysql?  What does your connection string
> > look like from your php file?  Can you cut and paste it here for us to
> > trouble shoot (if it is the apache->php->mysql connection problem)
> >
> >
> > Steve
> >
>
>
> --
> 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] 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  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:
>  class foo {}
> $db = new foo();
> $outA = barA();
> function barA() { global $db; include("Application B"); }
> ?>
>
> Application B:
>  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
>
>


Re: [PHP] which one is faster

2010-10-05 Thread chris h
On Tue, Oct 5, 2010 at 3:58 PM, Steve Staples  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 
> 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
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  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:53 PM, 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 
> 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] 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 
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  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
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  wrote:

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


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  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"  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  wrote:
>>
>>
>>> ""Col Day""  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.
>>>>
>>>>  
>>>>  
>>>>  PHP Test
>>>>  
>>>>  
>>>>  This is an HTML line
>>>>  >>> echo "This is a PHP line";
>>>> phpinfo();
>>>>  ?>
>>>>  
>>>>  
>>>>
>>>> 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] 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  wrote:

> On Tue, Oct 5, 2010 at 12:39 AM, chris h  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)
>


[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] Syntax Error

2010-10-03 Thread chris h
On Sun, Oct 3, 2010 at 12:47 PM, Gary  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)
>
> 
>  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;
> }
> }
> ?>
>  // *** 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;
> }
> }
> ?>
>  $editFormAction = $_SERVER['PHP_SELF'];
> if (isset($_SERVER['QUERY_STRING'])) {
> $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
> }
>
> ?>
>  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] Scraping Multiple sites

2010-10-02 Thread chris h
On Sat, Oct 2, 2010 at 9:03 PM, Russell Dias  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] 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  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] 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  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] 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  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] 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  wrote:

> From: chris h
>
> > On Fri, Sep 24, 2010 at 8:35 AM, Peter Lind 
> wrote:
> >
> >   On 24 September 2010 14:22, Bob McConnell  wrote:
> >   > From: David Hutto
> >   >
> >   >> On Fri, Sep 24, 2010 at 4:09 AM, Gary
>  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] Re: Copying an Object

2010-09-24 Thread chris h
On Fri, Sep 24, 2010 at 8:35 AM, Peter Lind  wrote:

> On 24 September 2010 14:22, Bob McConnell  wrote:
> > From: David Hutto
> >
> >> On Fri, Sep 24, 2010 at 4:09 AM, Gary 
> 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
>
> --
> 
> WWW: http://plphp.dk / http://plind.dk
> LinkedIn: http://www.linkedin.com/in/plind
> BeWelcome/Couchsurfing: Fake51
> Twitter: http://twitter.com/kafe15
> 
>
>


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] 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  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] PHP Email Question

2010-09-20 Thread chris h
> Ignore the other parameters unless you are very familiar with RFCs 2821,
> 2822 and their associated RFCs
>


I would advise against ignoring the other parameters.  Doing so will pretty
much guarantee having your email end up in SPAM.  Instead look up the
examples in the docs, or better yet use something like phpmailer as Tom
suggested.


Chris.


On Sun, Sep 19, 2010 at 6:37 PM, TR Shaw  wrote:

>
> On Sep 19, 2010, at 6:00 PM, Joe Jackson wrote:
>
> > Hi
> >
> > Sorry for the simple question but I am trying to get my head around PHP.
>  I
> > have a sample PHP script that I am trying to use to send a php powered
> email
> > message.  The snippet of code is shown below
> >
> >mail('em...@address.com', 'Subject', $values['message'], "From:
> > \"{$values['name']}\" <{$values['emailaddress']}>");
> >
> > This works fine, but how can I add in other fields to the email that is
> > recieved?
> >
> > For example in the form there are fields called, 'emailaddress',
> > 'telephone', 'address' and 'name' which I need to add into the form along
> > with the message field
> >
> > Also with the formatting how can I change the format of the email to
> >
> > Name: $values['name'],
> > Address: etc
> > Message:
> >
>
> Joe
>
> The mail command lets you send mail (an RFC2821 envelop). The function is:
>
> bool mail ( string $to , string $subject , string $message [, string
> $additional_headers [, string$additional_parameters ]] )
>
> $to is where you want it to go
> $subject is whatever you want the subject to be
> $message is the information you want to send

Ignore the other parameters unless you are very familiar with RFCs 2821,
> 2822 and their associated RFCs


> So if you want to send info from a form you might want to roll it up in xml
> and send it via the message part. when you receive it you can easily decode
> it. If you don't want to do that put it in a format that you can easily
> decode on the receiving end.
>
> Basically "mail" is a way to deliver information in the $message body. How
> you format the information there is up to you. However, depending on your
> system's config you are probably constrained to placing only 7bit ascii in
> the $message body.
>
> You might also move away from the mail function and look at phpmailer at
> sf.net if you need more complex capabilities.
>
> Tom
>
>
>
>


Re: [PHP] How to store data that doesn't change?

2010-09-18 Thread chris h
On Sat, Sep 18, 2010 at 12:37 PM, Ashley Sheridan
wrote:

>  On Sat, 2010-09-18 at 12:21 -0400, chris h wrote:
>
> When you really NEED a global resource I'm a fan of a registry class.  It's
> a little slower but not noticeable in most cases.
>
> With a registry you can store all global data in a single, controlled area.
>  You can also store arrays and resources instead of just strings.  One down
> side to most registry classes is that it's not truly "constant" data, but
> with magic methods you can correct that.
>
>
> In this class you can store values globally, and once they are set they
> can't be easily changed.
>
> myRegistry::get()->test = array('abc','xyz');
> myRegistry::get()->test = 1234;
>
> echo myRegistry::get()->test[1];  // should echo 'xyz'
>
>
> I just typed this up real quick so there may be errors; but if you want to
> try it, it should at least give you the just of it.
> -untested code
> class myRegistry {
>
> private $_Data = array();
>
> static private $_Object = null;
>
>
> static public function get () {
>
>   if( !( self::$_Object instanceof self ))
> self::$_Object = new self();
>
>   return self::$_Object;
>
> }
>
>
> private function __construct () { }
>
>
> public function __get ($name) {
>
>   if (isset( $this->_Data[$name] ))
> return $this->_Data[$name];
>
>   return null;
>
> }
>
>
> public function __set ($name, $value) {
>
>   if (isset( $this->_Data[$name] ))
> return false;
>
>   return $this->_Data[$name] = $value;
>
> }
>
> }
> --
>
> On Thu, Sep 16, 2010 at 10:50 AM, tedd  wrote:
>
> > At 8:46 AM -0400 9/15/10, Peter van der Does wrote:
> >
> >> Hi,
> >>
> >> How do you people store data that doesn't change, an example of this
> >> would be the version number of your software. You might want to use it
> >> through out your program but how to you store it?
> >>
> >> As far as I can see there are several options to use this data.
> >> 1. Global Variable
> >> 2. Store it in a registry class
> >> 3. Store it in a named constant.
> >> 4. Use a function that will return the data (kind of like a regsitry
> >> class but it's not a class)
> >>
> >> Personally I don't like option 1 but what about the other options. Is
> >> any of them faster then the others. What other pros and cons are there.
> >>
> >
> > Make it's a Constant -- it's simply a Global that doesn't change.
> >
> > I typically hold such things in a global configuration file that can be
> > included when needed.
> >
> > Cheers,
> >
> > tedd
> >
> > --
> > ---
> > http://sperling.com/
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>
>
> You might want to add in some error returns from the setters instead of
> just false, as attempting to overwrite a real constant would issue a notice.
>
>
>   Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>

I agree Ash, good idea and thanks for the feedback! :)


Re: [PHP] How to store data that doesn't change?

2010-09-18 Thread chris h
When you really NEED a global resource I'm a fan of a registry class.  It's
a little slower but not noticeable in most cases.

With a registry you can store all global data in a single, controlled area.
 You can also store arrays and resources instead of just strings.  One down
side to most registry classes is that it's not truly "constant" data, but
with magic methods you can correct that.


In this class you can store values globally, and once they are set they
can't be easily changed.

myRegistry::get()->test = array('abc','xyz');
myRegistry::get()->test = 1234;

echo myRegistry::get()->test[1];  // should echo 'xyz'


I just typed this up real quick so there may be errors; but if you want to
try it, it should at least give you the just of it.
-untested code
class myRegistry {

private $_Data = array();

static private $_Object = null;


static public function get () {

  if( !( self::$_Object instanceof self ))
self::$_Object = new self();

  return self::$_Object;

}


private function __construct () { }


public function __get ($name) {

  if (isset( $this->_Data[$name] ))
return $this->_Data[$name];

  return null;

}


public function __set ($name, $value) {

  if (isset( $this->_Data[$name] ))
return false;

  return $this->_Data[$name] = $value;

}

}
--

On Thu, Sep 16, 2010 at 10:50 AM, tedd  wrote:

> At 8:46 AM -0400 9/15/10, Peter van der Does wrote:
>
>> Hi,
>>
>> How do you people store data that doesn't change, an example of this
>> would be the version number of your software. You might want to use it
>> through out your program but how to you store it?
>>
>> As far as I can see there are several options to use this data.
>> 1. Global Variable
>> 2. Store it in a registry class
>> 3. Store it in a named constant.
>> 4. Use a function that will return the data (kind of like a regsitry
>> class but it's not a class)
>>
>> Personally I don't like option 1 but what about the other options. Is
>> any of them faster then the others. What other pros and cons are there.
>>
>
> Make it's a Constant -- it's simply a Global that doesn't change.
>
> I typically hold such things in a global configuration file that can be
> included when needed.
>
> Cheers,
>
> tedd
>
> --
> ---
> http://sperling.com/
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] 1984 (Big Brother)

2010-09-18 Thread chris h
So whenever the boss is in a meeting and his screen saver kicks on then the
business shuts down.  Also I think we've established that thumbdrive +
database = disaster.

Maybe a thumbdrive that has file with some random hash.  Then create a cron
that checks for the existence of that file each minute.  When the boss
leaves the cron doesn't find the file and shuts down the DB, when the boss
comes in the cron will see it and starts it up.

But Tedd, I'm still thinking that a "dead man's switch" is the way to go.
 :)

Chris.

On Sat, Sep 18, 2010 at 8:03 AM, TR Shaw  wrote:

> If you mean "not logoff properly" as, for instance, getting up and leaving
> his office for the day without logging off you can run a script when the
> machine "sleeps" or the screen saver runs and runs again when the machine
> transitions back to run.
>
> If your talking about powering off, same scripting approach as above (or
> just put DB on Boss' machine and if its off or crashes access ceases.
>
> As a crazy approach, put the DB on a thumb drive and attach the thumb to
> the Boss' car or house keys. He plugs the thumb in when he wants to "grant"
> access and takes it when he leaves because he need his keys.
>
> On Sep 17, 2010, at 11:44 PM, viraj wrote:
>
> >>
> >> Remind him that he must logout normally to lock the DB
> >
> > if you follow the thread closely, this is a requirement. boss may not
> > logout properly :)
> >
> > that's why all suggest a mechanical ways for the job. pressure
> > sensors, cameras etc etc
> >
> > ~viraj
> >
> >>
> >>
> >>
> >> On Sep 12, 2010, at 12:37 PM, Joshua Kehn wrote:
> >>
> >>> Tedd-
> >>>
> >>> Would he consider access to another database? I.e. a separate, say
> memcached db which stores the "boss" status?
> >>>
> >>> An issue with the temporary file would also be session length, if the
> session expires without the user explicitly logging off, the file wouldn't
> be removed. A way to bypass this would be to add some sort of session
> expiration header to the file and update that.
> >>>
> >>> And couldn't you make a simple check if the boss is logged in or not by
> the ability to access the database?
> >>>
> >>> Regards,
> >>>
> >>> -Josh
> >>> 
> >>> Joshua Kehn | josh.k...@gmail.com
> >>> http://joshuakehn.com
> >>>
> >>> On Sep 12, 2010, at 12:32 PM, tedd wrote:
> >>>
> >>>> 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
> >>>>
> >>>> --
> >>>> ---
> >>>> http://sperling.com/
> >>>>
> >>>> --
> >>>> 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
> >>>
> >>
> >>
> >> --
> >> 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
> >
>
>
> --
> 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.


  1   2   3   4   5   6   7   8   9   10   >