[PHP] Exporting HTML to Excel

2004-10-12 Thread Philip Thompson
Hi all.
This may not be completely a PHP question, but hopefully you will be 
able to provide some insight. I have a table in HTML that I want to 
export to an excel spreadsheet. Using PHP, I can create an excel 
document - however, it's empty/blank. I think I am just doing it 
incorrectly. Anybody done this before and/or have any ideas? I would 
prefer to NOT use a third-party program.

I've searched the web and php.net, but have been somewhat unsuccessful 
in finding anything. Here's what I have so far:

-



Something
Something else


-
I just want it to have that content in the spreadsheet. It's actually 
more involved than that, but that's the gist of it.

Thanks in advance.
~Philip
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Exporting HTML to Excel

2004-10-13 Thread Philip Thompson
How exactly would I change the mime headers?
~Philip
On Oct 12, 2004, at 5:07 PM, Vail, Warren wrote:
Have you tried changing your file name to project.htm but continue 
issuing
the mime headers for excel?

Warren Vail
-Original Message-
From: Philip Thompson [mailto:[EMAIL PROTECTED]
Sent: Tuesday, October 12, 2004 2:21 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Exporting HTML to Excel
Hi all.
This may not be completely a PHP question, but hopefully you will be
able to provide some insight. I have a table in HTML that I want to
export to an excel spreadsheet. Using PHP, I can create an excel
document - however, it's empty/blank. I think I am just doing it
incorrectly. Anybody done this before and/or have any ideas? I would
prefer to NOT use a third-party program.
I've searched the web and php.net, but have been somewhat unsuccessful
in finding anything. Here's what I have so far:
-



Something
Something else


-
I just want it to have that content in the spreadsheet. It's actually
more involved than that, but that's the gist of it.
Thanks in advance.
~Philip
--
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] Exporting HTML to Excel

2004-10-13 Thread Philip Thompson
Chris, as you may have (or may have not) noticed, I did that. Look at 
my original email. I wasn't sure if there was more to it than that.

~Philip
On Oct 13, 2004, at 8:34 AM, Chris Dowell wrote:
Header("Content-type: application/ms-excel");
or whatever the content type should be (on IE you can probably get 
away with application/octet-stream as it bases its decisions of file 
extensions for a lot of things).

HTH
Chris
Philip Thompson wrote:
How exactly would I change the mime headers?
~Philip
On Oct 12, 2004, at 5:07 PM, Vail, Warren wrote:
Have you tried changing your file name to project.htm but continue 
issuing
the mime headers for excel?

Warren Vail
-Original Message-----
From: Philip Thompson [mailto:[EMAIL PROTECTED]
Sent: Tuesday, October 12, 2004 2:21 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Exporting HTML to Excel
Hi all.
This may not be completely a PHP question, but hopefully you will be
able to provide some insight. I have a table in HTML that I want to
export to an excel spreadsheet. Using PHP, I can create an excel
document - however, it's empty/blank. I think I am just doing it
incorrectly. Anybody done this before and/or have any ideas? I would
prefer to NOT use a third-party program.
I've searched the web and php.net, but have been somewhat 
unsuccessful
in finding anything. Here's what I have so far:

-



Something
Something else


-
I just want it to have that content in the spreadsheet. It's actually
more involved than that, but that's the gist of it.
Thanks in advance.
~Philip
--
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] Re: Exporting HTML to Excel

2004-10-13 Thread Philip Thompson
On Oct 13, 2004, at 10:40 AM, Gryffyn, Trevor wrote:
To all who've helped.
Thanks for your input. [embarrassment] Truthfully, when I gave that
example in my original email, I didn't try that specific one. But it
did work for me also when I attempted that one. [/embarrassment]
The reason I was getting a blank spreadsheet was b/c I was
only showing
specific columns based on whether certain $_SESSION variables
were set.
However, the page that's supposed to export to excel, I did
not include
my `session_start()`, so none of the variables were ever TRUE. Once I
saw that and fixed it, it worked like a charm!
But I have run across a small dilemma at this point. I cannot
open the
excel file using IE. However, I can through Mozilla and Safari. Guess
this is something else I have to look at and try to tackle!
Thanks again!
~Philip



Something
Something else



Btw: the example above has a  instead of a  on the second cell
so it puts the values in A1 and A2 instead of A1 and B1.
Yeah, I realized that also whenever all of my items were going in 
column A. But I fixed that.

Another note, I put a =A1+B1 and it worked fine (put the
formula in and it evaluates just fine that is).
Neeto feature!
Also, if you're having trouble in IE (I didn't, it worked fine) you
might try changing the MIME type to something that'll download and give
the option of save/open.  There was another thread on this list about
creating folders (not with PHP, but opening a file dialog so the user
could create a folder for the download) that had a lot of good info
about forcing the browser to open that dialog box.
What problem are you having in IE right now?  Is it opening INSIDE IE 
as
an Excel sheet embedded or something (like PDFs do with Acrobat 
Reader)?
I had that happen once or twice while testing the code above.
Well, whenever I click on the link to export to excel (in IE), a "File 
Download" box pops up. It says the 'File name: toexcel.php' and the 
'File type: ' (blank). It asks if I want to open or save. However, the 
File name should not be toexcel.php (that's the page), it should be 
'project.xls'.

The error message I get whenever I try to Open or Save the file is: "IE 
cannot dowload toexcel.php from your.server.com. IE was not able to 
open this Internet site. The requested site is either unavailable or 
cannot be found. Please try again later." This is obviously not true 
b/c I can download from elsewhere.

Here's what I have included in the top of my file (just to reiterate):
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment; filename="project.xls"');
I tried adding the `vnd.` to the content-type, thinking that IE might 
like that better, but it didn't. It works just the same though.

Anyway, good luck. Glad you figured out the session problem, that can 
be
frustrating.

-TG
Thanks. Any ideas?
~Philip
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: Exporting HTML to Excel

2004-10-13 Thread Philip Thompson
On Oct 13, 2004, at 11:30 AM, John Holmes wrote:
Philip Thompson wrote:
Well, whenever I click on the link to export to excel (in IE), a 
"File Download" box pops up. It says the 'File name: toexcel.php' and 
the 'File type: ' (blank). It asks if I want to open or save. 
However, the File name should not be toexcel.php (that's the page), 
it should be 'project.xls'.
This is a known issue with IE. I think one workaround is to give the 
filename in the query string as the last variable, i.e.

toexcel.php?f=project.xls
You can just ignore $_GET['f'] in your code, but I think IE will pick 
that up as the filename when you send the download headers.
Tried this, but it doesn't work.

The error message I get whenever I try to Open or Save the file is: 
"IE cannot dowload toexcel.php from your.server.com. IE was not able 
to open this Internet site. The requested site is either unavailable 
or cannot be found. Please try again later." This is obviously not 
true b/c I can download from elsewhere.
Is this over SSL? I've had issues with this also and the solution was 
to change the session.cache_limiter value. It interfered with the 
download for some reason. A search of the archives should bring up 
some relevant threads.
Yes, this is on a secure server. I don't have access at this point to 
the .ini file at this point, but I will look into this when my 
supervisor returns tomorrow. Do you happen to know what value to change 
the session.cache_limiter to? I'll search the archives also.

---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
Thanks a bunch.
~Philiip
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] session timeout

2004-10-04 Thread Philip Thompson
Hi all.
I have users log into my site to perform certain actions. However, I 
want to create a timed session so that it automatically logs them out 
after a certain amount of time. I am using 
`session_set_cookie_params()` to create the amount of available time 
that the user is logged in.

But my question is: how do I test to see if the session has timed out? 
Once the session time has elapsed, are the $_SESSION variables 
automatically destroyed or what?

Thanks in advance,
~Philip
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] I'm looking to have a simple webpage send an email . ..

2004-10-04 Thread Philip Thompson
John,
On Oct 4, 2004, at 1:25 PM, John Nichel wrote:
Answers are usually found in a four step process...
RTFM
STFA
STFW
Mailing List
Can you clarify these abbr.? I think I understand the first one, but 
what are the next two? Hehe

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


[PHP] Page cannot be displayed after form submission

2004-10-07 Thread Philip Thompson
Hi all.
I have a form that calls the same page whenever it is submitted. It 
does some error-checking to make sure that all the appropriate fields 
were filled in by the user. So, if there's an error, it stays on the 
same page and lets the user know what they need to fill in.

However, I get `Page cannot be displayed` error if the page calls 
itself and has to reload some data but only in IE for Windows. If I 
hit the `Refresh` button, the page shows up and all the appropriate 
fields are filled in or not filled in with the specified error message.

It does not give the `Page cannot be displayed` error in other 
browsers: Mozilla and Firefox for Windoze, Safari and IE for Mac. 
Despite the fact that IE for Windoze is immensely inferior, is there a 
reason/get-around for this happening?

I can actually fix it to where it doesn't do it, but it's a hack. I 
have the form actually call a different page - but then that page just 
has an automatic redirect back to the original page. And all the 
information shows up correctly without the `Page cannot be displayed.`

Thanks for staying in tuned this far. Anyone have any thoughts on why 
this is happening?

Thanks in advance.
~Philip
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] dirty words

2004-10-18 Thread Philip Thompson
  $badwords = array('poo', 'bum', 'perl');
Perl. Laf!
~P
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] people/projects looking for developers...

2004-10-19 Thread Philip Thompson
On Oct 18, 2004, at 9:06 PM, bruce wrote:
interesting...
for the most part, people have responded with contract resource 
sites...
(guru.com/elance.com/etc)

no one has mentioned any kind of site specifically geared towards 
people who
want to come together to kind of build applications. ala the old
garage/basement type of process were you get a few guys together with 
a few
sales guys, and they build/start to sale the app, and create a biz...

so my question i guess, is why the hell isn't there more of an 
interest in
this kind of atmosphere..

have people just been too dam* burned too many times, or are people 
really
just satisfied with their jobs
What'd you have in mind? I'm freshly out of college and would be up for 
most things...

~Philip
interesting...
thanks
-bruce
-Original Message-
From: Dan Joseph [mailto:[EMAIL PROTECTED]
Sent: Monday, October 18, 2004 6:57 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] people/projects looking for developers...

a question for consideration. are there sites set up for people who 
have
ideas/projects, who are looking for developers. or vice versa, are 
there
sites for developers who are looking to be part of projects.

i'm not referring to open source projects, rather projects that are
intended
to be revenue generating businesses.
www.itmoonlighter.com is one that I use to use.  It has both companies
looking to find developers for their projects, and developers looking
for extra work.  I'm sure there are other sites, but I can't think of
'em.
-Dan Joseph
--
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] str_replace problem

2004-10-20 Thread Philip Thompson
On Oct 20, 2004, at 1:02 AM, Chris Ditty wrote:
Hi all.  I'm trying to do a little code snippets page for a site I am
working on.  I figured it would be simple enough.  I would do a
str_replace and replace the various html codes with the ascii
eqivulant.  Unfortunately, it is not working as expected.  Can anyone
help with this?
This is what I am using.
$snippetCode = str_replace("\n", "", $snippet['snippetCode']);
$snippetCode = str_replace("<", ">", $snippetCode);
< is actually less than
$snippetCode = str_replace(">", "<", $snippetCode);
and > is greater than. Don't know if this makes a difference to you.
$snippetCode = str_replace("&", "&", $snippetCode);
This is what is in $snippet['snippetCode'].
?>
This is what is showing on the web page.
?<>pre<>? print_r($ArrayName); ?<>/pre<>?
If anyone can help, it would be appreciated.  Also, if you have a
quick and dirty code colorer, I would appreciate that.
Thanks
Chris
Like the others have said, consider using htmlspecialchars().
Have fun!
~Philip
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Mac OS X and Editor

2004-10-21 Thread Philip Thompson
On Oct 20, 2004, at 3:57 PM, Michael Sims wrote:
Jonel Rienton wrote:
Hi guys, I just like to ask those using Macs here as to what editor
and/or IDE they are using for writing PHP codes.
I don't personally use Mac OS X, but let me throw in a recommendation 
for jEdit
(www.jedit.org).  It's Java based, hence cross-platform, and extremely 
powerful.  I
use it on Windows and couldn't live without it.  I have installed it 
on my friend's
iMac long enough to see that it works, but not long enough to know of 
any
platform-specific issues and/or gotchas.
I use Xcode to do all my coding.
Just a side-comment: in general, OS X users enjoy/use Cocoa-based 
applications over Java-based. Cocoa provides the "OS X Experience" with 
the native aqua interface and other cool features that Java cannot 
always supply. (Not intending to start a discussion... just informing 
those non-Mac users.)

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


Re: [PHP] how to display new icon for news posted within 2 days?

2009-01-15 Thread Philip Thompson
2 things. In that query, you can't have a comma in your 172,800. It's  
going to fail b/c 800 isn't a column name. Unless it actually is, then  
you're good to go. =D Secondly, to be more user friendly, if the user  
has viewed that news item, then mark it as read (take away the  
new.gif). There are a couple of ways to achieve this. One, you can use  
cookies to keep track of what they've read. The other is to keep track  
in the database (sorta like user preferences). Good luck.


~Philip

PS... Sorry to top post. It was the trend of the email and I didn't  
want to break it.


On Jan 15, 2009, at 7:50 AM, Phpster wrote:


That should work as well

Bastien

Sent from my iPod

On Jan 15, 2009, at 4:14 AM, paragasu  wrote:


is it possible to do it like
SELECT *, UNIX_TIMESTAMP(post_date)-172,800 as is_new FROM tbl

$post = mysqli_fetch_object($sql);
if($post->is_new)
echo '';

On 1/14/09, Phpster  wrote:

Make it easy and store the date as a unix timestamp. Then it's a
simple testto do

If ((current timestamp - db timestamp) < 172,800 ){
echo '';
}

Conversely, you can use strtotime() to convert the date.

Bastien

Sent from my iPod

On Jan 14, 2009, at 10:36 PM, paragasu  wrote:


i do have a mysql table with one date field.
what i want is to display and tiny icon (red new icon) so user will
notice it is a new post.
i am looking for the simplest solutions here.

i believe we can calculate whether the date is within two days of  
user

current time.
then we display an icon based on it.

can anyone help?

thanks


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



Re: [PHP] Client/Server Printing

2009-01-20 Thread Philip Thompson

On Jan 20, 2009, at 9:16 AM, Paul M Foster wrote:


I'd like a side check on what I'm doing to print on our internal
network.

We have an internal server/site which uses PHP code I've written to
"run" the business-- invoicing, A/P, inventory, etc. Some things, like
invoices and reports, need to be printed. Now remember, the code is on
the server, and we access it from our client machines on our desks.  
When

we print, we do so to our local printers, attached to the client
machines.

So the best way I could think of to making printing work was to  
generate

PDFs of whatever needs to be printed, dump the PDF on the server, and
provide a link to the PDF on the web page. The user clicks on the
generated PDF, and his/her browser opens up Acrobat or xpdf, and  
prints

from that application to their local machine.

Is that a reasonable way to implement this? Any better ideas?

Paul


We've addressed this issue in two ways. Originally our application was  
locally hosted. The solution for us was:


exec ("psexec.exe -d -i -w ". escapeshellarg($filepath) ." -u  
$user -p ". escapeshellcmd ($pass) . " -e gswin32c.exe -q -dNOPAUSE - 
dNOPROMPT -dQUIET -dBATCH -dNumCopies=$copies -sDEVICE=msinwpr2 - 
sOutputFile=\"spool\\$printerShare\" \"$pdfFilepath\" 2>&1");

}
else {
exec ("/usr/bin/lpr -# $copies -P ".  
escapeshellarg($printerShare) ." \"$pdfFilepath\" 2>&1");

}
?>

The Windows version uses psexec to call ghostscript. So you do have to  
use third-party utilities for Windows (but they are small). However,  
if on *nix, then you can use the built in lpr. Of course, just put  
that code in a function that is called when clicked on a link to print.


http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx
http://www.ghostscript.com/

Our online solution uses a third-party utility for printing  
(Cloverleaf/Secure Courier). Essentially we have a (print) server and  
each of our clients have a client-version that connects to the print  
server. In our application, we use sockets to send print jobs to the  
server. The server then divvies out the print jobs to the specific  
client id specified in the data sent through the socket. However,  
since all your servers/clients are local, the first option may be more  
realistic.


Hope that helps,

~Philip

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



[PHP] Imagick->setImageFormat()

2009-01-29 Thread Philip Thompson

Hello all.

I'm pretty new to Imagick. I'm merely attempting the examples on the  
PHP site (http://php.net/manual/en/imagick.examples-1.php), but I'm  
having some issues. I'm attempting the reflection of an image example  
and when I attempt to:


$canvas->setImageFormat("png");

I get an error that reads:

Fatal error: Uncaught exception 'ImagickException' in /home/www/pc4/ 
image.php:67 Stack trace: #0 /home/www/pc4/image.php(67): Imagick- 
>setimageformat('png') #1 {main} thrown in /home/www/pc4/image.php on  
line 67


Note that I CAN do this: $canvas->setImageFormat("gif");

I'm running Fedora Core 8. My first thought was that my machine  
doesn't support PNG. So I checked for libpng, and it's there and up to  
date. I've looked at my http error logs and I've google'd to no avail.  
Do you have any thoughts on why I can't use the "png" format?


Thanks in advance,
~Philip

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



[PHP] Re: Imagick->setImageFormat()

2009-01-29 Thread Philip Thompson

On Jan 29, 2009, at 4:20 PM, Philip Thompson wrote:


Hello all.

I'm pretty new to Imagick. I'm merely attempting the examples on the  
PHP site (http://php.net/manual/en/imagick.examples-1.php), but I'm  
having some issues. I'm attempting the reflection of an image  
example and when I attempt to:


$canvas->setImageFormat("png");

I get an error that reads:

Fatal error: Uncaught exception 'ImagickException' in /home/www/pc4/ 
image.php:67 Stack trace: #0 /home/www/pc4/image.php(67): Imagick- 
>setimageformat('png') #1 {main} thrown in /home/www/pc4/image.php  
on line 67


Note that I CAN do this: $canvas->setImageFormat("gif");

I'm running Fedora Core 8. My first thought was that my machine  
doesn't support PNG. So I checked for libpng, and it's there and up  
to date. I've looked at my http error logs and I've google'd to no  
avail. Do you have any thoughts on why I can't use the "png" format?


Thanks in advance,
~Philip


Ok, I figured it out. Along with that error message I was receiving  
"identify: no decode delegate for this image format" when I attempted  
to open up a PNG image. Well, after some searching, I discovered that  
that basically means you don't have the libraries to support that  
image type. The weird part is, I did have libpng. However, I think I  
may have installed it after I built ImageMagick. So, I rebuilt  
ImageMagick. This time I looked at the configuration and png support  
was enabled. It works now! Yay!


This person was having a similar issue and it helped me figure out  
what I need to know:

http://www.vbulletin.com/forum/archive/index.php/t-197439.html

Also, directions for installing ImageMagick from source:
http://www.imagemagick.org/script/install-source.php

Cheers!
~Philip

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



[PHP] CLI not obeying php.ini

2009-02-05 Thread Philip Thompson

In my php.ini, I have

error_reporting = E_ALL & ~E_NOTICE

When I run a script from the command line, I get a lot of notices  
even when I said I don't want them. Also, in my script, I specified  
error_reporting(E_ERROR) in attempts to explicitly tell it what I  
want. It doesn't work either.


Why am I still getting notices?! BTW, I don't receive notices via a  
web browser, just CLI.


I double-checked to see what INI file was loaded and it's the one I  
expected to see:


[pthomp...@pthompson scripts]$ php --ini
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /etc/php.ini

Thoughts on what's happening would be awesome! Thanks in advance.

~Philip

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



Re: [PHP] CLI not obeying php.ini

2009-02-05 Thread Philip Thompson

On Feb 5, 2009, at 4:17 PM, Ashley Sheridan wrote:


On Thu, 2009-02-05 at 15:45 -0600, Philip Thompson wrote:

In my php.ini, I have

error_reporting = E_ALL & ~E_NOTICE

When I run a script from the command line, I get a lot of notices
even when I said I don't want them. Also, in my script, I specified
error_reporting(E_ERROR) in attempts to explicitly tell it what I
want. It doesn't work either.

Why am I still getting notices?! BTW, I don't receive notices via a
web browser, just CLI.

I double-checked to see what INI file was loaded and it's the one I
expected to see:

[pthomp...@pthompson scripts]$ php --ini
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /etc/php.ini

Thoughts on what's happening would be awesome! Thanks in advance.

~Philip


Depending on what distro (I'm assuming Linux, who would run PHP on
anything else? ;) ) you may have a separate php.ini for the CLI. I
believe SUSE does this, and it could well be that other distros use a
similar model.

If you are running SUSE, the config files should be in /etc/php5/


Ash
www.ashleysheridan.co.uk


There are other .ini files located in /etc/php.d, but none specify  
error_reporting...


~Phil

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



Re: [PHP] CLI not obeying php.ini

2009-02-05 Thread Philip Thompson

On Feb 5, 2009, at 4:10 PM, Chris wrote:


Philip Thompson wrote:

In my php.ini, I have
error_reporting = E_ALL & ~E_NOTICE
When I run a script from the command line, I get a lot of  
notices even when I said I don't want them. Also, in my script,  
I specified error_reporting(E_ERROR) in attempts to explicitly tell  
it what I want. It doesn't work either.
Why am I still getting notices?! BTW, I don't receive notices via a  
web browser, just CLI.
I double-checked to see what INI file was loaded and it's the one I  
expected to see:

[pthomp...@pthompson scripts]$ php --ini
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /etc/php.ini
Thoughts on what's happening would be awesome! Thanks in advance.


Are you including another script (eg pear mail or mbd2 or whatever)?  
Maybe it's setting something and overriding your attempt. A quick  
grep would be able to check that.


I am including other classes. I did a grep on the whole directory and  
the only location that had error_reporting was the spot I wrote into  
my script to force it to E_ERROR. Odd, I know...


Thanks,
~Philip

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



Re: [PHP] CLI not obeying php.ini

2009-02-05 Thread Philip Thompson

On Feb 5, 2009, at 4:20 PM, Boyd, Todd M. wrote:


-Original Message-
From: Philip Thompson [mailto:philthath...@gmail.com]
Sent: Thursday, February 05, 2009 3:45 PM
To: PHP General list
Subject: [PHP] CLI not obeying php.ini

In my php.ini, I have

error_reporting = E_ALL & ~E_NOTICE

When I run a script from the command line, I get a lot of notices
even when I said I don't want them. Also, in my script, I specified
error_reporting(E_ERROR) in attempts to explicitly tell it what I
want. It doesn't work either.

Why am I still getting notices?! BTW, I don't receive notices via a
web browser, just CLI.

I double-checked to see what INI file was loaded and it's the one I
expected to see:

[pthomp...@pthompson scripts]$ php --ini
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /etc/php.ini

Thoughts on what's happening would be awesome! Thanks in advance.


In addition to what's already been said, you could try forcing a  
php.ini
file in the current directory by trying the -c command line option.  
I've

done it to try messing with a handful of values here and there for
particular scripts.

HTH,

// Todd


I tried this as well. No luck.

[pthomp...@pthompson scripts]$ php -c /etc -f updateLabels.php >  
labels.log


This issue is mainly annoying and not really a bigger issue b/c  
clients don't see it. Hrm. Oh well. Still open to suggestions. Should  
I try kicking my (virtual) machine? =D


~Philip

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



[PHP] Accessors

2009-02-18 Thread Philip Thompson

Hi all.

Maybe I'm wanting more Java-like functionality out of PHP, but I don't  
really like getting and setting members directly (even for public  
members) - I'd rather use accessors. This way you can control what is  
getting set and what is returning. However, I also don't really want  
to create a million get/set accessor methods - this is no fun and  
takes up a lot of space. After reading around a little bit, it got me  
thinking about overloading in PHP (which I'm sure we all know is  
completely different than any other language... but that's another  
day). I didn't want to use the standard __get and __set methods  
because that still leaves me with the same notation for getting/ 
setting members. So, instead, I used a close relative of __get and  
__set. Meet brother __call. Could it really be this trivial to get the  
notation I'm wanting? Yes. Yes it is. Ok, enough talking... onto the  
code.


$member;
return $value;
}

// Oh, args is not empty! Set the value
$this->$member = $args;
}
else {
// Blow up!
die ("Fatal Error: Call to undefined member: $member.  
Exiting...");

}
}
}

$person = new Person();

// Set the (private) first and last names
$person->first('Billy');
$person->last('Bob');

// Get the (private) first and last names
echo $person->first() . " " . $person->last()."";

// Set the (public) age
$person->age(103);

// Get the (public) age
echo "Age: ".$person->age()."";

// Explosions
$person->first = 'Buford';
$person->pizza('Is yummy');
?>

Now if you're reading this and thinking "Duh!" then good for you.  
However, I know there's at least 1 soul on this list who may benefit  
from this. But don't stop at the example above. If you want to add  
validation to the members you're getting/setting, build that into your  
code. If you want each member to be a specific type, include that as  
well (I'll leave the implementation up to you). ;-)


So let's recap.

•  This functionality allows me to not have to write 2 accessors for  
every member
•  This allows me to use methods instead of directly getting/setting  
members (even though I can still access public members directly... if  
I want)
•  Keeps code consistent and less confusing - I know how to get and  
set every member


What are your thoughts? Does this seem like a reasonable  
implementation? Useful? Pointless? Hit me up - I can handle  
*constructive* criticism. But for now, it's late and past my bedtime.


Cheers,
~Philip

"innerHTML is a string. The DOM is not a string, it's a hierarchal  
object structure. Shoving a string into an object is impure and  
similar to wrapping a spaghetti noodle around an orange and calling it  
lunch."

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



Re: [PHP] Accessors

2009-02-19 Thread Philip Thompson

On Feb 19, 2009, at 10:55 AM, Jochem Maas wrote:


please keep replies on list.


Sorry!


Philip Thompson schreef:

On Feb 19, 2009, at 2:59 AM, Jochem Maas wrote:


Philip Thompson schreef:

Hi all.






What are your thoughts? Does this seem like a reasonable  
implementation?
Useful? Pointless? Hit me up - I can handle *constructive*  
criticism.

But for now, it's late and past my bedtime.


how do you set a property to null?


Oh sure, point that out! JK. I thought of that as well. For members
where 'null' is an option, you may just want to create a definitive
accessor or modify the __call() function. Use a string to represent  
null

- I'll use 'nil' from objective-c. Something like this...


yes but then someone might want to set the value to 'nil' or '__nil'
or any other magic value you might want to use.

what about capturing a method name prefix:

$person->unsetFirst();


Yes, that is quite a viable option. I thought about the same thing,  
except for setting the member. Modify the __call method to check for  
'set' before the member name


$person->setFirst('John');
$person->setFirst(null);

If you do it this way, there is no doubt that you are wanting to set  
the value. And it even allows null.


~Philip



$member;
   return $value;
   }

   // Test to see if value is 'nil'. If so, set to null.
   if (!is_array ($args[0]) && $args[0] == 'nil') {
   $args[0] = null;
   }

   $this->$member = $args;
   }
   else {
   die ("Fatal Error: Call to undefined member: $member.  
Exiting...");

   }
}

$person = new Person();
$person->first('Billy');
$person->first('nil');
?>

I suppose it's a possibility that someone will assign 'nil' to a  
member

as an actual value, so put in some more checking or modify the null
keyword - maybe '__nil' or whatever? That a possibility?

Cheers,
~Phil


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



Re: [PHP] PHP/MYSQL/ Encrypting Sensetive information

2009-04-17 Thread Philip Thompson

On Apr 17, 2009, at 10:17 AM, Stefan Langwald wrote:


MySQLs own Function AES_(EN|DE)CRYPT is pretty cool for this case.
--

Stefan Langwald


We use MySQL's AES_(EN|DE)CRYPT. It's fast, easy to use and uses 128  
bit encryption (optionally 256).


http://dev.mysql.com/doc/refman/5.1/en/encryption-functions.html

~Philip



2009/4/17 דניאל דנון :
If its by a user-basis, something that can be a bit risky but  
possible - You
can encrypt it, password is hashed on database, and the key to the  
other

data is the un-encrypted password..

On Fri, Apr 17, 2009 at 5:00 PM, Russell Jones   
wrote:



We are looking at a project where we will potentially need to store
sensetive information in a few fields of a MySQL table. Any  
recommendations
on where to look for best practices in doing this? for encrypting  
the data,
etc.? We will need to be able to decrypt the data as well,  
although this

can
probably be done locally, so hashing alone is not really an option.

Russell Jones


--
Use ROT26 for best security


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



Re: [PHP] niewbie - call methods from another class

2009-04-20 Thread Philip Thompson

On Apr 19, 2009, at 9:43 AM, MEM wrote:


Hello, I have something like this:

$stmt = $this->_dbh->prepare("INSERT INTO DOG (name_dog, race_dog,  
id_vet)

VALUES (?, ?, ?)");

$stmt->bindParam(1, $this->getNameDog() );
$stmt->bindParam(2, $this->getRaceDog());
$stmt->bindParam(3, );


$stmt->execute();
  }

To make this insert function work, I need to fill the id_vet  
database column

with some values.
I cannot use $this->getIdVet() because this method is not in dog  
class, is

on the veterinary class.
So my question is:
How can I access the getIdVet() that is on the veterinary class to  
put it on

the insert dog method?


Thanks a lot,
Márcio


Try this

id;
}
}

class dog {
public function add () {
$vet = new veterinary ();

$stmt = $this->_dbh->prepare("INSERT INTO DOG (name_dog,  
race_dog, id_vet) VALUES (?, ?, ?)");


$stmt->bindParam(1, $this->getNameDog());
$stmt->bindParam(2, $this->getRaceDog());
$stmt->bindParam(3, $vet->getIdVet());
$stmt->execute();
}
}
?>

Of course here you will have to determine how the vet id is set. The  
method getIdVet has a redundant name. Since it's already in the  
veterinary class, just use getId() or id(). However, you'll probably  
want to change the above implementation to not create the veterinary  
in the add() method. You'll probably want to create it in the dog  
constructor...


vet = new veterinary ($vetId);
}
...
}
?>

And use $this->vet instead of $vet in the dog->add() method. Hope that  
helps. Do a little reading to try to understand using objects a little  
bit more.


http://php.net/object

~Philip


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



Re: [PHP] 800 pound gorilla

2009-04-20 Thread Philip Thompson

On Apr 20, 2009, at 8:48 AM, Marc Christopher Hall wrote:

Sun buys MySQL and now Oracle buys Sun (not final, yet). What will  
happen
with the main db we PHP'ers have come to know and love especially  
since v 5


Probably nothing. It would not behoove Oracle to get rid of or  
significantly modify MySQL. It appears that Oracle will just get  
richer... =D


~Philip

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



[PHP] Unit Testing

2009-04-27 Thread Philip Thompson
Hi. I did some searching in the archives, but didn't quite find what I  
was looking for. Maybe a few of you can assist me...


We have an application that's currently in production, but we're  
constantly modifying/upgrading it. We did not do unit testing early on  
because of the lack of time. Now that some time has opened up, we're  
considering unit testing. My question is. is it reasonable to  
start unit testing at this point in time with the application mostly  
built? Besides being really time-consuming, what are the pitfalls of  
starting unit testing at this stage?


Thanks in advance,
~Philip

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



Re: [PHP] Re: Unit Testing

2009-04-27 Thread Philip Thompson

On Apr 27, 2009, at 11:38 AM, Simon wrote:


As a programmer, i always test what I'm coding as i code it (mostly to
make sure i dont include typos), but i feel it is best to make proper
testing once the component is ready and working fine.  If your project
is large, it might be a good idea to break it in several 'modules' or
section if possible and treat each of them as separate projects
(testing would be done on a module once this one is ready).

You may be interested in looking for information on the net on 'IT
project management' which usually describe when is the best time to
test according to a certain structure...

Simon

On Mon, Apr 27, 2009 at 12:16 PM, Nathan Rixham   
wrote:

Philip Thompson wrote:


Hi. I did some searching in the archives, but didn't quite find  
what I was

looking for. Maybe a few of you can assist me...

We have an application that's currently in production, but we're
constantly modifying/upgrading it. We did not do unit testing  
early on

because of the lack of time. Now that some time has opened up, we're
considering unit testing. My question is. is it reasonable to  
start unit
testing at this point in time with the application mostly built?  
Besides
being really time-consuming, what are the pitfalls of starting  
unit testing

at this stage?

Thanks in advance,
~Philip


maybe a useless answer, but, no pitfalls - just do it - I'm always  
surprised
by my unit test results, its invaluable and it's never too late to  
start.


just think about the next years worth of bugs found by the client  
not being

there!


A question I have about unit testing. The point is to test individual  
"units"... correct? So, let's say I have this core class which creates  
instances of other classes. Well, if I only want test the core class,  
I don't want to instantiate the other classes... correct? Example:


class1 = new Class1 ($this);
$this->class2 = new Class2 ($this);
}
}

// CoreTest.php
require ('../PHPUnit/Framework.php');
require ('../includes/Core.php');

class CoreTest extends PHPUnit_Framework_TestCase {
protected function setUp () {
$this->core = new Core();
}
}
?>

So, here, Class1 and Class2 will be instantiated. However, I don't  
really care for them to be so that I can test all the methods in the  
core class. Is this a perfect example of how the original design of  
the core class is not conducive to implementing unit tests? Without  
rewriting the core class, is there a way to test this?


Thanks,
~Philip

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



Re: [PHP] Boolean Parameter to 3 Options?

2009-04-29 Thread Philip Thompson

On Apr 29, 2009, at 11:42 AM, Matt Neimeyer wrote:


I have a function that currently takes a boolean value as a parameter.
But now I want to expand it to 3 options...  So if I have...

function doFooBar($doFoo = false)
  {
  if($doFoo)
 { echo "Did Foo"; }
  else
 { echo "Did Bar"; }
  }

Is it as "simple" as changing it like follows to avoid having to
change existing code that won't use the new values.

function doFooBar($doFoo = 0)
  {
  if($doFoo == 2)
 { echo "Did Baz"; }
  else if($doFoo == 1)
 { echo "Did Foo"; }
  else
 { echo "Did Bar"; }
  }

Something about that disturbs me. Perhaps because any time I think "Oh
it will be as simple as..." it usually isn't.

Thanks in advance!

Matt


Unless you're doing a strict comparison (===), it probably won't make  
a lot of difference. However, if you sent "true" to the function, I  
believe it will reach the last else condition. You may revisit all the  
locations you call it and update them appropriately.


Those are my initial thoughts

~Philip


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



Re: [PHP] Re: XSS Preventing.

2009-06-23 Thread Philip Thompson

On Jun 23, 2009, at 9:29 AM, Martin Zvarík wrote:


Don't htmlentiies() before DB save.  In general:
- mysql_real_escape_string() before DB insertion
- htmlentities() before dispaly



I, on the other hand, would do htmlentities() BEFORE insertion.


Pros:
---
The text is processed once and doesn't have to be htmlentitied()  
everytime you read the database - what a stupid waste of performance  
anyway.



Cons:
---
Instead "&" you'll see "&" ... is that a problem? Not for me and  
I believe 80% of others who use DB to store & view on web.


I had a problem with storing & into the database instead of just  
&. When I wanted to search for something and "&" was in the value,  
typing "&" would not find the result. I fixed that by not using  
htmlentities() before inputing data into the database. IMO, using  
htmlentities() or htmlspecialchars() before inserting into db is  
inherently wrong. Making calls to those functions should have  
negligible impact on the application - there are other ways to improve  
the performance of your application.


My too scents,
~Philip



Martin


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



[PHP] Sockets (reading)

2009-08-26 Thread Philip Thompson

Hi.

During a socket read, why would all the requested number of bytes not  
get sent? For example, I request 1000 bytes:




This is actually in a loop, so I can get all the data if split up. So,  
for example, here's how the data split up in 3 iterations (for 1000  
bytes):


650 bytes
200 bytes
150 bytes

But if I can accept up to 2048 bytes per socket read, why would it not  
pull all 1000 bytes initially in 1 step? Any thoughts on this would be  
greatly appreciated!


Thanks,
~Philip

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



Re: [PHP] Sockets (reading)

2009-08-26 Thread Philip Thompson

On Aug 26, 2009, at 11:56 AM, Bob McConnell wrote:


From: Philip Thompson


During a socket read, why would all the requested number of bytes not
get sent? For example, I request 1000 bytes:



This is actually in a loop, so I can get all the data if split up.  
So,

for example, here's how the data split up in 3 iterations (for 1000
bytes):

650 bytes
200 bytes
150 bytes

But if I can accept up to 2048 bytes per socket read, why would it  
not
pull all 1000 bytes initially in 1 step? Any thoughts on this would  
be

greatly appreciated!


Because that's the way TCP/IP works, by design. TCP is a stream
protocol. It guarantees all of the bytes written to one end of the  
pipe

will come out the other end in the same order, but not necessarily in
the same groupings. There are a number of buffers along the way that
might split them up, as well as limits on packet sizes in the various
networks it passed through. So you get what is available in the last
buffer when a timer expires, no more, and no less.

If you have serialized data that needs to be grouped in specific  
blocks,

your application will need to keep track of those blocks, reassembling
or splitting the streamed data as necessary. You could use UDP which
does guarantee that packets will be kept together, but that protocol
doesn't guarantee delivery.

Bob McConnell


Thank you for your input.

Is it guaranteed that at least 1 byte will be sent each time? For  
example, if I know the data length...


if (($data = @socket_read ($socket, 1, PHP_BINARY_READ)) !==  
false) {

$input .= $data;
}
}

return $input;
?>

Or is this a completely unreasonable and unnecessary way to get the  
data?


Thanks,
~Philip

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



Re: [PHP] Sockets (reading)

2009-08-26 Thread Philip Thompson

On Aug 26, 2009, at 2:47 PM, Bob McConnell wrote:


From: Philip Thompson

On Aug 26, 2009, at 11:56 AM, Bob McConnell wrote:

From: Philip Thompson


During a socket read, why would all the requested number of bytes

not

get sent? For example, I request 1000 bytes:



This is actually in a loop, so I can get all the data if split up.
So,
for example, here's how the data split up in 3 iterations (for 1000
bytes):

650 bytes
200 bytes
150 bytes

But if I can accept up to 2048 bytes per socket read, why would it
not
pull all 1000 bytes initially in 1 step? Any thoughts on this would



be
greatly appreciated!


Because that's the way TCP/IP works, by design. TCP is a stream
protocol. It guarantees all of the bytes written to one end of the
pipe
will come out the other end in the same order, but not necessarily  
in

the same groupings. There are a number of buffers along the way that
might split them up, as well as limits on packet sizes in the  
various

networks it passed through. So you get what is available in the last
buffer when a timer expires, no more, and no less.

If you have serialized data that needs to be grouped in specific
blocks,
your application will need to keep track of those blocks,

reassembling

or splitting the streamed data as necessary. You could use UDP which
does guarantee that packets will be kept together, but that protocol
doesn't guarantee delivery.


Thank you for your input.

Is it guaranteed that at least 1 byte will be sent each time? For
example, if I know the data length...



Or is this a completely unreasonable and unnecessary way to get the
data?


While I have written a lot of code to manage sockets over the years,  
and
coded a UDP/IP stack, I have never done it in PHP. And  
unfortunately, I
don't have time to experiment right now. My boss is waiting for the  
next

product release from me.

Getting one byte at a time is somewhat wasteful, as it requires more
system calls than necessary. That's a lot of wasted overhead.

Whether you always get one or more bytes depends on a number of  
factors,
including whether the calls PHP uses are blocking or non-blocking,  
plus

there may be ways to switch the socket back and forth.

Have you tried doing a Google search on the group of PHP functions you
expect to use. That should come up with some sample code to look at.

Bob McConnell


I agree that one byte at a time is wasteful. I'm sure others haven't  
implemented something along these lines, but I wrote a much more  
efficient way to make sure I grab all the data of a known length...


if (($data = @socket_read ($socket, $len - $offset,  
PHP_BINARY_READ)) === false) {

return false;
}

$offset += strlen ($data);
$socketData .= $data;
}

return $socketData;
}
?>

If not all the data is obtained on a read, it will loop until the  
amount of data is the same as the length requested. This is working  
quite well.


Thanks Bob and the others!

~Philip

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



[PHP] IE, Word documents and Content Types

2007-01-03 Thread Philip Thompson

Hi.

I have a form where a user can upload different types of documents. A  
valid file type they will be able to upload is a Word Document.  
However, when I view the $_FILES 'type' of a word document in Internet  
Explorer, it says it's type 'application/octet-stream' instead of  
'application/msword' or 'application/vnd.ms-word'. It works fine in  
Firefox and Safari.


Any ideas why IE does this and/or how I might be able to get around  
this? I know of 1 or 2 options for sort of bypassing this, but I'd  
like to hear from the group to see if there's a better,  
security-conscious idea.


Thanks in advance,
~Philip

+--+
  When you least expect it...
  expect it!
+--+

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



[PHP] mssql_* overhead

2007-01-10 Thread Philip Thompson

Hi.

Does anyone know if the mssql_connect/_init/_bind/etc require a lot  
of overhead?


I have a page that requires multiple function calls and each of those  
opens a new connection to the database, performs the necessary  
actions in stored procedure(s), and then closes the connection.  
However, I found this to be slower than I was wanting. So I thought,  
just create one connection and assign it to the SESSION (a global),  
and in each function that requires a connection, call that SESSION  
variable. At the end of the page, close the connection and nullify  
the variable.


Does anyone see a problem with doing it this way? Security concerns?  
Anything?


Thanks in advance,
~Philip

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



Re: [PHP] mssql_* overhead

2007-01-10 Thread Philip Thompson

On Jan 10, 2007, at 10:09 AM, Jochem Maas wrote:


Philip Thompson wrote:

Hi.

Does anyone know if the mssql_connect/_init/_bind/etc require a  
lot of

overhead?

I have a page that requires multiple function calls and each of those
opens a new connection to the database, performs the necessary  
actions
in stored procedure(s), and then closes the connection. However, I  
found

this to be slower than I was wanting. So I thought, just create one
connection and assign it to the SESSION (a global), and in each  
function

that requires a connection, call that SESSION variable. At the end of
the page, close the connection and nullify the variable.


I wouldn't stick it in the SESSION superglobal (my tactic is  
usually to create
a little wrapper class to the relevant DB functions and store the  
connection

as a property of the class/object.

basically opening & closing the connection once per request is the  
way to
go - if your going to using a global, better [than $_SESSION] to  
stick it

in $GLOBALS imho.


Would there be any speed decrease with multiple users (hundreds)  
sharing this $GLOBALS variable (if that makes sense)?



$_SESSION is used for persisting data over multiple requests -  
something that
is not possible to do for 'resource identifiers' (which is what the  
connection [id] is).


BTW, it does work b/c that's how it's currently setup. I am open to  
changing it though. I should say, I'm creating at the beginning of  
the script and closing it at the end. So, it doesn't actually stay  
open throughout the whole user session.




Does anyone see a problem with doing it this way? Security concerns?
Anything?

Thanks in advance,
~Philip


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



Re: [PHP] mssql_* overhead

2007-01-10 Thread Philip Thompson
I just wanted to make sure that there is no speed decrease if I  
change from $_SESSION to $GLOBALS to hold my connection (even with  
lots of people). I guess that's my question?


Thanks,
~Philip


On Jan 10, 2007, at 11:01 AM, [EMAIL PROTECTED] wrote:

I thought the same thing as Jochem... that resources like database  
connections, couldn't be stored in $_SESSION. You say that's how  
you have (had?) it set up and it was working, but still sounds  
wrong to me.


As for connections.. definitely don't open a new connection every  
time you run a function, unless it's run so rarely that it makes it  
more efficient to open and close within the function.   If it's a  
function run many times, you're definitely going to see a  
performance hit.


Typical procedure (at least how I've seen it done and done it  
myself at a few different jobs) is to open the connection once and  
close it once.  Which sounds like what you're doing now.


So was your question answered?   Sounds like there's still some  
lingering questions or curiosities...


-TG

= = = Original message = = =

On Jan 10, 2007, at 10:09 AM, Jochem Maas wrote:


Philip Thompson wrote:

Hi.

Does anyone know if the mssql_connect/_init/_bind/etc require a
lot of
overhead?

I have a page that requires multiple function calls and each of  
those

opens a new connection to the database, performs the necessary
actions
in stored procedure(s), and then closes the connection. However, I
found
this to be slower than I was wanting. So I thought, just create one
connection and assign it to the SESSION (a global), and in each
function
that requires a connection, call that SESSION variable. At the  
end of

the page, close the connection and nullify the variable.


I wouldn't stick it in the SESSION superglobal (my tactic is
usually to create
a little wrapper class to the relevant DB functions and store the
connection
as a property of the class/object.

basically opening & closing the connection once per request is the
way to
go - if your going to using a global, better [than $_SESSION] to
stick it
in $GLOBALS imho.


Would there be any speed decrease with multiple users (hundreds)
sharing this $GLOBALS variable (if that makes sense)?



$_SESSION is used for persisting data over multiple requests -
something that
is not possible to do for 'resource identifiers' (which is what the
connection [id] is).


BTW, it does work b/c that's how it's currently setup. I am open to
changing it though. I should say, I'm creating at the beginning of
the script and closing it at the end. So, it doesn't actually stay
open throughout the whole user session.



Does anyone see a problem with doing it this way? Security concerns?
Anything?

Thanks in advance,
~Philip


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



Re: [PHP] mssql_* overhead

2007-01-10 Thread Philip Thompson
Ok, just kidding. Thank you Jim and Jochem. You answered my question  
in your previous posts!


Thanks to all!
~Phil


On Jan 10, 2007, at 11:27 AM, Philip Thompson wrote:

I just wanted to make sure that there is no speed decrease if I  
change from $_SESSION to $GLOBALS to hold my connection (even with  
lots of people). I guess that's my question?


Thanks,
~Philip


On Jan 10, 2007, at 11:01 AM, [EMAIL PROTECTED] wrote:

I thought the same thing as Jochem... that resources like database  
connections, couldn't be stored in $_SESSION. You say that's how  
you have (had?) it set up and it was working, but still sounds  
wrong to me.


As for connections.. definitely don't open a new connection every  
time you run a function, unless it's run so rarely that it makes  
it more efficient to open and close within the function.   If it's  
a function run many times, you're definitely going to see a  
performance hit.


Typical procedure (at least how I've seen it done and done it  
myself at a few different jobs) is to open the connection once and  
close it once.  Which sounds like what you're doing now.


So was your question answered?   Sounds like there's still some  
lingering questions or curiosities...


-TG

= = = Original message = = =

On Jan 10, 2007, at 10:09 AM, Jochem Maas wrote:


Philip Thompson wrote:

Hi.

Does anyone know if the mssql_connect/_init/_bind/etc require a
lot of
overhead?

I have a page that requires multiple function calls and each of  
those

opens a new connection to the database, performs the necessary
actions
in stored procedure(s), and then closes the connection. However, I
found
this to be slower than I was wanting. So I thought, just create one
connection and assign it to the SESSION (a global), and in each
function
that requires a connection, call that SESSION variable. At the  
end of

the page, close the connection and nullify the variable.


I wouldn't stick it in the SESSION superglobal (my tactic is
usually to create
a little wrapper class to the relevant DB functions and store the
connection
as a property of the class/object.

basically opening & closing the connection once per request is the
way to
go - if your going to using a global, better [than $_SESSION] to
stick it
in $GLOBALS imho.


Would there be any speed decrease with multiple users (hundreds)
sharing this $GLOBALS variable (if that makes sense)?



$_SESSION is used for persisting data over multiple requests -
something that
is not possible to do for 'resource identifiers' (which is what the
connection [id] is).


BTW, it does work b/c that's how it's currently setup. I am open to
changing it though. I should say, I'm creating at the beginning of
the script and closing it at the end. So, it doesn't actually stay
open throughout the whole user session.


Does anyone see a problem with doing it this way? Security  
concerns?

Anything?

Thanks in advance,
~Philip


--
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] Stored Procedure returns nothing on ROLLBACK

2007-01-10 Thread Philip Thompson

Hi.

I have been experiencing MSSQL woes lately. I have a stored procedure  
that I call in PHP using mssql_* functions. In my procedure, I have a  
transaction that rolls back on failure and commits on success (of  
course). If it commits, I get the proper return value (int) and the  
appropriate output parameters. However, if it rolls back, I get  
NOTHING... even if I try to return an error code (int) after the  
ROLLBACK TRANSACTION statement. The output parameter also does not  
get set upon rollback.


Is there a way to grab the error even in a rollback? or at least  
return something besides an empty string/int? I would like to know  
what error message to provide the user/admin.


SQL Server 2000, PHP 5.1.6, ntwdblib.dll version 8.00.194

Thanks in advance.
~Philip

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



Re: [PHP] Stored Procedure returns nothing on ROLLBACK

2007-01-11 Thread Philip Thompson

On Jan 10, 2007, at 6:36 PM, Chris wrote:


Philip Thompson wrote:

Hi.
I have been experiencing MSSQL woes lately. I have a stored  
procedure that I call in PHP using mssql_* functions. In my  
procedure, I have a transaction that rolls back on failure and  
commits on success (of course). If it commits, I get the proper  
return value (int) and the appropriate output parameters. However,  
if it rolls back, I get NOTHING... even if I try to return an  
error code (int) after the ROLLBACK TRANSACTION statement. The  
output parameter also does not get set upon rollback.
Is there a way to grab the error even in a rollback? or at least  
return something besides an empty string/int? I would like to know  
what error message to provide the user/admin.

SQL Server 2000, PHP 5.1.6, ntwdblib.dll version 8.00.194


Does it work outside of php? That is - you run it manually in mssql  
(whatever tools that has) you get the proper codes?



Yes, it works perfectly from the server and returns the expected  
outcome. It's as though PHP sees the 'rollback' and automatically  
assumes that the whole thing failed... so why return a value or  
output parameters. Weird, I know. Any other suggestions?


Thanks,
~Philip

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



Re: [PHP] Stored Procedure returns nothing on ROLLBACK

2007-01-12 Thread Philip Thompson

On Jan 11, 2007, at 5:53 PM, Chris wrote:


Philip Thompson wrote:

On Jan 10, 2007, at 6:36 PM, Chris wrote:

Philip Thompson wrote:

Hi.
I have been experiencing MSSQL woes lately. I have a stored  
procedure that I call in PHP using mssql_* functions. In my  
procedure, I have a transaction that rolls back on failure and  
commits on success (of course). If it commits, I get the proper  
return value (int) and the appropriate output parameters.  
However, if it rolls back, I get NOTHING... even if I try to  
return an error code (int) after the ROLLBACK TRANSACTION  
statement. The output parameter also does not get set upon  
rollback.
Is there a way to grab the error even in a rollback? or at least  
return something besides an empty string/int? I would like to  
know what error message to provide the user/admin.

SQL Server 2000, PHP 5.1.6, ntwdblib.dll version 8.00.194


Does it work outside of php? That is - you run it manually in  
mssql (whatever tools that has) you get the proper codes?
Yes, it works perfectly from the server and returns the expected  
outcome. It's as though PHP sees the 'rollback' and automatically  
assumes that the whole thing failed... so why return a value or  
output parameters. Weird, I know. Any other suggestions?


Can you show us the part of the code that deals with the rollback?

If you are issuing a rollback yourself:

$result = mssql_query("rollback transaction");

then you need to handle that yourself because that's treated as a  
separate query.


If you're not doing that (the transaction is rolling itself back),  
then I'm out of ideas :)



I'm calling a stored procedure, not running the query from my code.  
So yes, I have a statement in my procedure that has ROLLBACK  
TRANSACTION. It's just odd because I know it works as a script on the  
server, but PHP doesn't recognize it properly, IMHO. I would almost  
be so presumptuous to say that it's a bug. But before I go that  
direction, I wanted to see if anyone had a similar experience. If  
not, I'll go ahead  and think about reporting a bug.


Thanks,
~Phil

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



Re: [PHP] Help wtih a query?

2007-01-30 Thread Philip Thompson

On Jan 30, 2007, at 4:33 PM, Skip Evans wrote:


Hey all,

I have the following query:

   $sql="SELECT count(*) AS  
count,votes.storyID,stories.title,stories.storyID as  
sID,stories.approved, stories.story,stories.userID, fname, lname
   FROM `bsp_story_votes` as votes, bsp_story_stories  
AS stories, users AS usr
   WHERE votes.storyID=stories.storyID AND  
stories.userID=usr.id AND stories.contestID=$contestID

   GROUP BY votes.storyID
   ORDER BY stories.approved,count DESC, sID ASC LIMIT  
$b_recno,$recs";


How would this need to be changed so that it would return rows for  
the members of the bsp_story_stories table that do not have records  
in the bsp_story_votes table?


Is that what the left/right joins do???

Thanks!
Skip



This may be closer to what you're wanting...


SELECT count(stories.*) AS count, votes.storyID, stories.title,  
stories.storyID AS sID, stories.approved, stories.story,  
stories.userID, fname, lname


FROM bsp_story_votes AS votes LEFT JOIN (bsp_story_stories AS stories  
ON votes.storyID = stories.storyID) INNER JOIN users AS usr ON  
stories.userID = usr.id


WHERE stories.contestID=$contestID

GROUP BY votes.storyID

ORDER BY stories.approved, count DESC, sID ASC LIMIT $b_recno, $recs


If that doesn't work, you may try changing the LEFT to RIGHT. I  
probably screwed it up, but that's closer to how JOINs work. I'm not  
sure if the GROUP BY will work with this query either??? I thought  
you had to use HAVING with a GROUP BY? Refer to the M*SQL manual.


Now that think about it... I don't know if you can have a 'count()'  
in with that query. If it doesn't work, you may try pulling count()  
out and just using m*sql_num_rows() afterwards to get the count. Hope  
that helps!


~Philip

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



Re: [PHP] Redirecting in a PHP script

2007-03-13 Thread Philip Thompson
As other people have already said, use the header() function.  
However, be sure to include exit; after you call it. I've run into  
problems where it did not redirect properly if I didn't have the exit  
call. This also prevents anymore of the page loading (and maybe  
providing sensitive information that you don't want others to see).


Also use output buffering if you have already displayed HTML. So, an  
example page:


--


Hi

  Hi

...


--

~Philip


On Mar 12, 2007, at 3:02 PM, Larry Bradley wrote:

I need to "goto"  different PHP pages in my web site depending on  
what happens within some PHP code.


For example, if the user is not logged in when he goes to a page, I  
want to send him to a LOGIN page.


I've have everything working fine, using the following Javascript  
code:

$location = 'login.php';
echo "\n";
echo "document.location.href = '" . $location . "'; \n";
echo "\n";

I also played around with using the header("location: ...") function.

I understand that the header() function must be issued before any  
HMTL is output.


But I'm not sure about the Javascript code. In every instance in my  
code, I use the Javascript before any HTML - this type of action  
normally occurs in PHP code called via a form POST.


I presume that the Javascript code really does the same as the PHP  
stuff, and thus must obey the same rules, but I'm not sure.

Comments?

Larry Bradley
Orleans (Ottawa), Ontario, CANADA


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



Re: [PHP] Getting last record ID created from DB

2007-03-16 Thread Philip Thompson

On Mar 16, 2007, at 10:28 PM, Jeff wrote:


Is there a way to get the last Record # created by the DB.

Example:

User_ID = auto_increment
f_name = varchar
l_name = varchar
e-mail = varchar
b_date = varchar
pic = varchar


Since user_id is an auto_inc field I submit it as a NULL, also I  
haven't
started the code for a picture yet either so I have it set to NULL  
at this

moment.
My code is:

$query = "INSERT INTO `t_users` (`user_id`, `f_name`, `l_name`,  
`e_mail`,
`b_date`, `pic`) VALUES ('', '$f_name', '$l_name', '$e_mail',  
'$b_date',

'')";
$result = mysql_query($query);
if(!$result)
{
die("Could not query the database: ".mysql_error());
}
echo "Your Player information has been stored OK.";

what code could I add here to make the following line work?

echo "REMEMBER your USER ID# you will need it when creating  
Characters!! It

is: $user_id"; <- I want to show the "user_id" just created here.

Thanks in advance!



For auto increment values, you don't have to specify the id. For  
example:


INSERT INTO t_users (f_name, l_name, e_mail, b_date, pic)
VALUES ('$f_name', '$l_name', '$e_mail', '$b_date', null);

Then to find the latest entry:

SELECT user_id FROM t_users ORDER BY user_id DESC limit 1;

Hope that helps.

~Philip

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



[PHP] Displaying files from database

2007-03-28 Thread Philip Thompson
Hi. I'm storing an uploaded file into a MySQL database. I want the  
file to then be downloaded and viewed. Uploading looks like:



if (is_uploaded_file($file) && $filename) {
  $handle = fopen ($file, 'r');
  $resume["data"] = base64_encode (fread ($handle, filesize ($file)));
  fclose($handle);

  $resume["type"] = $_FILES['resume']['type'];
  $resume["size"] = $_FILES['resume']['size'];
}


It loads into the database fine. If it's a word document, it merely  
spits out plain text. If it's a PDF, it says it can't open it.  
Downloading looks like:



$app = applications ($_GET["id"]);

header ("Status: 200 OK");
header ("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header ("Content-Length: ".$app["size"][0]);
header ("Content-Type: ".$app["type"][0]);
header ("Content-Disposition: attachment; filename=Resume-".$app 
["full"][0]);


echo $app["resume"][0];
exit;


What am I doing wrong?!! =D Thanks in advance.

~Philip

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



Re: [PHP] Displaying files from database

2007-03-28 Thread Philip Thompson

On Mar 28, 2007, at 12:59 PM, Tijnema ! wrote:


On 3/28/07, Philip Thompson <[EMAIL PROTECTED]> wrote:

Hi. I'm storing an uploaded file into a MySQL database. I want the
file to then be downloaded and viewed. Uploading looks like:


if (is_uploaded_file($file) && $filename) {
  $handle = fopen ($file, 'r');
  $resume["data"] = base64_encode (fread ($handle, filesize  
($file)));

  fclose($handle);

  $resume["type"] = $_FILES['resume']['type'];
  $resume["size"] = $_FILES['resume']['size'];
}


It loads into the database fine. If it's a word document, it merely
spits out plain text. If it's a PDF, it says it can't open it.
Downloading looks like:


$app = applications ($_GET["id"]);

header ("Status: 200 OK");
header ("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header ("Content-Length: ".$app["size"][0]);
header ("Content-Type: ".$app["type"][0]);
header ("Content-Disposition: attachment; filename=Resume-".$app
["full"][0]);

echo $app["resume"][0];
exit;


What am I doing wrong?!! =D Thanks in advance.

~Philip


You base64_encode your file when reading, you should also  
base64_decode i think.

so:
echo base64_decode($app["resume"][0]);

And you get $app from $_GET, and later use it as an array. I hope you
did some database actions between :)

Tijnema


Yup, that was it - I needed to add the decode... of course the  
obvious. It works! And yes, I prevent SQL injection and other stuff -  
that's just not shown here. Thanks for the advice! =D


~Philip

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



Re: [PHP] Displaying files from database

2007-03-28 Thread Philip Thompson

On Mar 28, 2007, at 1:36 PM, Richard Davey wrote:


Philip Thompson wrote:

Hi. I'm storing an uploaded file into a MySQL database. I want the  
file to then be downloaded and viewed. Uploading looks like:


Assuming you actually have a good reason *why* you are storing  
uploaded files in your database, how has the table been set-up?  
What is the table type and the column you are storing this file in?  
Is PHP set to automatically magic quote the data on insert? If so,  
you're in for a world of pain, so disable it.


Storing in the database to keep the data all together. Don't want to  
deal with storing it elsewhere and keeping up with it. It's a first  
for me to do it this way. The column is type LONGBLOB.




if (is_uploaded_file($file) && $filename) {
  $handle = fopen ($file, 'r');


You should always fopen with 'rb' for binary safe, system-portable  
handling.


I actually had it that way. When I gave the example, I had tested it  
both ways to see if that was where the problem was occurring. It's  
back to 'rb'.




Downloading looks like:

$app = applications ($_GET["id"]);
header ("Status: 200 OK");
header ("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header ("Content-Length: ".$app["size"][0]);
header ("Content-Type: ".$app["type"][0]);
header ("Content-Disposition: attachment; filename=Resume-".$app 
["full"][0]);

echo $app["resume"][0];
exit;

What am I doing wrong?!! =D Thanks in advance.


What are the size of these files? First of all, you need to base  
DECODE your data before sending to the client. Secondly, check if  
SQL is automatically escaping the data, which will cause you no end  
of trouble.


Third, if your files are larger than the maximum amount of memory a  
single PHP script can use on your server, your way of doing this  
will fail, because you are echoing out the data.


I limit the upload size, so I know that it *should* never reach the  
limit.



Actually storing the files as files, and then using passthru() to  
send them to the browser avoids this limitation. As it stands, if  
there is a 4MB file, each call to your script for it will use 4MB  
of memory minimum, so I hope you've got a dogs-bollocks server  
there, or a pitifully low traffic site ;)


Cheers,

Rich



~Philip

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



Re: [PHP] Question about form submitting

2007-04-03 Thread Philip Thompson

On Apr 3, 2007, at 1:13 PM, Mário Gamito wrote:


Hi,

Sorry for the lame question, but i didn't find a satisfactory  
answer in

the web.

I have this subscribe form (subscribe.php) and on submit i have to  
check

for errors:

a) password and password confirmation mismatch;
b) missing filled fields
c) check e-mail validity
d) etc.

My question is how do i make all these possibilities show a different
error message without leaving subscribe.php ?

I know that the for action must be subscribe.php, from there i'm blind
as a bat.

Any help would be appreciated.

Warm Regards
--
:wq! Mário Gamito


-
   urlencode($_POST['field2'])."&field3=".urlencode($_POST 
['field3']);


header ("location: subscribe.php?error=someError$list");
exit;
  }

} else if ($_GET['error']) {
  // SESSION
  $field1 = $_SESSION['field1'];
  $field2 = $_SESSION['field2'];
  $field3 = $_SESSION['field3'];

  // GET
  $field1 = urldecode($_GET['field1']);
  $field2 = urldecode($_GET['field2']);
  $field3 = urldecode($_GET['field3']);
}
?>

...
  
  Field 1: 


  Field 2: 


  Field 3: 


  ...
  
...

// Be sure to destroy the error fields so that they don't show up  
next submit

unset ($_SESSION['error']);
?>
-

That's one way to specify an error for each field. It's tedious, but  
forms are. Hope that helps.


~Philip

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



Re: [PHP] PHP editor

2007-04-11 Thread Philip Thompson

On Apr 11, 2007, at 9:17 AM, Jochem Maas wrote:


Jonathan Kahan wrote:

Hi all,

I beleive this is in the realm of php (I have learned my lesson from
last time). Does anyone have recomendation for any free (I.E.
permanently free not 30 day trial) of a good php editor. The ones  
i am

seeing all only allow usage for a limited time.


STFA, STFW, notepad, textpad, whateverpad.

look what I find after googling for 5 seconds:
http://www.php-editors.com/review/

*you* have to decide if you like an editor, nobody else can do it  
for you.


this topic comes almost weekly and it's rather boring - go search
and find *lots* of totally abitrary, rose-tinted opinions about what
the best freaking editor is.


Obviously some people think this is NOT "in the realm of php."  
Nonetheless, I think it's a relevant question and others have  
answered it well. It's up to you to decide which suits you best...  
and Google, can probably help you with that.


For Mac (my main platform), I use TextMate, but it's not free.
For PC, I use Crimson Editor, and it is free.

Hope that helps.

~Philip



Kind Regards
Jonathan Kahan

Systems Developer
Estrin Technologies, inc.
1375 Broadway, 3rd Floor, New York, NY, 10018

Email: [EMAIL PROTECTED]
Web: http://www.estrintech.com


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



Re: [PHP] PHP editor

2007-04-13 Thread Philip Thompson

On Apr 13, 2007, at 10:26 AM, Jay Blanchard wrote:


[snip]
Just showing my ignorance, probably,
but what exactly is meant by a "PHP editor"?

Does it mean an editor for editing PHP scripts,
or an editor written in PHP?
[/snip]

Something to edit PHP with...unless you're trying to be funny



LOL! I don't know why this was so funny, but I laughed at Jay's  
comment (I can just see the light bulb turn on). Nonetheless, this  
"ignorant" user brings up a thought - are there any editors written  
in PHP?


~Philip

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



Re: [PHP] Json.php

2007-04-16 Thread Philip Thompson

On Apr 16, 2007, at 4:40 AM, Jochem Maas wrote:


Otto Wyss wrote:

Tijnema ! wrote:


*ROFLMFAO*...Did you actually try google for json.php?
Second result:
http://mike.teczno.com/JSON/JSON.phps


This doesn't have a json_encode but needs a $json object which then
could be used as $json->encode(...). Thanks anyway.


that's going to make it completely impossible to use then isn't it.
no way you could possibly wrap the class/objects functionality in a  
wrapper

function.

if (!function_exists('json_encode')) {
function json_encode($data) {
$json = new JSON; // or whatever the class is called.
return $json->encode($data);
}
}

omg that was hard.


Can't you just feel the love in the room? That's the kind of support  
I like to see! =P


~PT

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



Re: [PHP] Re: header('Location:') works locally but not remotely

2007-04-16 Thread Philip Thompson

On Apr 16, 2007, at 12:44 PM, Ross wrote:

ok I have a page that calls my my functions, basically a 6 step  
signup. All

the steps look like this

function step_one() {

$_SESSION['property_id'] =$_POST['property_id'];
$property_id = $_POST['property_id'];
$postcode= $_POST['postcode'];


Escape your data:
$property_id = mysql_real_escape_string($_POST['property_id']);
$postcode = mysql_real_escape_string($_POST['postcode']);



$query = "INSERT INTO properties (property_id, postcode) VALUES
('$property_id', '$postcode')";
$result= mysql_query($query);
header( 'Location: ?step=two' );


As others have mentioned, you must include at least the relative path.

header ("Location: add_new.php?step=two");
exit;

Always include 'exit;' after a redirect. Happy coding...

~Philip



}

This SHOULD redirect to

add_new.php?step=two

As add_new is the container page.

Thanks.

R.


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



Re: [PHP] WWE in Stamford, CT needs a kick ass PHP Developer!

2007-04-17 Thread Philip Thompson
I'm not looking for a response... but this thread that opened up  
several days ago would now considered to be OT. Maybe take it  
offline? :)


The ironic thing... when I put [OT] in the subject line, the list  
rejected it. This is the 2nd attempt. So, the moral is to talk about  
whatever the hell you want and just don't say it's off topic.



On Apr 17, 2007, at 9:28 AM, Tim wrote:


-Message d'origine-
De : Jochem Maas [mailto:[EMAIL PROTECTED]
Envoyé : mardi 17 avril 2007 16:19
À : [EMAIL PROTECTED]
Cc : Robert Cummings; Tim; 'Jarrel Cobb'; 'tedd';
php-general@lists.php.net
Objet : Re: [PHP] WWE in Stamford, CT needs a kick ass PHP Developer!

Richard Lynch wrote:

On Fri, April 13, 2007 8:14 pm, Robert Cummings wrote:

peacepipe in one hand, broadsword in the other - lets hack on :-)

***BIG SMILE***

And WHAT are you smiling at??? Staves beat peacepipes and

broadswords

anyday!


Maybe he's smiling because of what's IN his peacepipe... :-)

Does this shock you?


That was my assumption when I first read it...

But maybe I've just hung out with too many stoner musicians... :-v



Just musicians? ;P





... huh?


... what?


... do somebody say something?

;-)


I didn't think you could fit peacepipe and broadsword in the same
sentence... I geuss so... :P


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



[PHP] PHP & Text Messaging

2007-04-19 Thread Philip Thompson
Hi. I have attempted to look at the archives for this, but keep  
getting redirected back to the main PHP site when I click on the  
archive link. With that said, does anyone know of any good resources  
for sending text messages using PHP? I have Googled this topic and  
found a few, but find it hard to judge which ones are "good." I have  
also looked at the SAM package, but wasn't sure how much that is  
being used by the community.


Thanks in advance,
~Philip

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



Re: [PHP] CSS vs. Tables OT

2007-04-19 Thread Philip Thompson

On Apr 19, 2007, at 9:08 AM, tedd wrote:


At 8:59 AM +1200 4/19/07, Bruce Cowin wrote:
Now can we please close this thread!  There are better forums to  
discuss

this - it has nothing to do with PHP!!

Lori


Lori:

True, it has nothing to do with php programming other than  
compliance, accessibility, data gathering and data presentation.


If php lived in a vacuum where computation was all there was, then  
that would not be a concern. However, we use other languages to  
grab our input and present our findings. IMO, to be "well rounded"  
we have to understand other languages such as html, xml, mysql,  
css, javascript and even ajax. These languages have both good and  
bad practices and carry with them responsibilities to our clients  
and adherence to standards and compliance issues. It's more than  
just pounding code.


I think it's good that we discuss these things because it brings  
about an understanding and appreciation of issues where our actions  
may have far reaching influence on important matters of which we  
may not be aware. Knowledge carries with it responsibility.


Cheers,

tedd


*CLAP CLAP CLAP*

=P

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



Re: [PHP] PHP & Text Messaging

2007-04-20 Thread Philip Thompson
Thanks to all who replied. I was unaware of being able to use the mail 
() function to send text messages. When hearing this, I looked up to  
find what all the major phone companies addresses were. I was able to  
compile this list - I've been unable to test each one of them, but  
I'm guessing they will work.



Alltel
AT&T
Cingularoption>

Nextel
Sprint PCS
T-Mobile
Verizon
Virgin Mobile


Because Cingular is very big in our area, this is the only one I've  
verified. Does anyone see if these values are wrong or know of some  
other major carriers?


Also, because Cingular and AT&T are combined (like Sprint and  
Nextel), would the Cingular selection work on an AT&T phone number?


If you care to test/view: http://thril.uark.edu/SMS/

Thanks,
~Philip


On Apr 20, 2007, at 7:59 AM, Wolf wrote:


What I found to work was @provider.whatever

The pain was just in finding out which provider used what sub- 
domain for their clients.


But it works for all of them that I have needed to send to.

HTH,
Wolf

Philip Thompson wrote:
Hi. I have attempted to look at the archives for this, but keep  
getting redirected back to the main PHP site when I click on the  
archive link. With that said, does anyone know of any good  
resources for sending text messages using PHP? I have Googled this  
topic and found a few, but find it hard to judge which ones are  
"good." I have also looked at the SAM package, but wasn't sure how  
much that is being used by the community.

Thanks in advance,
~Philip


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



Re: [PHP] ie6 "memory could not be read" help!

2009-09-17 Thread Philip Thompson

On Sep 17, 2009, at 4:04 AM, Ashley Sheridan wrote:


On Thu, 2009-09-17 at 16:41 +0800, Shelley wrote:

Hi all,

With IE6,

After the pages i developed was loaded, there seems to be no problem,
but when you then click a link, refresh the page, etc. it shows  
"memory

could not be 'read'" error message.

However, when you load other sites, google.com, for example, there  
is no

such problem.

Anybody knows how to fix this problem?

Any help is appreciated & thanks in advance.



http://support.microsoft.com/kb/899811

first result from a Google search

Thanks,
Ash


Since this post is not PHP-related, I'll continue the trend. Are  
people still using IE6? In sites I design, I prevent the user from  
viewing it. If they're still on IE6, I don't want them to use my sites.


Cheers,
~Philip

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



Re: [PHP] Extract links from strings

2009-09-23 Thread Philip Thompson

On Sep 21, 2009, at 6:20 PM, Jim Lucas wrote:


Jim Lucas wrote:

Jônatas Zechim wrote:

Hi there, i've the following strings:

$string1 = 'Lorem ipsum dolor http://site.com sit amet';
$string2 = 'Lorem ipsum dolor http://www.site.com/ sit amet';
$string3 = 'Lorem ipsum dolor http://www.site.net sit amet';

How can I extract the URL from these strings?
They can be [http:// + url] or [www. + url].

Zechim




Something like this should work for you.

http://site.com sit amet';
$urls[] = 'Lorem ipsum dolor https://www.site.com/ sit amet';
$urls[] = 'Lorem ipsum dolor www.site1.net sit amet';
$urls[] = 'Lorem ipsum dolor www site2.net sit amet';

foreach ( $urls AS $url ) {
if ( preg_match('%((https?://|www\.)[^\s]+)%', $url, $m) ) {
print_r($m);
}
}

?>



Actually, try this.  It seems to work a little better.

http://site.com sit amet';
$urls[] = 'Lorem ipsum dolor https://www.site.com/ or http://www.site2.com/' 
;

$urls[] = 'Lorem ipsum dolor www.site1.net sit amet';
$urls[] = 'Lorem ipsum dolor www site2.net sit amet';

foreach ( $urls AS $url ) {
if ( preg_match_all('%(https?://[^\s]+|www\.[^\s]+)%',
$url,
$m,
(PREG_SET_ORDER ^ PREG_OFFSET_CAPTURE)
) ) {
print_r($m);
}
}

?>


What if the sub domain was not 'www'?

http://no-www.org/

Cheers,
~Philip


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



Re: [PHP] NULLS vs Empty result in PHP

2009-09-23 Thread Philip Thompson

On Sep 23, 2009, at 9:48 AM, Dan Shirah wrote:



From reading the other responses to this thread, it seems that you  
want

to
"skip" or "exclude" rows in the results where my_column === null.

If this is correct, why not do it in the SELECT statement to begin  
with?


$my_query = "SELECT my_column FROM my_database WHERE my_column IS NOT
NULL";

That should do it.



I want to exclude the rows that might be NULL, "" (empty), or  
""

(empty series of spaces)

From all of the input so far, it seems that using trim() on the  
variable and

then use empty() is the best way to pick all three types up.


I don't think you're using mysql, but your selected db may have a  
similar option. I would do the work in the sql.


$sql = "SELECT * FROM `table` WHERE TRIM(`column`) <> '' AND `column`  
IS NOT NULL";

$result = query($sql);
while ($row = fetch_row ($result)) {
echo "Not empty, multiple spaces or NULL!";
}
?>

So, if you have any extraneous spaces, they will be removed. It also  
accounts for nulls. No work is required by PHP to determine the values  
you need. Just use what it returns. This should work.


Hope this helps.
~Philip


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



[PHP] Where's my memory going?!

2009-09-28 Thread Philip Thompson

Hi all.

I have a script that opens a socket, creates a persistent mysql  
connection, and loops to receive data. When the amount of specified  
data has been received, it calls a class which processes the data and  
inserts it into the database. Each iteration, I unset/destruct that  
class I call. However, the script keeps going up in memory and  
eventually runs out, causing a fatal error. Any thoughts on where to  
start to see where I'm losing my memory?


Thanks in advance,
~Philip

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



Re: [PHP] Where's my memory going?!

2009-09-28 Thread Philip Thompson

On Sep 28, 2009, at 4:18 PM, Jim Lucas wrote:


Philip Thompson wrote:

Hi all.

I have a script that opens a socket, creates a persistent mysql
connection, and loops to receive data. When the amount of specified  
data
has been received, it calls a class which processes the data and  
inserts

it into the database. Each iteration, I unset/destruct that class I
call. However, the script keeps going up in memory and eventually  
runs
out, causing a fatal error. Any thoughts on where to start to see  
where

I'm losing my memory?

Thanks in advance,
~Philip



We cannot tell you anything without see an example of what your  
script is doing.


Let us see some code!


I was wondering if you were gonna ask that! Umm... I don't know if I  
can show you the code b/c it's not as trivial as I explained it above.  
I'll tell you what, I give you something to chew on and you let me  
know if it's enough.


core = new coreFunctions (false, 'interface');
parent::__construct ($this->core, $host, $port, $clients);
$this->readFunction = 'processData';
$this->startPersistentListener();
}

public function processData ($data)
{
if ($this->filetype == 'demographics') {
$demoImporter = new Demographics ();
$ret = $demoImporter->importFromDataStream ($data);
$demoImporter->__destruct();
unset ($demoImporter);
echo "Memory usage: " . number_format (memory_get_usage  
()) . "\n";

return $ret;
}
}
}

class Socket
{
public function startPersistentListener ()
{
// Create a persistent listening socket connection
$this->create();
$this->setOption(SOL_SOCKET, SO_KEEPALIVE, 1);
$this->bind();
$this->listen();
$this->clients = array($this->sock);

while ($this->isAlive) {
// Create the list of connected clients
$this->createClients();

if ($this->select() < 1) {
// No clients - go to the next iteration
continue;
}

$this->accept();
$this->read();
}
}
}

set_time_limit (0);
new SocketListener ();
?>

I stripped out a lot of code, but this is the basics. I have a  
listener class that extends the socket class. When the socket class  
receives some data, it calls the processData() method - which creates  
a new instance of the Demographics class. It destroys the instance  
after it's finished. The line where I echo the memory usage indicates  
that the memory continues to grow until it just explodes.


There's a lot more going on behind the scenes that *could* cause the  
memory leak, but hopefully this will give you somewhere to go.


Thanks!
~Philip

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



Re: [PHP] Re: Where's my memory going?!

2009-09-28 Thread Philip Thompson

On Sep 28, 2009, at 4:27 PM, Ralph Deffke wrote:

well this sound clearly to me like you are not freeing resultsets  
you are not going to use anymore. In long scripts you have to take  
care of this. on short scripts you can be a bit weak on that,  
because the resultsets are closed and freed on script ending.


assumed u r using MySQL are u using mysql_free_result($result)

goog luck

ralph_def...@yahoo.de


"Philip Thompson"  wrote in message news:9c0b9c4c-5e64-4519-862b-8a3e1da4d...@gmail.com 
...

Hi all.

I have a script that opens a socket, creates a persistent mysql
connection, and loops to receive data. When the amount of specified
data has been received, it calls a class which processes the data and
inserts it into the database. Each iteration, I unset/destruct that
class I call. However, the script keeps going up in memory and
eventually runs out, causing a fatal error. Any thoughts on where to
start to see where I'm losing my memory?

Thanks in advance,
~Philip


I am not using mysql_free_result(). Is that highly recommended by all?

Thanks,
~Philip

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



Re: [PHP] Where's my memory going?!

2009-09-29 Thread Philip Thompson

On Sep 28, 2009, at 4:40 PM, jeff brown wrote:

Yes, that's the best way to clean up after yourself.  And you really  
should use that on anything you have sitting around daemon like.


Jeff

Philip Thompson wrote:

On Sep 28, 2009, at 4:27 PM, Ralph Deffke wrote:
well this sound clearly to me like you are not freeing resultsets  
you are not going to use anymore. In long scripts you have to take  
care of this. on short scripts you can be a bit weak on that,  
because the resultsets are closed and freed on script ending.


assumed u r using MySQL are u using mysql_free_result($result)

goog luck

ralph_def...@yahoo.de


"Philip Thompson"  wrote in message news:9c0b9c4c-5e64-4519-862b-8a3e1da4d...@gmail.com 
...

Hi all.

I have a script that opens a socket, creates a persistent mysql
connection, and loops to receive data. When the amount of specified
data has been received, it calls a class which processes the data  
and

inserts it into the database. Each iteration, I unset/destruct that
class I call. However, the script keeps going up in memory and
eventually runs out, causing a fatal error. Any thoughts on where  
to

start to see where I'm losing my memory?

Thanks in advance,
~Philip
I am not using mysql_free_result(). Is that highly recommended by  
all?

Thanks,
~Philip


I took your suggestions and made sure to clean up after myself. I'm  
running into something that *appears* to be a bug with  
mysql_free_result(). Here's a snippet of my db class.


echo "\nMemory usage before query: " . number_format  
(memory_get_usage ()) . "\n";

$resultSet = $this->query($sql);
echo "Memory usage after  query: " . number_format  
(memory_get_usage ()) . "\n";


if (!$assoc) { $result = $this->fetch_row($resultSet); }
else {
$result = $this->fetch_array($resultSet);
echo "Memory usage after  fetch: " . number_format  
(memory_get_usage ()) . "\n";

}

$this->freeResult($resultSet);
echo "Memory usage after   free: " . number_format  
(memory_get_usage ()) . "\n";


return $result;
}

function freeResult ($result)
{
if (is_resource ($result)) {
if (!mysql_free_result ($result)) { echo "Memory could  
not be freed\n"; }

}
unset ($result); // For good measure
}

function fetch_row ($set) {
return mysql_fetch_row ($set);
}

function fetch_array ($set) {
return mysql_fetch_array ($set, MYSQL_ASSOC);
}
}

// I seem to be losing memory when I call this
$db->fetch($sql);
?>

The result I get with this is...

Memory usage before query: 6,406,548
Memory usage after  query: 6,406,548
Memory usage after  fetch: 6,406,548
Memory usage after   free: 6,406,572

As you may notice, the memory actually goes UP after the *freeing* of  
memory. Why is this happening?! What have I done wrong? Is this a bug?  
Any thoughts would be appreciated.


Thanks,
~Philip


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



Re: [PHP] Where's my memory going?!

2009-09-29 Thread Philip Thompson

On Sep 29, 2009, at 3:07 PM, jeff brown wrote:


Philip Thompson wrote:

On Sep 28, 2009, at 4:40 PM, jeff brown wrote:
Yes, that's the best way to clean up after yourself.  And you  
really should use that on anything you have sitting around daemon  
like.


Jeff

Philip Thompson wrote:

On Sep 28, 2009, at 4:27 PM, Ralph Deffke wrote:
well this sound clearly to me like you are not freeing  
resultsets you are not going to use anymore. In long scripts you  
have to take care of this. on short scripts you can be a bit  
weak on that, because the resultsets are closed and freed on  
script ending.


assumed u r using MySQL are u using mysql_free_result($result)

goog luck

ralph_def...@yahoo.de


"Philip Thompson"  wrote in message news:9c0b9c4c-5e64-4519-862b-8a3e1da4d...@gmail.com 
...

Hi all.

I have a script that opens a socket, creates a persistent mysql
connection, and loops to receive data. When the amount of  
specified
data has been received, it calls a class which processes the  
data and
inserts it into the database. Each iteration, I unset/destruct  
that

class I call. However, the script keeps going up in memory and
eventually runs out, causing a fatal error. Any thoughts on  
where to

start to see where I'm losing my memory?

Thanks in advance,
~Philip
I am not using mysql_free_result(). Is that highly recommended by  
all?

Thanks,
~Philip
I took your suggestions and made sure to clean up after myself. I'm  
running into something that *appears* to be a bug with  
mysql_free_result(). Here's a snippet of my db class.

   echo "\nMemory usage before query: " . number_format  
(memory_get_usage ()) . "\n";

   $resultSet = $this->query($sql);
   echo "Memory usage after  query: " . number_format  
(memory_get_usage ()) . "\n";

   if (!$assoc) { $result = $this->fetch_row($resultSet); }
   else {
   $result = $this->fetch_array($resultSet);
   echo "Memory usage after  fetch: " . number_format  
(memory_get_usage ()) . "\n";

   }


/*


   $this->freeResult($resultSet);

*/
 mysql_free_result($resultSet);

   echo "Memory usage after   free: " . number_format  
(memory_get_usage ()) . "\n";

   return $result;
   }
   function freeResult ($result)
   {
   if (is_resource ($result)) {
   if (!mysql_free_result ($result)) { echo "Memory could  
not be freed\n"; }

   }
   unset ($result); // For good measure
   }
   function fetch_row ($set) {
   return mysql_fetch_row ($set);
   }
   function fetch_array ($set) {
   return mysql_fetch_array ($set, MYSQL_ASSOC);
   }
}
// I seem to be losing memory when I call this
$db->fetch($sql);
?>
The result I get with this is...
Memory usage before query: 6,406,548
Memory usage after  query: 6,406,548
Memory usage after  fetch: 6,406,548
Memory usage after   free: 6,406,572
As you may notice, the memory actually goes UP after the *freeing*  
of memory. Why is this happening?! What have I done wrong? Is this  
a bug? Any thoughts would be appreciated.

Thanks,
~Philip


try the above...

jeff


Unfortunately, the same result:

Memory usage before query: 6,524,676
Memory usage after  query: 6,524,676
Memory usage after  fetch: 6,524,676
Memory usage after   free: 6,524,700

Memory usage before query: 6,524,792
Memory usage after  query: 6,524,792
Memory usage after  fetch: 6,524,792
Memory usage after   free: 6,524,816

Memory usage before query: 6,524,932
Memory usage after  query: 6,524,932
Memory usage after  fetch: 6,524,932
Memory usage after   free: 6,524,956

Each iteration shows a 24 byte difference between fetching the array  
and freeing the result. Thoughts? This is baffling to me.


Thanks,
~Philip


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



Re: [PHP] Where's my memory going?!

2009-09-29 Thread Philip Thompson

On Sep 29, 2009, at 3:23 PM, Philip Thompson wrote:


On Sep 29, 2009, at 3:07 PM, jeff brown wrote:


Philip Thompson wrote:

On Sep 28, 2009, at 4:40 PM, jeff brown wrote:
Yes, that's the best way to clean up after yourself.  And you  
really should use that on anything you have sitting around daemon  
like.


Jeff

Philip Thompson wrote:

On Sep 28, 2009, at 4:27 PM, Ralph Deffke wrote:
well this sound clearly to me like you are not freeing  
resultsets you are not going to use anymore. In long scripts  
you have to take care of this. on short scripts you can be a  
bit weak on that, because the resultsets are closed and freed  
on script ending.


assumed u r using MySQL are u using mysql_free_result($result)

goog luck

ralph_def...@yahoo.de


"Philip Thompson"  wrote in message news:9c0b9c4c-5e64-4519-862b-8a3e1da4d...@gmail.com 
...

Hi all.

I have a script that opens a socket, creates a persistent mysql
connection, and loops to receive data. When the amount of  
specified
data has been received, it calls a class which processes the  
data and
inserts it into the database. Each iteration, I unset/destruct  
that

class I call. However, the script keeps going up in memory and
eventually runs out, causing a fatal error. Any thoughts on  
where to

start to see where I'm losing my memory?

Thanks in advance,
~Philip
I am not using mysql_free_result(). Is that highly recommended  
by all?

Thanks,
~Philip
I took your suggestions and made sure to clean up after myself.  
I'm running into something that *appears* to be a bug with  
mysql_free_result(). Here's a snippet of my db class.

  echo "\nMemory usage before query: " . number_format  
(memory_get_usage ()) . "\n";

  $resultSet = $this->query($sql);
  echo "Memory usage after  query: " . number_format  
(memory_get_usage ()) . "\n";

  if (!$assoc) { $result = $this->fetch_row($resultSet); }
  else {
  $result = $this->fetch_array($resultSet);
  echo "Memory usage after  fetch: " . number_format  
(memory_get_usage ()) . "\n";

  }


/*


  $this->freeResult($resultSet);

*/
mysql_free_result($resultSet);

  echo "Memory usage after   free: " . number_format  
(memory_get_usage ()) . "\n";

  return $result;
  }
  function freeResult ($result)
  {
  if (is_resource ($result)) {
  if (!mysql_free_result ($result)) { echo "Memory could  
not be freed\n"; }

  }
  unset ($result); // For good measure
  }
  function fetch_row ($set) {
  return mysql_fetch_row ($set);
  }
  function fetch_array ($set) {
  return mysql_fetch_array ($set, MYSQL_ASSOC);
  }
}
// I seem to be losing memory when I call this
$db->fetch($sql);
?>
The result I get with this is...
Memory usage before query: 6,406,548
Memory usage after  query: 6,406,548
Memory usage after  fetch: 6,406,548
Memory usage after   free: 6,406,572
As you may notice, the memory actually goes UP after the *freeing*  
of memory. Why is this happening?! What have I done wrong? Is this  
a bug? Any thoughts would be appreciated.

Thanks,
~Philip


try the above...

jeff


Unfortunately, the same result:

Memory usage before query: 6,524,676
Memory usage after  query: 6,524,676
Memory usage after  fetch: 6,524,676
Memory usage after   free: 6,524,700

Memory usage before query: 6,524,792
Memory usage after  query: 6,524,792
Memory usage after  fetch: 6,524,792
Memory usage after   free: 6,524,816

Memory usage before query: 6,524,932
Memory usage after  query: 6,524,932
Memory usage after  fetch: 6,524,932
Memory usage after   free: 6,524,956

Each iteration shows a 24 byte difference between fetching the array  
and freeing the result. Thoughts? This is baffling to me.


Thanks,
~Philip


I did a little searching and found this article:

http://www.ibm.com/developerworks/opensource/library/os-php-v521/

He gives the same example I do with mysql_free_result() not  
appropriately freeing the memory. He concludes with "we can assume  
that mysql_query() is allocating memory incorrectly." However, he  
never explains his thoughts on why or anything else. Thanks, Tracy.


So am I chasing a tangent? Should my focus be moved to mysql_query()  
instead? Thoughts?


Thanks,
~Philip

PS... Yes, this is giving me a headache.

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



Re: [PHP] Where's my memory going?!

2009-09-29 Thread Philip Thompson

On Sep 29, 2009, at 4:38 PM, Jim Lucas wrote:


Philip Thompson wrote:

On Sep 28, 2009, at 4:40 PM, jeff brown wrote:


Yes, that's the best way to clean up after yourself.  And you really
should use that on anything you have sitting around daemon like.

Jeff

Philip Thompson wrote:

On Sep 28, 2009, at 4:27 PM, Ralph Deffke wrote:

well this sound clearly to me like you are not freeing resultsets
you are not going to use anymore. In long scripts you have to take
care of this. on short scripts you can be a bit weak on that,
because the resultsets are closed and freed on script ending.

assumed u r using MySQL are u using mysql_free_result($result)

goog luck

ralph_def...@yahoo.de


"Philip Thompson"  wrote in message
news:9c0b9c4c-5e64-4519-862b-8a3e1da4d...@gmail.com...

Hi all.

I have a script that opens a socket, creates a persistent mysql
connection, and loops to receive data. When the amount of  
specified
data has been received, it calls a class which processes the  
data and
inserts it into the database. Each iteration, I unset/destruct  
that

class I call. However, the script keeps going up in memory and
eventually runs out, causing a fatal error. Any thoughts on  
where to

start to see where I'm losing my memory?

Thanks in advance,
~Philip
I am not using mysql_free_result(). Is that highly recommended by  
all?

Thanks,
~Philip


I took your suggestions and made sure to clean up after myself. I'm
running into something that *appears* to be a bug with
mysql_free_result(). Here's a snippet of my db class.

query($sql);
   echo "Memory usage after  query: " . number_format
(memory_get_usage ()) . "\n";

   if (!$assoc) { $result = $this->fetch_row($resultSet); }
   else {
   $result = $this->fetch_array($resultSet);
   echo "Memory usage after  fetch: " . number_format
(memory_get_usage ()) . "\n";
   }

   $this->freeResult($resultSet);
   echo "Memory usage after   free: " . number_format
(memory_get_usage ()) . "\n";

   return $result;
   }

   function freeResult ($result)
   {
   if (is_resource ($result)) {
   if (!mysql_free_result ($result)) { echo "Memory could not
be freed\n"; }
   }
   unset ($result); // For good measure
   }

   function fetch_row ($set) {
   return mysql_fetch_row ($set);
   }

   function fetch_array ($set) {
   return mysql_fetch_array ($set, MYSQL_ASSOC);
   }
}

// I seem to be losing memory when I call this
$db->fetch($sql);
?>

The result I get with this is...

Memory usage before query: 6,406,548
Memory usage after  query: 6,406,548
Memory usage after  fetch: 6,406,548
Memory usage after   free: 6,406,572

As you may notice, the memory actually goes UP after the *freeing* of
memory. Why is this happening?! What have I done wrong? Is this a  
bug?

Any thoughts would be appreciated.



First off, my question would be, is your query actually working?   
Because I
would imagine that if you were getting results back from the DB,  
that the amount

of memory being used would increase between step 1 & 2.

Check to make sure that you are getting results.


I'm confident the queries are working (there's many of them and I know  
the data they're returning is correct), but they may not always be  
returning results. The memory value does change in some instances...


Memory usage before query: 5,138,372
Memory usage after  query: 5,138,396
Memory usage after   free: 5,138,556

This was one that use fetch_row() instead of fetch_array(), but the  
same difference. I did some searching around and I think it's a bug in  
PHP and/or Zend Memory Management engine. As I mentioned in a previous  
post about mysql_query() not allocating memory appropriately, I  
believe this could quite possibly be the case. Several people have  
reported bugs similar to this... unfortunately, they are marked as  
(erroneously?) bogus or said it has been fixed (when, IMO, it has not).


http://bugs.php.net/bug.php?id=40883
http://bugs.php.net/bug.php?id=28424
http://bugs.php.net/bug.php?id=41871

I'm using version 5.2.6 on Fedora 8 and the bug still appears to be  
there. I think I'm going to take a different approach to fix this.  
I'll create a shell script to loop and invoke the socket listener  
script, and when it gathers data, call the import script. This way,  
the php script(s) will end execution after each iteration and release  
the memory. Is this reasonable?


This has been a long day. Thanks for your input. Any more thoughts are  
welcome.


~Philip

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



Re: [PHP] Where's my memory going?!

2009-09-30 Thread Philip Thompson

On Sep 29, 2009, at 5:51 PM, Jim Lucas wrote:


Philip Thompson wrote:

On Sep 29, 2009, at 4:38 PM, Jim Lucas wrote:


Philip Thompson wrote:

On Sep 28, 2009, at 4:40 PM, jeff brown wrote:

Yes, that's the best way to clean up after yourself.  And you  
really

should use that on anything you have sitting around daemon like.

Jeff

Philip Thompson wrote:

On Sep 28, 2009, at 4:27 PM, Ralph Deffke wrote:
well this sound clearly to me like you are not freeing  
resultsets
you are not going to use anymore. In long scripts you have to  
take

care of this. on short scripts you can be a bit weak on that,
because the resultsets are closed and freed on script ending.

assumed u r using MySQL are u using mysql_free_result($result)

goog luck

ralph_def...@yahoo.de


"Philip Thompson"  wrote in message
news:9c0b9c4c-5e64-4519-862b-8a3e1da4d...@gmail.com...

Hi all.

I have a script that opens a socket, creates a persistent mysql
connection, and loops to receive data. When the amount of  
specified
data has been received, it calls a class which processes the  
data

and
inserts it into the database. Each iteration, I unset/ 
destruct that

class I call. However, the script keeps going up in memory and
eventually runs out, causing a fatal error. Any thoughts on  
where to

start to see where I'm losing my memory?

Thanks in advance,
~Philip
I am not using mysql_free_result(). Is that highly recommended  
by all?

Thanks,
~Philip


I took your suggestions and made sure to clean up after myself. I'm
running into something that *appears* to be a bug with
mysql_free_result(). Here's a snippet of my db class.

query($sql);
  echo "Memory usage after  query: " . number_format
(memory_get_usage ()) . "\n";

  if (!$assoc) { $result = $this->fetch_row($resultSet); }
  else {
  $result = $this->fetch_array($resultSet);
  echo "Memory usage after  fetch: " . number_format
(memory_get_usage ()) . "\n";
  }

  $this->freeResult($resultSet);
  echo "Memory usage after   free: " . number_format
(memory_get_usage ()) . "\n";

  return $result;
  }

  function freeResult ($result)
  {
  if (is_resource ($result)) {
  if (!mysql_free_result ($result)) { echo "Memory could  
not

be freed\n"; }
  }
  unset ($result); // For good measure
  }

  function fetch_row ($set) {
  return mysql_fetch_row ($set);
  }

  function fetch_array ($set) {
  return mysql_fetch_array ($set, MYSQL_ASSOC);
  }
}

// I seem to be losing memory when I call this
$db->fetch($sql);
?>

The result I get with this is...

Memory usage before query: 6,406,548
Memory usage after  query: 6,406,548
Memory usage after  fetch: 6,406,548
Memory usage after   free: 6,406,572

As you may notice, the memory actually goes UP after the  
*freeing* of
memory. Why is this happening?! What have I done wrong? Is this a  
bug?

Any thoughts would be appreciated.



First off, my question would be, is your query actually working?
Because I
would imagine that if you were getting results back from the DB,  
that

the amount
of memory being used would increase between step 1 & 2.

Check to make sure that you are getting results.


I'm confident the queries are working (there's many of them and I  
know

the data they're returning is correct), but they may not always be
returning results. The memory value does change in some instances...

Memory usage before query: 5,138,372
Memory usage after  query: 5,138,396
Memory usage after   free: 5,138,556

This was one that use fetch_row() instead of fetch_array(), but the  
same

difference. I did some searching around and I think it's a bug in PHP
and/or Zend Memory Management engine. As I mentioned in a previous  
post
about mysql_query() not allocating memory appropriately, I believe  
this

could quite possibly be the case. Several people have reported bugs
similar to this... unfortunately, they are marked as (erroneously?)
bogus or said it has been fixed (when, IMO, it has not).

http://bugs.php.net/bug.php?id=40883
http://bugs.php.net/bug.php?id=28424
http://bugs.php.net/bug.php?id=41871

I'm using version 5.2.6 on Fedora 8 and the bug still appears to be
there. I think I'm going to take a different approach to fix this.  
I'll
create a shell script to loop and invoke the socket listener  
script, and

when it gathers data, call the import script. This way, the php
script(s) will end execution after each iteration and release the
memory. Is this reasonable?

This has been a long day. Thanks for your input. Any more thoughts  
are

welcome.

~Philip



Doesn't PHP only give back a "pointer" back from MySQL when it runs  
a query?
Then what PHP does is uses that "pointer" to mysql to request the  
next row of

results?

Couldn't you use the unbuffered-query function for this?

htt

Re: [PHP] Where's my memory going?!

2009-09-30 Thread Philip Thompson

On Sep 29, 2009, at 6:15 PM, Eddie Drapkin wrote:


On Tue, Sep 29, 2009 at 6:51 PM, Jim Lucas  wrote:

Philip Thompson wrote:

On Sep 29, 2009, at 4:38 PM, Jim Lucas wrote:


Philip Thompson wrote:

On Sep 28, 2009, at 4:40 PM, jeff brown wrote:

Yes, that's the best way to clean up after yourself.  And you  
really

should use that on anything you have sitting around daemon like.

Jeff

Philip Thompson wrote:

On Sep 28, 2009, at 4:27 PM, Ralph Deffke wrote:
well this sound clearly to me like you are not freeing  
resultsets
you are not going to use anymore. In long scripts you have to  
take

care of this. on short scripts you can be a bit weak on that,
because the resultsets are closed and freed on script ending.

assumed u r using MySQL are u using mysql_free_result($result)

goog luck

ralph_def...@yahoo.de


"Philip Thompson"  wrote in message
news:9c0b9c4c-5e64-4519-862b-8a3e1da4d...@gmail.com...

Hi all.

I have a script that opens a socket, creates a persistent  
mysql
connection, and loops to receive data. When the amount of  
specified
data has been received, it calls a class which processes the  
data

and
inserts it into the database. Each iteration, I unset/ 
destruct that

class I call. However, the script keeps going up in memory and
eventually runs out, causing a fatal error. Any thoughts on  
where to

start to see where I'm losing my memory?

Thanks in advance,
~Philip
I am not using mysql_free_result(). Is that highly recommended  
by all?

Thanks,
~Philip


I took your suggestions and made sure to clean up after myself.  
I'm

running into something that *appears* to be a bug with
mysql_free_result(). Here's a snippet of my db class.

query($sql);
   echo "Memory usage after  query: " . number_format
(memory_get_usage ()) . "\n";

   if (!$assoc) { $result = $this->fetch_row($resultSet); }
   else {
   $result = $this->fetch_array($resultSet);
   echo "Memory usage after  fetch: " . number_format
(memory_get_usage ()) . "\n";
   }

   $this->freeResult($resultSet);
   echo "Memory usage after   free: " . number_format
(memory_get_usage ()) . "\n";

   return $result;
   }

   function freeResult ($result)
   {
   if (is_resource ($result)) {
   if (!mysql_free_result ($result)) { echo "Memory  
could not

be freed\n"; }
   }
   unset ($result); // For good measure
   }

   function fetch_row ($set) {
   return mysql_fetch_row ($set);
   }

   function fetch_array ($set) {
   return mysql_fetch_array ($set, MYSQL_ASSOC);
   }
}

// I seem to be losing memory when I call this
$db->fetch($sql);
?>

The result I get with this is...

Memory usage before query: 6,406,548
Memory usage after  query: 6,406,548
Memory usage after  fetch: 6,406,548
Memory usage after   free: 6,406,572

As you may notice, the memory actually goes UP after the  
*freeing* of
memory. Why is this happening?! What have I done wrong? Is this  
a bug?

Any thoughts would be appreciated.



First off, my question would be, is your query actually working?
Because I
would imagine that if you were getting results back from the DB,  
that

the amount
of memory being used would increase between step 1 & 2.

Check to make sure that you are getting results.


I'm confident the queries are working (there's many of them and I  
know

the data they're returning is correct), but they may not always be
returning results. The memory value does change in some instances...

Memory usage before query: 5,138,372
Memory usage after  query: 5,138,396
Memory usage after   free: 5,138,556

This was one that use fetch_row() instead of fetch_array(), but  
the same
difference. I did some searching around and I think it's a bug in  
PHP
and/or Zend Memory Management engine. As I mentioned in a previous  
post
about mysql_query() not allocating memory appropriately, I believe  
this

could quite possibly be the case. Several people have reported bugs
similar to this... unfortunately, they are marked as (erroneously?)
bogus or said it has been fixed (when, IMO, it has not).

http://bugs.php.net/bug.php?id=40883
http://bugs.php.net/bug.php?id=28424
http://bugs.php.net/bug.php?id=41871

I'm using version 5.2.6 on Fedora 8 and the bug still appears to be
there. I think I'm going to take a different approach to fix this.  
I'll
create a shell script to loop and invoke the socket listener  
script, and

when it gathers data, call the import script. This way, the php
script(s) will end execution after each iteration and release the
memory. Is this reasonable?

This has been a long day. Thanks for your input. Any more thoughts  
are

welcome.

~Philip



Doesn't PHP only give back a "pointer" back from MySQL when it runs  
a query?
Then what PHP does is uses that "pointer" to mysql to request the  
next 

Re: [PHP] Self-Process php forms or not?

2009-10-05 Thread Philip Thompson

On Oct 2, 2009, at 3:00 AM, Manuel Lemos wrote:


Hello,

on 10/02/2009 04:41 AM kranthi said the following:

I try to avoid the use of hidden form elements as much as possible,
especially for tracking whether a user has submitted a form or not...

I use name="submit" for the submit button instead, that will pass the
value of the submit button to the action script.

above all i use a template engine, smarty to take care of the
presentation for me(like deciding whether to show the form and/or a
success/failure message)


That only works if the user clicks on that submit button. If the user
hits the enter key in a text input, the form is submitted but the  
submit
input variable is not set. That is why an hidden input is a safer  
solution.


If you need the button to be *clicked*...



Or something along those lines.

~Philip

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



Re: [PHP] Self-Process php forms or not?

2009-10-06 Thread Philip Thompson

On Oct 5, 2009, at 7:42 PM, Manuel Lemos wrote:


Hello,

on 10/05/2009 03:02 PM Philip Thompson said the following:

I try to avoid the use of hidden form elements as much as possible,
especially for tracking whether a user has submitted a form or  
not...


I use name="submit" for the submit button instead, that will pass  
the

value of the submit button to the action script.

above all i use a template engine, smarty to take care of the
presentation for me(like deciding whether to show the form and/or a
success/failure message)


That only works if the user clicks on that submit button. If the  
user
hits the enter key in a text input, the form is submitted but the  
submit

input variable is not set. That is why an hidden input is a safer
solution.


If you need the button to be *clicked*...



Or something along those lines.


That does not make much sense and is pointless. First that syntax you
mentioned probably requires JQuery or some other large Javascript
library. something like this['submitButton'].click() would emulate the
click event. Second, by the time that onsubmit is called, the event  
that

triggered it was already dispatched. Emulating the click on a button
would probably fire the form submission and onsubmit code would be run
again, leading to an infinite loop sucking machine CPU.


It makes perfect sense and is not pointless. Yes, it is library- 
specific javascript. However, it was used to show an example and make  
a point. I assume that most the subscribers here are able to decipher  
the code and determine what the intent was. And no, this will not  
cause an infinite loop. The onsubmit is called first and will process  
whatever action you specify, and then move on. *If* the submit button  
wasn't *clicked* and you needed it to be, then this would emulate that  
functionality. I'm not saying this is the best solution on how to deal  
with the previous question but it is *a* solution.


Here's some code that you can see there's no infinite loop and shows  
which events are called first.


--



loop? i don't think so


Times submitted: 

name="theForm" onsubmit="document.getElementById('submitBtn').click();  
return false;">


>




document.theForm.text.focus();


--

The above code works as expected in Safari 4.0.3, FF3.5.3 and IE8.

Cheers,
~Philip

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



Re: [PHP] Re: ternary operator sintax help

2009-10-06 Thread Philip Thompson

On Oct 6, 2009, at 2:26 PM, MEM wrote:


Sorry all,
It's ok. The sintax:

'.$erros['anexo'].'' :''); ?>

Was right all the time.

Anyway, I've learn something new: having a var with '' is not the  
same thing
as not been unset. So we must pay attention on what cases we use  
isset, or

!empty.


Thanks a lot,
Márcio


-Original Message-
From: João Cândido de Souza Neto [mailto:j...@consultorweb.cnt.br]
Sent: terça-feira, 6 de Outubro de 2009 19:53
To: php-general@lists.php.net
Subject: [PHP] Re: ternary operator sintax help

'.$erros['anexo'].'' :''); ?>

""MEM""  escreveu na mensagem
news:002401ca46b4$ed6ad6a0$c84083...@com...
Hello all,

I'm trying to display a div, only when some php value is set.
Since this will be near html, I'd like to keep it on one line. So,  
I'd

love
to use shortcuts and a ternary operator for the effect.

I'm having something like this right now, but the div still appears
even if
the error is NOT set.

'
.$erros['anexo'].'' :''; ?>

:(

Can I have your help with the right syntax ?


Another one to consider...

strlen ($item) > 0 ? 'not empty' : 'empty';

Because "empty()" will return true if 0 is the value, sometimes you  
have to check for the length of the item.


~Philip


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



Re: [PHP] Need unrounded precision

2009-10-14 Thread Philip Thompson

On Oct 12, 2009, at 2:37 PM, Andrea Giammarchi wrote:

bitwise right shift is probably the fastest cast to int so far ...  
still in many languages, intval is a function call


being a cast in both cases (int) is good as well ... bitwise,  
casting, works with strings, arrays, boolean, whatever as well.


I don't think there is any difference in php, except when the  
integer is "too big" ... but this was not the case, we had to deal  
with 1 to 10 :-)


Regards


From: jbo...@mindsites.com
To: an_...@hotmail.com
CC: php-general@lists.php.net
Date: Mon, 12 Oct 2009 11:33:10 -0500
Subject: RE: [PHP] Need unrounded precision


Hmmm... Didn't think about this, but % only works with int values


it was just future prof precaution since this statement is false  
for many other languages.

In few words I am not sure PHP6 does the same ... never mind so far


Good to know.  In that case, I would probably just use intval()  
instead of >> since it's clearer and bitwise shifts aren't  
necessarily integer only either.


Jaime


I like the bitwise shifting, but here's another potential (albeit  
probably slower) solution.


$a = 28.56018;
list (,$dec) = explode ('.', $a);
$b = $dec{0};

Cheers,
~Philip

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



[PHP] Please don't kick me!

2009-10-19 Thread Philip Thompson

Hi all.

I know this question has been asked a thousand times on the list, but  
my searches in the archives are not being nice to me. So... please  
don't kick me.


Currently, we use DOMPDF to generate PDFs from HTML. However, it's no  
longer maintained and it has a few bugs that we just can no longer  
live with. What PDF generating software do you use? It does not have  
to be free, but it must run on linux and may be command line or run  
through code. Some of the ones I have researched are...


html2pdf
html2ps
html2fpdf
xhtml2pdf
fpdf
tcpdf

You're thoughts would be appreciated. Oh, my preference would be to  
send HTML/CSS to a script and it just automagically convert to PS/PDF.


Thanks,
~Philip

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



Re: [PHP] Please don't kick me!

2009-10-19 Thread Philip Thompson

On Oct 19, 2009, at 3:52 PM, Floyd Resler wrote:


Phillip,
	I use ezpdf (http://www.ros.co.nz/pdf/).  I've been using it for  
years and have found it very capable of making any PDF I want.


Take care,
Floyd


This one seems fairly neat. However, it appears as though the author  
no longer keeps up with it - last entry on 6/17/2006. Have you ever  
run into any problems or setbacks with it?


Thanks,
~Philip

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



Re: [PHP] Get rid of warning massage

2009-10-20 Thread Philip Thompson

On Oct 20, 2009, at 10:34 AM, resea soul wrote:


Hi,

I'm using the function file_get_contents($url). If the url is  
invalid the

function displays a warning message while I am using my own customized
message. I want to get rid of the warning message.

Thank you


@file_get_contents(...)



Re: [PHP] Please don't kick me!

2009-10-20 Thread Philip Thompson

On Oct 19, 2009, at 4:21 PM, Floyd Resler wrote:

Nope.  I've never had any troubles with it.  I've been able to  
produce all kinds of PDFs including loan agreements, inventory pick  
lists with barcodes, and various others.  I find it incredibly  
powerful and easy to use.


Take care,
Floyd


Sorry if this is slightly OT.

I've been messing around with ezPdf for a little bit and it doesn't  
appear to be able to allow for custom background colors or borders on  
a per-row basis. Meaning, I have the option to color every other line  
a single color... but I can't color every line a different color if I  
want. Am I missing something here?


Basically, with the reports I'm currently generating, every row could  
be a different color than the previous - it depends on various  
factors. This is easy to accomplish with HTML/CSS. If this isn't  
possible (or at least easily-accomplishable), then ezPdf may not be  
for me.


Thanks,
~Philip

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



Re: [PHP] Please don't kick me!

2009-10-20 Thread Philip Thompson

On Oct 20, 2009, at 2:40 PM, Floyd Resler wrote:

As far as I know ezPDF can't do what you want it to do.  Of course,  
you could always modify the code the suite your needs.  Since it  
already draws tables it probably wouldn't be too difficult to modify  
it draw row backgrounds of different colors.


Take care,
Floyd


I got it to draw the different background colors successfully.  
However, drawing borders is not as straight forward. I'm sure I could  
get it working as well... but I'd rather it work *out of the box*.  
Thanks for the suggestion. ;)


~Phil



On Oct 20, 2009, at 3:25 PM, Philip Thompson wrote:


On Oct 19, 2009, at 4:21 PM, Floyd Resler wrote:

Nope.  I've never had any troubles with it.  I've been able to  
produce all kinds of PDFs including loan agreements, inventory  
pick lists with barcodes, and various others.  I find it  
incredibly powerful and easy to use.


Take care,
Floyd


Sorry if this is slightly OT.

I've been messing around with ezPdf for a little bit and it doesn't  
appear to be able to allow for custom background colors or borders  
on a per-row basis. Meaning, I have the option to color every other  
line a single color... but I can't color every line a different  
color if I want. Am I missing something here?


Basically, with the reports I'm currently generating, every row  
could be a different color than the previous - it depends on  
various factors. This is easy to accomplish with HTML/CSS. If this  
isn't possible (or at least easily-accomplishable), then ezPdf may  
not be for me.


Thanks,
~Philip


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



Re: [PHP] Please don't kick me!

2009-10-22 Thread Philip Thompson

On Oct 20, 2009, at 3:44 PM, Kim Madsen wrote:


Philip Thompson wrote on 2009-10-20 21:58:

I got it to draw the different background colors successfully.  
However, drawing borders is not as straight forward. I'm sure I  
could get it working as well... but I'd rather it work *out of the  
box*. Thanks for the suggestion. ;)


Well, you're always welcome to contribute to an open source project  
you take advantage of ;o)


Tis true. However, my passion does not include creating a better PDF  
generator. After doing a lil bit more research, I came across this one  
and I really like it so far.


http://realobjects.com/PDFreactor.939.0.html

It's definitely not free, but it seems to do what I need... so far.

Thanks,
~Philip


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



Re: [PHP] Spam opinions please

2009-10-22 Thread Philip Thompson

On Oct 20, 2009, at 1:48 PM, Gary wrote:

NO I have not, I think my issue is I hate when I run across one, it  
usually
takes me more than one try to actually figure out what the charactor  
is, so

hence my disdain.


GAry


Here are some captchas:

"What's three minus two?"
"Which word is listed first in the dictionary: apple, banana, pizza?"
"Add 4 plus 5"

Create a list of simple questions that only humans can answer. I find  
these to be less annoying.


~Philip



"Paul M Foster"  wrote in message
news:20091020184001.gi3...@quillandmouse.com...

On Tue, Oct 20, 2009 at 02:31:53PM -0400, Gary wrote:

I have several sites that are getting hit with form spam.  I have  
the

script
set up to capture the IP address so I know from where they come.   
I found

a
short script that is supposed to stop these IP addresses from  
accessing

the
form page, it redirects the spammer to another page (I was going to
redirect
to a page that has lots of pop-ups, scantily clad men and offers  
of joy

beyond imagination), but someone suggested I redirect to the Federal
Trade
Commission or perhpas the FBI.

Any thoughts on the script and its effectivness?

http://www.google.com/";);
  exit();
} ?>Gary



Have you tried CAPTCHA?

Paul


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



[PHP] Limit query/function time

2009-10-22 Thread Philip Thompson

Hi all.

I'm running into a random issue where sometimes it take several  
minutes (up to 10 or 15) to complete a query. According to 1 or 2  
references, this may be a mysql bug. These links explain the similar  
problem I'm experiencing:


http://forums.mysql.com/read.php?24,57257
http://forum.percona.com/s/m/790/

I did some testing yesterday and this 1 sql statement successfully  
queried (in milliseconds) approximately 50,000 times before it took  
several minutes to query, which hung all the other processes on the  
database. Because it occurs successfully so many times, I know the  
query is good.


Is it possible to set a time limit on a single function in PHP? E.g.,  
when I call mysql_query() and it takes 30 seconds, then quit  
processing that function and continue on. I know I could set_time_limit 
() to a specific time, but that would cause a fatal error... and I  
want to be able to catch it.


Any thoughts on what direction I should go? Also, I'm going to do some  
research to see if a newer version of mysql has fixed this bug. We're  
running 5.0.45.


Thanks,
~Philip

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



Re: [PHP] Limit query/function time

2009-10-22 Thread Philip Thompson

On Oct 22, 2009, at 3:26 PM, Eddie Drapkin wrote:

On Thu, Oct 22, 2009 at 4:14 PM, Philip Thompson > wrote:

Hi all.

I'm running into a random issue where sometimes it take several  
minutes (up
to 10 or 15) to complete a query. According to 1 or 2 references,  
this may
be a mysql bug. These links explain the similar problem I'm  
experiencing:


http://forums.mysql.com/read.php?24,57257
http://forum.percona.com/s/m/790/

I did some testing yesterday and this 1 sql statement successfully  
queried
(in milliseconds) approximately 50,000 times before it took several  
minutes
to query, which hung all the other processes on the database.  
Because it

occurs successfully so many times, I know the query is good.

Is it possible to set a time limit on a single function in PHP?  
E.g., when I

call mysql_query() and it takes 30 seconds, then quit processing that
function and continue on. I know I could set_time_limit() to a  
specific
time, but that would cause a fatal error... and I want to be able  
to catch

it.

Any thoughts on what direction I should go? Also, I'm going to do  
some

research to see if a newer version of mysql has fixed this bug. We're
running 5.0.45.

Thanks,
~Philip


You could use ErrorException and catch that:
http://www.php.net/manual/en/class.errorexception.php
Or you could just set your own error handler:
http://www.php.net/manual/en/function.set-error-handler.php

Something I don't know if you've thought of that came to mind, though,
is the MySQL query cache.  It's entirely likely that you have a query
that takes several minutes to run, then is stored in query cache for
the next 50,000 iterations of the query.  Have you observed this same
behavior without the query cache enabled (it also looks like the bug
mentioned in the second link - the one that pertains to the 5.0.x
branch of mysql - has to do with an overly large query cache)?  Based
on that post, I'd guess that your next action would be to disable the
query cache and determine from there if it's a slow query or actually
the bug in MySQL.


I didn't think you could catch fatal errors - isn't that why they're  
fatal?


I will check into the query cache thing. However, the query that I'm  
running isn't exactly the same each time. Each iteration has a  
different ID value in the WHERE clause.


Thank you,
~Philip



Re: [PHP] Limit query/function time

2009-10-22 Thread Philip Thompson

On Oct 22, 2009, at 3:30 PM, Phpster wrote:


Have you run an explain plan on the query?

Bastien

Sent from my iPod


Yes, I have. For giggles, I wanted to run it again. Here it is  
(slightly stripped down) and it looks good to me.


mysql> EXPLAIN SELECT
-> `p`.`patient_id`,
-> `p`.`address_id`,
-> `p`.`patient_sub_id`,
-> AES_DECRYPT(`p`.`patient_first_name`, 'hidden_key') AS  
`patient_first_name`,
-> AES_DECRYPT(`p`.`patient_last_name`, 'hidden_key') AS  
`patient_last_name`,
-> AES_DECRYPT(`p`.`patient_middle_name`, 'hidden_key') AS  
`patient_middle_name`,

-> AES_DECRYPT(`p`.`patient_dob`, 'hidden_key') AS `patient_dob`
-> FROM `patient` `p`
-> INNER JOIN `center_patient` `cp` ON `p`.`patient_id` =  
`cp`.`patient_id`
-> WHERE ((`p`.`patient_id` = '256783' OR `p`.`patient_sub_id` =  
'256783') AND `cp`.`center_id` = '109')

-> ORDER BY `patient_id` DESC;
++-++-- 
+--+
| id | key_len | ref| rows |  
Extra|
++-++-- 
+--+
|  1 | 4,4 | NULL   |2 | Using union 
(PRIMARY,patient_sub_id); Using where; Using filesort |
|  1 | 8   | p.patient_id,const |1 | Using  
index  |
++-++-- 
+--+

2 rows in set (0.00 sec)

There are about 350,000 records in `patient` and `center_patient`  
tables. The average number of rows returned from this query is less  
than 5.


~Philip


On Oct 22, 2009, at 4:14 PM, Philip Thompson  
 wrote:



Hi all.

I'm running into a random issue where sometimes it take several  
minutes (up to 10 or 15) to complete a query. According to 1 or 2  
references, this may be a mysql bug. These links explain the  
similar problem I'm experiencing:


http://forums.mysql.com/read.php?24,57257
http://forum.percona.com/s/m/790/

I did some testing yesterday and this 1 sql statement successfully  
queried (in milliseconds) approximately 50,000 times before it took  
several minutes to query, which hung all the other processes on the  
database. Because it occurs successfully so many times, I know the  
query is good.


Is it possible to set a time limit on a single function in PHP?  
E.g., when I call mysql_query() and it takes 30 seconds, then quit  
processing that function and continue on. I know I could  
set_time_limit() to a specific time, but that would cause a fatal  
error... and I want to be able to catch it.


Any thoughts on what direction I should go? Also, I'm going to do  
some research to see if a newer version of mysql has fixed this  
bug. We're running 5.0.45.


Thanks,
~Philip


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



[PHP] It's not behaving. Error reporting, that is

2009-11-03 Thread Philip Thompson

Hi all.

This seems like a trivial issue to fix, but I'm having issues. I'm  
running a script via command line and it's throwing out PHP "notices."  
Well, I want to suppress those notices. At the top of my script I have  
the line...




...thinking that this would get rid of the notices. However, it did  
not. They still appear. I even attempted using ini_set(), but to no  
avail. I then set error_reporting in php.ini - this made no  
difference. (I shouldn't have to restart apache when running via  
command line, but for giggles, I did.) I then changed display_errors  
to Off. You guessed it - no change! This immediately brought up the  
question... "Well, what php.ini is this script using?" Here's my  
results...


[pthomp...@s-irv-pthompson scripts]$ php --ini
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /etc/php.ini
Scan for additional .ini files in: /etc/php.d
...

Yup, according to PHP I'm using the correct ini. Now I'm at a loss.  
Can anyone shed some light on this big brain fart I'm having? Thanks  
in advance.


~Philip

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



Re: [PHP] It's not behaving. Error reporting, that is

2009-11-04 Thread Philip Thompson

On Nov 3, 2009, at 11:24 AM, Kim Madsen wrote:


Hi Philip

Try to post a link to a page, that prints phpinfo()

--  
Kind regards

Kim Emax

Philip Thompson wrote on 2009-11-03 17:11:

Hi all.
This seems like a trivial issue to fix, but I'm having issues. I'm  
running a script via command line and it's throwing out PHP  
"notices." Well, I want to suppress those notices. At the top of my  
script I have the line...


...thinking that this would get rid of the notices. However, it did  
not. They still appear. I even attempted using ini_set(), but to no  
avail. I then set error_reporting in php.ini - this made no  
difference. (I shouldn't have to restart apache when running via  
command line, but for giggles, I did.) I then changed  
display_errors to Off. You guessed it - no change! This immediately  
brought up the question... "Well, what php.ini is this script  
using?" Here's my results...

[pthomp...@s-irv-pthompson scripts]$ php --ini
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /etc/php.ini
Scan for additional .ini files in: /etc/php.d
...
Yup, according to PHP I'm using the correct ini. Now I'm at a loss.  
Can anyone shed some light on this big brain fart I'm having?  
Thanks in advance.

~Philip



--
Kind regards
Kim Emax - masterminds.dk


That's all good and dandy. But this is a cli application. And besides,  
the computer is not accessible via the Internet.


Thanks,
~Philip

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



Re: [PHP] function not returning query

2009-11-23 Thread Philip Thompson
On Nov 23, 2009, at 6:22 PM, Allen McCabe wrote:

> Hi, thanks for reading, I hope you can help:
> 
> In my main file for an orders page I have the following code:
> 
> 
> if (isset($_GET['filterby']))
> {
>  $resultOrders = adminFilterQuery();
>  $numberOfOrders = mysql_num_rows($resultOrders);
> }
> else
> {
>  $resultOrders = mysql_query("SELECT * FROM afy_order;") or
> die(mysql_error("Could not query the database!"));
>  $numberOfOrders = mysql_num_rows($resultOrders);
> }

You reduce this part by one line by putting the following after the else 
statement and removing the other 2:

$numberOfOrders = mysql_num_rows ($resultOrders);

Also, these queries don't need a semi-colon (;) to end the query. PHP handles 
this part. Remove them.


> adminFilterQuery() is a custom function that is supposed to return a
> mysql_query, here are the last few lines of this function:
> 
> 
> $query = "SELECT * FROM afy_order WHERE school_id = '{$school}' ORDER BY
> {$order_by_param};";
> $result = mysql_query($query);
> return $result;
> 
> l am getting this error when I try to filter my query using a form in tandem
> with the quey building function:
> 
> *Warning*: mysql_num_rows(): supplied argument is not a valid MySQL result
> resource
> 
> where the line is the one where I use the mysql_num_rows function.
> 
> What am I missing here?
> 
> Thanks!

Do you get this warning with both queries? Make sure that your queries are 
using a valid mysql connection. You may also consider using a database class to 
perform the repetitive tasks so that you really only have to be concerned with 
the queries you're writing...?

query('SELECT * FROM afy_order');
$numRows = $db->numRows($result);
?>

Of course this is just a simple example, but you get the idea. Hope that stirs 
your brain!

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



Re: [PHP] Query based on Server offset TimeStamp

2009-11-23 Thread Philip Thompson
On Nov 23, 2009, at 7:37 PM, Don Wieland wrote:

> Hello,
> 
> I have a mySQL database server in Florida USA (EST) and I want to do a query 
> on a record in California, USA (PST) 3 hours earlier using PST instead of EST.
> 
> I would like to add to my CORE page that offset of the timezone so I can use 
> it in a query like:
> 
> Select * FROM aTable WHERE ServerOffsetTimeStap >= Row_Start_TimeStamp AND 
> ServerOffsetTimeStap <= Row_End_TimeStamp
> 
> How would I do this?
> 
> Appreciate any help you can offer. Thanks!

When I store timestamps, I store them in GMT time. This way, no matter when you 
pull it out of the database, you *know* when it was stored - even in a 
different timezone. To achieve this...



Maybe this will make it a little easier to query accordingly...? Hope this 
stirs your brain.

~Philip

PS... Others may profess that you use UTC instead of GMT, but that's a 
different thread.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] function not returning query

2009-11-25 Thread Philip Thompson
On Nov 25, 2009, at 4:32 AM, Ashley Sheridan wrote:

> On Tue, 2009-11-24 at 23:27 -0800, Allen McCabe wrote:
> 
>> If I were to loop through my inputs, I could just exclude any
>> problematic names, eg.:
>> 
>> foreach ($_POST as $var = $val)
>> {
>>   if ($var != filter.x || $var != filter.y)
>>  {
>>$var = $val;
>>  }
>> }
>> 
>> Like that?



> Not really, what if someone else decided they wanted to throw in their
> own form field values in the hope of breaking your system? It's much
> better to be specifically looking for certain form fields and certain
> field values/ranges. For example, if you had some fields that would
> filter something by cost, you might have two form fields named 'max' and
> 'min' which would be ranges for the cost. You should check that these
> fields only contain numbers for example before processing them. Any data
> coming from the client-side is untrustworthy and should be regarded as
> tainted until you can prove otherwise.
> 
> Thanks,
> Ash

The system Ash is referring to is a whitebox approach. You know what you should 
get in, so only accept those values. A simple thing to accomplish what you're 
trying to do, Allen, would be to create an array of required/accepted fields...

 $val) {
if (in_array ($var, $acceptable)) {
// Do whatever here
} else {
// Not acceptable - throw error message or do nothing
}
}
?>

Hope that helps.
~Philip
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP+Firebird numeric format problem

2009-11-30 Thread Philip Thompson
On Nov 30, 2009, at 5:37 AM, helderfelipe wrote:

> I have a query who is returning a NUMERIC(18,8) column.
> 
> In the IBExpert, te resultset is:
> 
> 30,9127
> 836,5800
> 
> But PHP returns in a strange format:
> 
> 3.9127
> 83.65800
> 
> Somebody help ?

That "strange format" you're referring to looks like US_EN locale (or similar). 
I'm guessing you're not from the U.S.? =D If you need to reformat the output, 
consider

http://php.net/number_format

Hope that helps.
~Philip
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] cookies and carts

2009-12-07 Thread Philip Thompson
On Dec 7, 2009, at 4:39 PM, Allen McCabe wrote:

> I have a shopping cart type system set up which keeps track of the cart
> contents using a SESSION variable, where $_SESSION['cart'][$item_id'] is
> equal to the quantity, so the name/value pair is all the information I need.
> 
> But sessions are unreliable on the free server I am currently using for this
> website (not my choice), so I had start using cookies because users were
> being sporadically logged out, sometimes just on a page refresh.
> 
> I want to find a way to set a cookie to remember the cart items as well, and
> I thought setting a cookie for each item/quantity pair was the way to go
> until I started trying to figure out how to unset all those cookies if the
> user empties their cart.
> 
> Is there any way to set cookies with an array for the name? Intead of
> $_COOKIE['item_number'] have $_COOKIE['cart']['item_number'] like I have the
> SESSION?

Don't do it this way. At some point (don't know if it's still true), IE had a 
limit of 20 cookies per domain - this includes cookie arrays. The proper way to 
do this would be to hold some sort of key in a cookie:

user_cart = 'some unique value for this user'

Then, in your PHP code, grab the value of $_COOKIE['user_cart'] to reference 
data in a database. Then, you pull the information from the database with this 
unique key and use it to display the appropriate items. This is the most secure 
way to do it (with the proper security measures ;) and it doesn't put 100's of 
needless cookies on the user's machine.

Hope this helps.
~Philip
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] cookies and carts

2009-12-07 Thread Philip Thompson
On Dec 7, 2009, at 4:40 PM, Ashley Sheridan wrote:

> On Mon, 2009-12-07 at 14:39 -0800, Allen McCabe wrote:
> 
>> I have a shopping cart type system set up which keeps track of the cart
>> contents using a SESSION variable, where $_SESSION['cart'][$item_id'] is
>> equal to the quantity, so the name/value pair is all the information I need.
>> 
>> But sessions are unreliable on the free server I am currently using for this
>> website (not my choice), so I had start using cookies because users were
>> being sporadically logged out, sometimes just on a page refresh.
>> 
>> I want to find a way to set a cookie to remember the cart items as well, and
>> I thought setting a cookie for each item/quantity pair was the way to go
>> until I started trying to figure out how to unset all those cookies if the
>> user empties their cart.
>> 
>> Is there any way to set cookies with an array for the name? Intead of
>> $_COOKIE['item_number'] have $_COOKIE['cart']['item_number'] like I have the
>> SESSION?
> 
> 
> What about storing a unique ID in the cookie, and matching it up with
> information for that user in a database. It's sort of simulating a
> sessions, but without the session handler getting involved, which looks
> slightly messed up from what you've said.
> 
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk

Blast your speedier typing!! =P

~Philip


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



Re: [PHP] cookies and carts

2009-12-07 Thread Philip Thompson
On Dec 7, 2009, at 4:46 PM, Ashley Sheridan wrote:

> On Mon, 2009-12-07 at 16:48 -0600, Philip Thompson wrote:
>> 
>> On Dec 7, 2009, at 4:40 PM, Ashley Sheridan wrote:
>> 
>> > On Mon, 2009-12-07 at 14:39 -0800, Allen McCabe wrote:
>> > 
>> >> I have a shopping cart type system set up which keeps track of the cart
>> >> contents using a SESSION variable, where $_SESSION['cart'][$item_id'] is
>> >> equal to the quantity, so the name/value pair is all the information I 
>> >> need.
>> >> 
>> >> But sessions are unreliable on the free server I am currently using for 
>> >> this
>> >> website (not my choice), so I had start using cookies because users were
>> >> being sporadically logged out, sometimes just on a page refresh.
>> >> 
>> >> I want to find a way to set a cookie to remember the cart items as well, 
>> >> and
>> >> I thought setting a cookie for each item/quantity pair was the way to go
>> >> until I started trying to figure out how to unset all those cookies if the
>> >> user empties their cart.
>> >> 
>> >> Is there any way to set cookies with an array for the name? Intead of
>> >> $_COOKIE['item_number'] have $_COOKIE['cart']['item_number'] like I have 
>> >> the
>> >> SESSION?
>> > 
>> > 
>> > What about storing a unique ID in the cookie, and matching it up with
>> > information for that user in a database. It's sort of simulating a
>> > sessions, but without the session handler getting involved, which looks
>> > slightly messed up from what you've said.
>> > 
>> > Thanks,
>> > Ash
>> > http://www.ashleysheridan.co.uk
>> 
>> Blast your speedier typing!! =P
>> 
>> ~Philip
>> 
> 
> By the power of Kenco!
> 
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
> 

I hope you don't kiss your mother with that mouth!!



Re: [PHP] Passing HTML array index to JS?

2009-12-07 Thread Philip Thompson
On Dec 7, 2009, at 5:02 PM, Skip Evans wrote:

> Hey all,
> 
> I have an HTML field like this
> 
>  style="text-align: right;" onblur="calculateBidUnit();">
> 
> ... and what I need to do is pass to the calculateBidUnit function the value 
> of quantity, do a calculation on it and plug into this field.
> 
> 
> 
> Which of course I know how to do for non-array values, but not sure how to 
> get the values to do the calculation on the JS side if the fields are in an 
> array.
> 
> Any help, as always, is greatly appreciated,
> Skip

This question is probably more appropriate for a JS list... but I'm not mean, 
so I'll let you know. The easiest way would be to update the blur event qty 
input:

onblur="calculateBidUnit(this.value);"

Now you have the value sent to that function. Another way would be to give your 
input and output an id each - let's say 'qty' and 'bid_unit_value', 
respectively. Then reference those ids in your function. This gives you the 
following:





function calculateBidUnit () {
var qty = document.getElementById('qty');
var buv = document.getElementById('bid_unit_value');
buv.value = qty.value;
}


I'll give you a small warning. All browsers are not alike, so my recommendation 
would be to use a library that handles the cross-browser compatibility portion 
of javascript (I use Mootools). Nonetheless, the above *should* work. Learning 
the bare bones of javascript will help with the more complicated stuff and 
you'll be smarter for it! =P

Hope that helps,
~Philip
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Passing HTML array index to JS?

2009-12-07 Thread Philip Thompson
On Dec 7, 2009, at 6:32 PM, Skip Evans wrote:

> Hey Philip,
> 
> But will that ID value identify the right member of each array? I thought 
> about that but just assumed that it would not.
> 
> Skip
> 
> Philip Thompson wrote:
>> On Dec 7, 2009, at 5:02 PM, Skip Evans wrote:
>>> Hey all,
>>> 
>>> I have an HTML field like this
>>> 
>>> >> style="text-align: right;" onblur="calculateBidUnit();">
>>> 
>>> ... and what I need to do is pass to the calculateBidUnit function the 
>>> value of quantity, do a calculation on it and plug into this field.
>>> 
>>> 
>>> 
>>> Which of course I know how to do for non-array values, but not sure how to 
>>> get the values to do the calculation on the JS side if the fields are in an 
>>> array.
>>> 
>>> Any help, as always, is greatly appreciated,
>>> Skip
>> This question is probably more appropriate for a JS list... but I'm not 
>> mean, so I'll let you know. The easiest way would be to update the blur 
>> event qty input:
>> onblur="calculateBidUnit(this.value);"
>> Now you have the value sent to that function. Another way would be to give 
>> your input and output an id each - let's say 'qty' and 'bid_unit_value', 
>> respectively. Then reference those ids in your function. This gives you the 
>> following:
>> > onblur="calculateBidUnit();" id="qty" />
>> 
>> 
>> function calculateBidUnit () {
>>var qty = document.getElementById('qty');
>>var buv = document.getElementById('bid_unit_value');
>>buv.value = qty.value;
>> }
>> 
>> I'll give you a small warning. All browsers are not alike, so my 
>> recommendation would be to use a library that handles the cross-browser 
>> compatibility portion of javascript (I use Mootools). Nonetheless, the above 
>> *should* work. Learning the bare bones of javascript will help with the more 
>> complicated stuff and you'll be smarter for it! =P
>> Hope that helps,
>> ~Philip

Each text input will only contain 1 value... and contain 1 unique "id." So, if 
you have multiple input boxes with the same name (qty[]), only the $_POST 
output will contain an array of each value. See below...








function calc (value) {
document.getElementById('buv').value = value;
}


When you blur qty1, buv will receive the value 1; blur qty2, buv will be 2; and 
so on. The last input box that you blur on will determine buv's final value 
(unless you throw in some logic to handle this)...


function calc (value) {
var buv = document.getElementById('buv');
if (buv.value == '') buv.value = value;
}


So, let's say you blur on qty2 and then submit the form, your PHP script will 
have this in $_POST...

Array
(
[qty] => Array
(
[0] => 1
[1] => 2
[3] => 3
)
[bid_unit_value] => Array
(
[0] => 2
)
)

If this is not what you're wanting, you will need to modify the behavior above. 
If you're wanting the bid_unit_value to contain all the values of each blur, 
you may want to do something like this...


function calc (value) {
var buv = document.getElementById('buv');
if (buv.value == '') buv.value = value;
else buv.value += '|'+value;
}


Which may result from each blur in $_POST to be...

Array
(
[qty] => Array
(
[0] => 1
[1] => 2
[3] => 3
)
[bid_unit_value] => Array
(
[0] => 2|1|3
)
)

Or something along those lines. Then you can just explode() on that first index 
to get individual values. Maybe you can clarify your ultimate goal and we can 
assist you in what the best plan is.

Hope that helps,
~Philip
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] request for support

2009-12-08 Thread Philip Thompson
On Dec 8, 2009, at 6:12 AM, Ashley Sheridan wrote:

> On Tue, 2009-12-08 at 12:08 +, Tarek Kaddoura wrote:
>> __
>> Subject: RE: [PHP] request for support
>> From: a...@ashleysheridan.co.uk
>> To: stevewiese...@hotmail.com
>> CC: php-general@lists.php.net
>> Date: Tue, 8 Dec 2009 11:53:53 +
>> 
>> On Tue, 2009-12-08 at 11:53 +, Tarek Kaddoura wrote:
>> 
>> 
>>sorry sorry thats a typo error
>>the code im using is:
>>PHPIniDir "C:/PHP/"
>>LoadModule php5_module "C:/PHP/php5apache2.dll"
>> 
>>__
>> 
>>Subject: Re: [PHP] request for support
>>From: a...@ashleysheridan.co.uk
>>To: stevewiese...@hotmail.com
>>CC: php-general@lists.php.net
>>Date: Tue, 8 Dec 2009 11:45:38 +
>> 
>>On Tue, 2009-12-08 at 11:29 +, Tarek Kaddoura wrote: 
>> 
>> 
>>I'm using PHP 5.2.11 with Apache 2 (and i also tried Apache 
>> 2.2)
>> 
>>However, when I add this entry to my httpd.conf:
>>
>>LoadModule php4_module "C:/Program 
>> Files/php/sapi/php4apache.dll"
>>
>>Apache will crash when trying to start the service.
>>If I comment the line out, Apache starts just fine.
>> 
>>Thanks for your help.
>>Regards, 
>> 
>>
>>Well, you say you've got PHP 5 installed, yet you're trying to
>>load a PHP 4 module in. Which do you want? I don't think
>>Apache can run 4 and 5 at the same time without complications.
>> 
>>Thanks,
>>Ash
>>http://www.ashleysheridan.co.uk
>> 
>> Don't forget to hit reply to all on the list, and try not to top
>> post! :p
>> 
>> What does it say on the command line when you try to start the service
>> up?
>> 
>> In a root privaleged console type:
>> 
>> /etc/init.d/httpd start
>> 
>> 
>> Thanks,
>> Ash
>> http://www.ashleysheridan.co.uk
>> 
>> No Ashley im using Windows,
>> whenever i start the apache service, it either crashes or promptes me
>> that the operation has failed
>> if i comment these 2 lines out, the apache service starts normally
> 
> Why don't you try a Wamp install, rather than installing the individual
> components?
> 
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk

Why don't you check the apache logs to see what's (not) happening?

~Philip



Re: [PHP] Passing HTML array index to JS?

2009-12-08 Thread Philip Thompson

On Dec 8, 2009, at 11:10 AM, tedd wrote:

> At 9:07 PM -0600 12/7/09, Philip Thompson wrote:
>> 
>> -snip-
> 
> Good stuff.
> 
> Thanks,
> 
> tedd

You say so much with so little...

~Philip


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



Re: [PHP] MySQL Appeal from Monty

2009-12-14 Thread Philip Thompson

On Dec 14, 2009, at 12:51 AM, Lester Caine wrote:

> Lenin wrote:
>> You might also like this:
>> Come on Monty - Lukas Smith http://bit.ly/5lmwwD
> 
> I've been watching some of this debate with interest, but I'll stay with a 
> database that has none of the baggage that MySQL has always had, and IS 
> currently replacing Oracle in many large sites :)
> 
> -- 
> Lester Caine - G8HFL

Do share your db of interest... (and please don't say MSSQL).

~Philip


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



Re: [PHP] PHP live chat

2009-12-14 Thread Philip Thompson
On Dec 14, 2009, at 2:14 AM, Angelo Zanetti wrote:

> Hi all, 
> 
> I know there are a lot of scripts that one can pay for, for "live chat" -
> website support.
> 
> Are there are any free open source ones that work well?
> 
> I found: www.phplivechat.com
> 
> But still waiting to evaluate it.
> 
> Please send you comments, good or bad and what you would recommend or not
> recommend and why
> 
> Thanks in advance.
> 
> Angelo

We used phplivechat at my last company. I'm pretty sure I was the one who set 
it up, and I don't remember hating it. It seemed to work pretty reliably and 
our customers seemed to have enjoyed it. I'd recommend it.

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



Re: [PHP] Best ajax library

2009-12-14 Thread Philip Thompson
On Dec 14, 2009, at 4:27 AM, Ali Asghar Toraby Parizy wrote:

> Hi
> I think the best choice is jquery until now.
> But, is it reasonable to combine jquery and other library to client
> side and server side scripting respectively?
> By the way, where i can find good lessons about jquery and php?

I really like this js library.

http://mootools.net/

It's based off of jquery or prototype... I can't remember.

~Philip

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



[PHP] PHP + ODBC

2009-12-14 Thread Philip Thompson
Hello all.

My head hurts from hitting it on my desk all day, so I thought I'd turn to a 
fresher set of eyes. The issue I'm having is getting PHP to connect ODBC. I can 
get it to work using isql from the command line. Can you verify my settings:

/etc/odbc.ini:

[MySQL]
Description = MySQL 3.51 ODBC driver
Driver  = MySQL
Host= s-irv-web02
Server  = s-irv-web02
UID = user
Password= pass
Database= clients
Port= 3306

/etc/odbcinst.ini:

[MySQL]
Description = ODBC 3.51 for MySQL
Driver  = /usr/lib/libmyodbc3.so
Setup   = /usr/lib/libodbcmyS.so
FileUsage   = 1
UsageCount  = 2

Again, isql allows me to connect with the same settings as above: isql MySQL 
user pass

I've tried several settings in PHP to attempt to connect to it. All have been 
fruitless:



I've tried the above DSNs and many other versions of it ad nauseum. The 
specific error I'm getting is... "[unixODBC][Driver Manager]Data source name 
not found, and no default driver specified." I really have searched high and 
low for a solution, but to no avail. Any thoughts?

Thanks in advance,
~Philip
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP + ODBC

2009-12-15 Thread Philip Thompson
On Dec 14, 2009, at 8:47 PM, James McLean wrote:

> On Tue, Dec 15, 2009 at 10:03 AM, Philip Thompson
>  wrote:
>> My head hurts from hitting it on my desk all day, so I thought I'd turn to a 
>> fresher set of eyes. The issue I'm having is getting PHP to connect ODBC. I 
>> can get it to work using isql from the command line. Can you verify my 
>> settings:
>> 
> [snipped]
>> 
>> I've tried the above DSNs and many other versions of it ad nauseum. The 
>> specific error I'm getting is... "[unixODBC][Driver Manager]Data source name 
>> not found, and no default driver specified." I really have searched high and 
>> low for a solution, but to no avail. Any thoughts?
> 
> Why not just use the built in MySQL libraries or PDO?

Oh, that would be "my" preference. However, the database that I really need to 
connect to is an MSSQL one and the allowed connection type is ODBC. I was just 
testing first with a MySQL connection to get it working (I don't have the MSSQL 
credentials yet). Turned out I was VERY close with my solution, which a 
coworker figured out this morning. The [ODBC Data Sources] entry for MySQL 
needed to specified correctly in /etc/odbc.ini.

[ODBC Data Sources]
MySQL = MySQL

[MySQL]
Description...
Driver...

I could have sworn I tried that, but who knows

Thank you!
~Philip
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Best ajax library

2009-12-15 Thread Philip Thompson
On Dec 15, 2009, at 3:12 AM, Joseph Masoud wrote:

> On 15 Dec 2009, at 08:50, Ali Asghar Toraby Parizy 
>  wrote:
> 
>> Which one is more active than others? I mean which project extends
>> faster and better, in future?
>> 
>> On Tue, Dec 15, 2009 at 1:37 AM, Philip Thompson  
>> wrote:
>>> On Dec 14, 2009, at 4:27 AM, Ali Asghar Toraby Parizy wrote:
>>> 
>>>> Hi
>>>> I think the best choice is jquery until now.
>>>> But, is it reasonable to combine jquery and other library to client
>>>> side and server side scripting respectively?
>>>> By the way, where i can find good lessons about jquery and php?
>>> 
>>> I really like this js library.
>>> 
>>> http://mootools.net/
>>> 
>>> It's based off of jquery or prototype... I can't remember.
>>> 
>>> ~Philip
>>> 
> JQuery and Mootools are two very different approaches of creating a 
> JavaScript framework. Both shine in different ways.
> 
> I use JQuery when I want to get things done quickly (using the Yii framework 
> or on custom projects).  I use mootols when I develop Joomla! Extensions and 
> it's amazing.  Which is more suitable boils down to what your project needs.
> 
> I'm messing around with Ext at the moment and it's really nice too!
> 
> The ultimate answer to your question is; "it depends". 

Along those lines of "it depends"... to my knowledge, most of the larger/more 
popular js frameworks consider other libraries when being developed. Meaning, 
the chances of a naming conflict are lowered. Not that I recommend it, but it 
does allow for using multiple libraries for a single project - that's another 
thread.

I can't speak for the other libraries, but I know that MooTools is constantly 
being updated and improved. I doubt that it will be leaving anytime soon. Check 
out some extended functionality of MooTools... Clientcide. It's created by the 
same author of MooTools to work with it.

http://www.clientcide.com/

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



  1   2   3   4   >