Re: [PHP] Saving server side file to local machine with JS

2009-07-27 Thread Thijs Lensselink
Skip Evans wrote:
> Sorry, I should have been clearer.
> 
> When PHP finishes creating the file I need one of the JS alert type
> windows to appear that says..
> 
> "Your file has completed, would you like to save it to your machine?"
> 
> Like you get when you download a file.
> 
> If I knew the JS code to do this I perhaps could embed it in the PHP at
> the end of the function that creates the file???
> 
> Is that clearer?
> 
> Thanks,
> Skip

Not sure if you can save it directly From javascript!

What you could do is.

1. Make an asynchrome call to a php script on the server with javascript.

2. Once PHP is finished you can make it return a URL to the asynchrome
javascript call. This URl will point to the generated download file.

3. Then with javascript create a nice div with two buttons. One to
initiate the download and the other to cancel...


> 
> 
> Paul M Foster wrote:
>> On Sun, Jul 26, 2009 at 09:55:14PM -0500, Skip Evans wrote:
>>
>>> Okay, I know I've done this before, but now I'm blanking out.
>>>
>>> I have code that creates a CSV file, and when it's done I want
>>> a JS alert to pop up and let them save the file.
>>>
>>> Isn't this some kind of alert() type call on the JS side???
>>>
>>> I know I've done this before and I've been on Google an hour now!
>>
>> Not sure I understand your question, but there is a function called
>> alert() in javascript. It opens a window with your error message in it.
>>
>> I don't know of a way to trigger this from PHP, since PHP is server-side
>> and Javascript is client-side. You might be able to have javascript scan
>> for the existence/closing of the file in question and then alert the
>> user. Or you could have PHP, when the file is complete, launch a new
>> page which contains the javascript code to alert the user.
>>
>> Paul
>>
> 


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



Re: [PHP] open source forum

2009-07-27 Thread mrfroasty
Thanks for the input, after playing around the choicesI think I
might go for SMF.
Looks pretty cool software, So far I have checked Phorum, phpBB and SMF
only.

The only negative thing I can tell so far is there is no gettext
infrastructure on SMF or phorum...but atleast there is a means to
translate the sofware :-)

GR
mrfroasty



K. N. Lesmer wrote:
> On Sun, 26 Jul 2009 14:50:03 +0200
> mrfroasty  wrote:
>
>   
>> Hello,
>>
>> I need some advice in picking a PHP forum for a group of people, I
>> know there are couple of them but could somebody from here give
>> advice on which one to choose.
>>
>> ***My strongest requirements I need localization support, as that
>> software might need to be translated into a language other than
>> English. ***Also the software should be a little bit easy to use,
>> interms of administration as the clients computer literacy isnt so
>> high enough. ***LAMP based software please :-)
>> ***ofcourse open source software... :-P
>>
>> I know this phpBB, but what are other options?I have never played
>> with a forum before.
>> 
>
> I can strongly recommend Phorum (http://www.phorum.org/).
>
>   
>> Thanks for the input...
>>
>> GR
>> mrfroasty
>>
>> -- 
>> Extra details:
>> OSS:Gentoo Linux
>> profile:x86
>> Hardware:msi geforce 8600GT asus p5k-se
>> location:/home/muhsin
>> language(s):C/C++,VB,VHDL,bash,PHP,SQL,HTML,CSS
>> Typo:40WPM
>> url:http://www.mzalendo.net
>>
>>
>> -- 
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>> 
>
>
> ---
> Mange venlige hilsner/Best regards
>
> Kim Naim Lesmer
> Programmer/Unix systemadministrator
>
> Web: www.bitflop.com
> E-mail : k...@bitflop.com
>
>
>   


-- 
Extra details:
OSS:Gentoo Linux
profile:x86
Hardware:msi geforce 8600GT asus p5k-se
location:/home/muhsin
language(s):C/C++,VB,VHDL,bash,PHP,SQL,HTML,CSS
Typo:40WPM
url:http://www.mzalendo.net



RE: [PHP] open source forum

2009-07-27 Thread Bob McConnell
From: mrfroasty

> I need some advice in picking a PHP forum for a group of people, I
know
> there are couple of them but could somebody from here give advice on
> which one to choose.

Your request is a bit open ended. Are you looking for blogs, wiki,
message based, or what?

A couple of years ago we set up Dokuwiki as a grass roots effort in the
development group. In just over a year we had 1100 pages created. It was
so popular that management got into the act and decided to replace it
with an officially supported Confluence server. Very few of us
considered that an upgrade, but that's what happens when the PHB's get
involved.

I maintained the Dokuwiki server on a Red Hat system. It took about 30
minutes a week to keep up. It's all PHP, with numerous add-on features
and capabilities.

Bob McConnell

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



[PHP] More on "JS alert that links to file"

2009-07-27 Thread tony mount
I have a question that follows on from this discussion. I have a loop
which creates a number of files. It first write each file to a server
location then sets up the headers and asks the "Save As" question. This
works OK once, but after the first download it exits without any errors
or messages. If I remove the header() lines (ie just create the files on
the server) no worries, it creates them all. (I start op buffer at the
top of the code and flush the buffer on each loop). Anyone have any
ideas please?
Thanks
Tony 


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



Re: [PHP] More on "JS alert that links to file"

2009-07-27 Thread Ashley Sheridan
I assume you want to force the files to the user as a series of files to
download? Have you considered just offering a page of links to each
file? You can actually have the links go to a PHP script which can
stream the file as a forced download, and the user can then download the
files one-by-one by clicking the link as if it were a normal link.
Alternatively, you could zip the files up into one archive using PHP and
offer stream that file down to the user.

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

On Mon, 2009-07-27 at 21:54 +0930, tony mount wrote:
> I have a question that follows on from this discussion. I have a loop
> which creates a number of files. It first write each file to a server
> location then sets up the headers and asks the "Save As" question. This
> works OK once, but after the first download it exits without any errors
> or messages. If I remove the header() lines (ie just create the files on
> the server) no worries, it creates them all. (I start op buffer at the
> top of the code and flush the buffer on each loop). Anyone have any
> ideas please?
> Thanks
> Tony 
> 
> 


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



[PHP] How to pull window to the foreground - Window Focus

2009-07-27 Thread WebPat
I have a web page with a button that displays additional information for 
the user. It does a Window.Open to create a "popup" window, then 
populates it.


If the user goes back to the web page without closing the window, it 
often goes behind the browser and is not visible (which is not the 
problem). But if the user selects the button again, nothing appears to 
happen because the window remains behind the browser, although it is 
updated.


The popup window has its own source file that populates it. I'd like to 
add a Window.Focus at the end of the population process. That should 
move the popup window to the foreground whenever it is refreshed. I 
can't get the code to actually do that. How can I make that popup window 
have focus?


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



Re: [PHP] JS alert that links to a file

2009-07-27 Thread Skip Evans

Hey all,

With LinuxMan's help I got this working. It was a bit tricky 
as it's an AJAX environment, but what I did was create a 
separate page with code similar to what he has below and then 
call it from the JS side and it works great.


Thanks all, and especially LinuxManMikeC for the key!

Skip

Skip Evans wrote:

LinuxManMikeC wrote:






Okay, right, I remember this.

But it has to be in it's own file, otherwise you get the 'headers 
already sent error', right?


Is there any way around that? Any way to get it right at the end of 
where the file is created???


Thanks!
Skip



--

Skip Evans
Big Sky Penguin, LLC
503 S Baldwin St, #1
Madison WI 53703
608.250.2720
http://bigskypenguin.com

Those of you who believe in
telekinesis, raise my hand.
 -- Kurt Vonnegut

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



Re: [PHP] Question on code profiling

2009-07-27 Thread Andrew Ballard
On Sat, Jul 25, 2009 at 1:31 AM, Daniel Kolbo wrote:
> Andrew Ballard wrote:
>> On Thu, Jul 23, 2009 at 11:31 PM, Andrew Ballard wrote:
>>> From what I can tell, the numbers I see in WinCacheGrind
>>> look like they are off by about a factor of 10 pretty
>>> uniformly.
>>>
>>> Andrew
>>>
>>
>> Apparently the difference is indeed WinCacheGrind, as a number of
>> other people have left comments on the project site that the values it
>> reports need to be multiplied by 10. Now that I know the numbers are
>> "right" comes the fun part.  :-\
>>
>> Andrew
>>
> Is this factor of 10 business only for ZF on Windows IIS or for Linux too?
> thanks,
> dK
> `
>

It seems to be just an error in WinCacheGrind itself. It looks like
the "current" release was published more than 4 years ago, and the
latest post to the project feed was 8 months ago. There are even a
couple posts in the project feed that say you have to multiply
whatever time it displays by 10. I didn't notice the feed section
initially since I found the download link by following a link from the
xdebug site.

As for the performance of ZF itself, I have been extremely
disappointed with it running under the couple of Windows hosts I have
tried. I have had much better success with the couple sites I used it
with that were on shared hosting accounts using Linux servers.

Andrew

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



Re: [PHP] How to pull window to the foreground - Window Focus

2009-07-27 Thread Bastien Koert
On Mon, Jul 27, 2009 at 8:31 AM, WebPat wrote:
> I have a web page with a button that displays additional information for the
> user. It does a Window.Open to create a "popup" window, then populates it.
>
> If the user goes back to the web page without closing the window, it often
> goes behind the browser and is not visible (which is not the problem). But
> if the user selects the button again, nothing appears to happen because the
> window remains behind the browser, although it is updated.
>
> The popup window has its own source file that populates it. I'd like to add
> a Window.Focus at the end of the population process. That should move the
> popup window to the foreground whenever it is refreshed. I can't get the
> code to actually do that. How can I make that popup window have focus?
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


in the body tag add an onfocus event



-- 

Bastien

Cat, the other other white meat

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



Re: [PHP] How to pull window to the foreground - Window Focus

2009-07-27 Thread WebPat

Bastien Koert wrote:

On Mon, Jul 27, 2009 at 8:31 AM, WebPat wrote:

I have a web page with a button that displays additional information for the
user. It does a Window.Open to create a "popup" window, then populates it.

If the user goes back to the web page without closing the window, it often
goes behind the browser and is not visible (which is not the problem). But
if the user selects the button again, nothing appears to happen because the
window remains behind the browser, although it is updated.

The popup window has its own source file that populates it. I'd like to add
a Window.Focus at the end of the population process. That should move the
popup window to the foreground whenever it is refreshed. I can't get the
code to actually do that. How can I make that popup window have focus?

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





in the body tag add an onfocus event





That was just what I need. Thanks.
However, I first tried it in Firefox and it did not work.
Eventually gave it a try in IE7 and it works just fine! Maybe something 
wrong with Firefox. I have Firebug available in Firefox. It reported 
"Prototype undefined" for this event. Not sure if that means in Firebug 
or Firefox.

Anyway, I'll leave it at that and be happy with your help. Thanks again.

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



[PHP] Imposing a range on what is stored in a session variable

2009-07-27 Thread Miller, Terion
I want to store only 1000 records at a time in the session variable thought I 
could use a range(1,1000

How would you do this, store the first 1000 , then the second on refresh etc

My snippet so far

---
// Process all results into 
$_SESSION array 
  $position = 1;
while ($row = mysql_fetch_array($result))   
   {  
$_SESSION['fullRestaurantList'][$position] = $row;  
$position++;
 foreach(range('1','1000') as $c){  
 ($position == $c)

$_SESSION['totalNumberOfRestaurants'] = $c; 
 }  
  }

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



RE: [PHP] More on "JS alert that links to file"

2009-07-27 Thread kyle.smith
You really can't send multiple files in a single response, and you certainly 
can't send multiple headers after data has gone through.

Zipping would be a nice approach.  Another would be to use AJAX calls to 
sequenctially download the files.

HTH,
- Kyle


-Original Message-
From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk]
Sent: Mon 7/27/2009 8:30 AM
To: tony mount
Cc: php-general@lists.php.net
Subject: Re: [PHP] More on "JS alert that links to file"
 
I assume you want to force the files to the user as a series of files to
download? Have you considered just offering a page of links to each
file? You can actually have the links go to a PHP script which can
stream the file as a forced download, and the user can then download the
files one-by-one by clicking the link as if it were a normal link.
Alternatively, you could zip the files up into one archive using PHP and
offer stream that file down to the user.

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

On Mon, 2009-07-27 at 21:54 +0930, tony mount wrote:
> I have a question that follows on from this discussion. I have a loop
> which creates a number of files. It first write each file to a server
> location then sets up the headers and asks the "Save As" question. This
> works OK once, but after the first download it exits without any errors
> or messages. If I remove the header() lines (ie just create the files on
> the server) no worries, it creates them all. (I start op buffer at the
> top of the code and flush the buffer on each loop). Anyone have any
> ideas please?
> Thanks
> Tony 
> 
> 


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




Re: [PHP] Imposing a range on what is stored in a session variable

2009-07-27 Thread Bastien Koert
On Mon, Jul 27, 2009 at 10:30 AM, Miller,
Terion wrote:
> I want to store only 1000 records at a time in the session variable thought I 
> could use a range(1,1000
>
> How would you do this, store the first 1000 , then the second on refresh etc
>
> My snippet so far
>
> ---
>                                            // Process all results into 
> $_SESSION array                                                               
>         $position = 1;                                                        
>                     while ($row = mysql_fetch_array($result))                 
>                      {                                      
> $_SESSION['fullRestaurantList'][$position] = $row;                            
>           $position++;                                                        
>                      foreach(range('1','1000') as $c){                        
>                            ($position == $c)
>                                                    
> $_SESSION['totalNumberOfRestaurants'] = $c;                                   
>    }                                                                          
>                                                                           }
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Teri,

Do you really need that data to persist? This will not scale effectively.
-- 

Bastien

Cat, the other other white meat


Re: [PHP] More on "JS alert that links to file"

2009-07-27 Thread Jim Lucas
tony mount wrote:
> I have a question that follows on from this discussion. I have a loop
> which creates a number of files. It first write each file to a server
> location then sets up the headers and asks the "Save As" question. This
> works OK once, but after the first download it exits without any errors
> or messages. If I remove the header() lines (ie just create the files on
> the server) no worries, it creates them all. (I start op buffer at the
> top of the code and flush the buffer on each loop). Anyone have any
> ideas please?
> Thanks
> Tony 
> 
> 

Tony,

Ashley's answer is correct.  But the one thing she didn't is that what
you are doing is NOT possible.

You can only send your set of header()s once, then all content that
follows until an exit, die, or end of script happens.



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



Re: [PHP] How to pull window to the foreground - Window Focus

2009-07-27 Thread Andrew Ballard
On Mon, Jul 27, 2009 at 10:26 AM, WebPat wrote:
> Bastien Koert wrote:
>>
>> On Mon, Jul 27, 2009 at 8:31 AM, WebPat wrote:
>>>
>>> I have a web page with a button that displays additional information for
>>> the
>>> user. It does a Window.Open to create a "popup" window, then populates
>>> it.
>>>
>>> If the user goes back to the web page without closing the window, it
>>> often
>>> goes behind the browser and is not visible (which is not the problem).
>>> But
>>> if the user selects the button again, nothing appears to happen because
>>> the
>>> window remains behind the browser, although it is updated.
>>>
>>> The popup window has its own source file that populates it. I'd like to
>>> add
>>> a Window.Focus at the end of the population process. That should move the
>>> popup window to the foreground whenever it is refreshed. I can't get the
>>> code to actually do that. How can I make that popup window have focus?
>>>
>>
>>
>> in the body tag add an onfocus event
>>
>> 
>>
>
> That was just what I need. Thanks.
> However, I first tried it in Firefox and it did not work.
> Eventually gave it a try in IE7 and it works just fine! Maybe something
> wrong with Firefox. I have Firebug available in Firefox. It reported
> "Prototype undefined" for this event. Not sure if that means in Firebug or
> Firefox.
> Anyway, I'll leave it at that and be happy with your help. Thanks again.
>

A lot of sites are moving to simulated dialog windows inside the page.
They have a few nice benefits:

1) Since they aren't real windows, they do not interfere with other
tabs or windows you have open in your browser.

2) Since they are actually part of the page itself, they will always
either stay on top of the other page elements or else they will
automatically close (whichever effect is desired).

3) They are not actual pop-up windows, so they won't be blocked by
pop-up blockers.


Granted, they depend on JavaScript, but then so did your other approach.


http://www.google.com/search?q=div+popup+window


Andrew

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



RE: [PHP] More on "JS alert that links to file"

2009-07-27 Thread Ashley Sheridan
On Mon, 2009-07-27 at 10:30 -0400, kyle.smith wrote:
> You really can't send multiple files in a single response, and you certainly 
> can't send multiple headers after data has gone through.
> 
> Zipping would be a nice approach.  Another would be to use AJAX calls to 
> sequenctially download the files.
> 
> HTH,
> - Kyle
> 
> 
> -Original Message-
> From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk]
> Sent: Mon 7/27/2009 8:30 AM
> To: tony mount
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] More on "JS alert that links to file"
>  
> I assume you want to force the files to the user as a series of files to
> download? Have you considered just offering a page of links to each
> file? You can actually have the links go to a PHP script which can
> stream the file as a forced download, and the user can then download the
> files one-by-one by clicking the link as if it were a normal link.
> Alternatively, you could zip the files up into one archive using PHP and
> offer stream that file down to the user.
> 
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
> 
> On Mon, 2009-07-27 at 21:54 +0930, tony mount wrote:
> > I have a question that follows on from this discussion. I have a loop
> > which creates a number of files. It first write each file to a server
> > location then sets up the headers and asks the "Save As" question. This
> > works OK once, but after the first download it exits without any errors
> > or messages. If I remove the header() lines (ie just create the files on
> > the server) no worries, it creates them all. (I start op buffer at the
> > top of the code and flush the buffer on each loop). Anyone have any
> > ideas please?
> > Thanks
> > Tony 
> > 
> > 
> 
> 

That's why I suggested offering a page of links rather than whatever he
was trying before.

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


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



Re: [PHP] More on "JS alert that links to file"

2009-07-27 Thread Ashley Sheridan
On Mon, 2009-07-27 at 07:34 -0700, Jim Lucas wrote:
> tony mount wrote:
> > I have a question that follows on from this discussion. I have a loop
> > which creates a number of files. It first write each file to a server
> > location then sets up the headers and asks the "Save As" question. This
> > works OK once, but after the first download it exits without any errors
> > or messages. If I remove the header() lines (ie just create the files on
> > the server) no worries, it creates them all. (I start op buffer at the
> > top of the code and flush the buffer on each loop). Anyone have any
> > ideas please?
> > Thanks
> > Tony 
> > 
> > 
> 
> Tony,
> 
> Ashley's answer is correct.  But the one thing she didn't is that what
> you are doing is NOT possible.
> 
> You can only send your set of header()s once, then all content that
> follows until an exit, die, or end of script happens.
> 
> 
> 
For the record, I'm still a he ;)

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


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



Re: [PHP] More on "JS alert that links to file"

2009-07-27 Thread Andrew Ballard
On Mon, Jul 27, 2009 at 10:34 AM, Jim Lucas wrote:
> Ashley's answer is correct.  But the one thing she ...

He.

Andrew

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



Re: [PHP] Imposing a range on what is stored in a session variable

2009-07-27 Thread Jim Lucas
Miller, Terion wrote:
> I want to store only 1000 records at a time in the session variable thought I 
> could use a range(1,1000
> 
> How would you do this, store the first 1000 , then the second on refresh etc
> 
> My snippet so far
> 
> ---
> // Process all results into 
> $_SESSION array   
> $position = 1;
> while ($row = mysql_fetch_array($result)) 
>  {  
> $_SESSION['fullRestaurantList'][$position] = $row;
>   $position++;
>  foreach(range('1','1000') as $c){
>($position == $c)
> 
> $_SESSION['totalNumberOfRestaurants'] = $c;   
>}  
>   }
> 

Use the mysql function for this called LIMIT.  It LIMITs the amount of
data returned.

SELECT * FROM table_name LIMIT 1000

1. it will make your SQL calls much faster
2. it will use less memory



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



Re: [PHP] More on "JS alert that links to file"

2009-07-27 Thread Jim Lucas
Ashley Sheridan wrote:
> On Mon, 2009-07-27 at 07:34 -0700, Jim Lucas wrote:
>> tony mount wrote:
>>> I have a question that follows on from this discussion. I have a loop
>>> which creates a number of files. It first write each file to a server
>>> location then sets up the headers and asks the "Save As" question. This
>>> works OK once, but after the first download it exits without any errors
>>> or messages. If I remove the header() lines (ie just create the files on
>>> the server) no worries, it creates them all. (I start op buffer at the
>>> top of the code and flush the buffer on each loop). Anyone have any
>>> ideas please?
>>> Thanks
>>> Tony 
>>>
>>>
>> Tony,
>>
>> Ashley's answer is correct.  But the one thing she didn't is that what
>> you are doing is NOT possible.
>>
>> You can only send your set of header()s once, then all content that
>> follows until an exit, die, or end of script happens.
>>
>>
>>
> For the record, I'm still a he ;)
> 
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
> 

opps, my apologies!


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



Re: [PHP] More on "JS alert that links to file"

2009-07-27 Thread Ashley Sheridan
On Mon, 2009-07-27 at 07:43 -0700, Jim Lucas wrote:
> Ashley Sheridan wrote:
> > On Mon, 2009-07-27 at 07:34 -0700, Jim Lucas wrote:
> >> tony mount wrote:
> >>> I have a question that follows on from this discussion. I have a loop
> >>> which creates a number of files. It first write each file to a server
> >>> location then sets up the headers and asks the "Save As" question. This
> >>> works OK once, but after the first download it exits without any errors
> >>> or messages. If I remove the header() lines (ie just create the files on
> >>> the server) no worries, it creates them all. (I start op buffer at the
> >>> top of the code and flush the buffer on each loop). Anyone have any
> >>> ideas please?
> >>> Thanks
> >>> Tony 
> >>>
> >>>
> >> Tony,
> >>
> >> Ashley's answer is correct.  But the one thing she didn't is that what
> >> you are doing is NOT possible.
> >>
> >> You can only send your set of header()s once, then all content that
> >> follows until an exit, die, or end of script happens.
> >>
> >>
> >>
> > For the record, I'm still a he ;)
> > 
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> > 
> 
> opps, my apologies!
> 

Handbags at dawn!

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


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



Re: [PHP] Imposing a range on what is stored in a session variable

2009-07-27 Thread Miller, Terion
Well there are currently about 17000 records in the db, and my manager wants to 
have it only pulling in 1000 at a time as a session range
And why do my code snippets always look so messed up , I put them in using the 
rich text or html settings in my Entourage mail...
They look fine when I send them and then crazy when I see them on a post 
reply...
Anyways...it's one of those mondays where when we left on Friday all our pages 
were working brilliant and now they are all doing strange things, like trying 
to save instead of open
And boss thinks it's the server strain and we need ranged sessions...would my 
thinking on using the foreach(range work though?



On 7/27/09 9:34 AM, "Bastien Koert"  wrote:

On Mon, Jul 27, 2009 at 10:30 AM, Miller,
Terion wrote:
> I want to store only 1000 records at a time in the session variable thought I 
> could use a range(1,1000
>
> How would you do this, store the first 1000 , then the second on refresh etc
>
> My snippet so far
>
> ---
>// Process all results into 
> $_SESSION array   
> $position = 1;
> while ($row = mysql_fetch_array($result)) 
>  {  
> $_SESSION['fullRestaurantList'][$position] = $row;
>   $position++;
>  foreach(range('1','1000') as $c){
>($position == $c)
>
> $_SESSION['totalNumberOfRestaurants'] = $c;   
>}  
>   }
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Teri,

Do you really need that data to persist? This will not scale effectively.
--

Bastien

Cat, the other other white meat



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



Re: [PHP] Imposing a range on what is stored in a session variable

2009-07-27 Thread Miller, Terion



On 7/27/09 9:40 AM, "Jim Lucas"  wrote:

Miller, Terion wrote:
> I want to store only 1000 records at a time in the session variable thought I 
> could use a range(1,1000
>
> How would you do this, store the first 1000 , then the second on refresh etc
>
> My snippet so far
>
> ---
> // Process all results into 
> $_SESSION array   
> $position = 1;
> while ($row = mysql_fetch_array($result)) 
>  {  
> $_SESSION['fullRestaurantList'][$position] = $row;
>   $position++;
>  foreach(range('1','1000') as $c){
>($position == $c)
> 
> $_SESSION['totalNumberOfRestaurants'] = $c;   
>}  
>   }
>

Use the mysql function for this called LIMIT.  It LIMITs the amount of
data returned.

SELECT * FROM table_name LIMIT 1000

1. it will make your SQL calls much faster
2. it will use less memory




But that limits results right, if a query generated more then 1000 records how 
would a user be able to access 1001 ..put the query in a loop?

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



Re: [PHP] Imposing a range on what is stored in a session variable

2009-07-27 Thread Bastien Koert
On Mon, Jul 27, 2009 at 10:44 AM, Miller,
Terion wrote:
> Well there are currently about 17000 records in the db, and my manager wants 
> to have it only pulling in 1000 at a time as a session range
> And why do my code snippets always look so messed up , I put them in using 
> the rich text or html settings in my Entourage mail...
> They look fine when I send them and then crazy when I see them on a post 
> reply...
> Anyways...it's one of those mondays where when we left on Friday all our 
> pages were working brilliant and now they are all doing strange things, like 
> trying to save instead of open
> And boss thinks it's the server strain and we need ranged sessions...would my 
> thinking on using the foreach(range work though?
>
>
>
> On 7/27/09 9:34 AM, "Bastien Koert"  wrote:
>
> On Mon, Jul 27, 2009 at 10:30 AM, Miller,
> Terion wrote:
>> I want to store only 1000 records at a time in the session variable thought 
>> I could use a range(1,1000
>>
>> How would you do this, store the first 1000 , then the second on refresh etc
>>
>> My snippet so far
>>
>> ---
>>                                            // Process all results into 
>> $_SESSION array                                                              
>>          $position = 1;                                                      
>>                       while ($row = mysql_fetch_array($result))              
>>                         {                                      
>> $_SESSION['fullRestaurantList'][$position] = $row;                           
>>            $position++;                                                      
>>                        foreach(range('1','1000') as $c){                     
>>                               ($position == $c)
>>                                                    
>> $_SESSION['totalNumberOfRestaurants'] = $c;                                  
>>     }                                                                        
>>                                                                             }
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
>
> Teri,
>
> Do you really need that data to persist? This will not scale effectively.
> --
>
> Bastien
>
> Cat, the other other white meat
>
>
>

I would page the data with the LIMIT call as Jim suggested. What is
the user doing with 1K records and how are they getting 1K records?

-- 

Bastien

Cat, the other other white meat

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



Re: [PHP] Imposing a range on what is stored in a session variable

2009-07-27 Thread Ashley Sheridan
On Mon, 2009-07-27 at 07:44 -0700, Miller, Terion wrote:
> Well there are currently about 17000 records in the db, and my manager wants 
> to have it only pulling in 1000 at a time as a session range
> And why do my code snippets always look so messed up , I put them in using 
> the rich text or html settings in my Entourage mail...
> They look fine when I send them and then crazy when I see them on a post 
> reply...
> Anyways...it's one of those mondays where when we left on Friday all our 
> pages were working brilliant and now they are all doing strange things, like 
> trying to save instead of open
> And boss thinks it's the server strain and we need ranged sessions...would my 
> thinking on using the foreach(range work though?
> 
> 
> 
> On 7/27/09 9:34 AM, "Bastien Koert"  wrote:
> 
> On Mon, Jul 27, 2009 at 10:30 AM, Miller,
> Terion wrote:
> > I want to store only 1000 records at a time in the session variable thought 
> > I could use a range(1,1000
> >
> > How would you do this, store the first 1000 , then the second on refresh etc
> >
> > My snippet so far
> >
> > ---
> >// Process all results into 
> > $_SESSION array 
> >   $position = 1;
> > while ($row = mysql_fetch_array($result))   
> >{  
> > $_SESSION['fullRestaurantList'][$position] = $row;  
> > $position++;
> >  foreach(range('1','1000') as $c){  
> >  ($position == $c)
> >
> > $_SESSION['totalNumberOfRestaurants'] = $c; 
> >  }  
> > 
> >   }
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> 
> 
> Teri,
> 
> Do you really need that data to persist? This will not scale effectively.
> --
> 
> Bastien
> 
> Cat, the other other white meat
> 
> 
> 

The clue to the email formatting is in the list rules if I'm not
mistaken. I believe they say something about sending emails as plain
text, not formatted text, and in any case, the mailing list converts
them all to plain text anyway, hence the messed up appearance.

As to your question, why does your boss think that sessions are the way
to go for this? Doing the limit in the query will be a lot faster and
will need less memory.

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


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



Re: [PHP] Imposing a range on what is stored in a session variable

2009-07-27 Thread Miller, Terion



=snipped
>

I would page the data with the LIMIT call as Jim suggested. What is
the user doing with 1K records and how are they getting 1K records?

--

Bastien

Cat, the other other white meat


Here is a link to the code at PasteBin

It's a db full of the town's restaurant inspections that users can look at to 
see what places have violations etc

http://pastebin.ca/1504393

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



Re: [PHP] Imposing a range on what is stored in a session variable

2009-07-27 Thread Bastien Koert
On Mon, Jul 27, 2009 at 10:54 AM, Miller,
Terion wrote:
>
>
>
> =snipped
>>
>
> I would page the data with the LIMIT call as Jim suggested. What is
> the user doing with 1K records and how are they getting 1K records?
>
> --
>
> Bastien
>
> Cat, the other other white meat
>
>
> Here is a link to the code at PasteBin
>
> It's a db full of the town's restaurant inspections that users can look at to 
> see what places have violations etc
>
> http://pastebin.ca/1504393
>


So this is a report that is being run on the data at any particular
moment in time. Is there criteria that can be used to limit the data
range for more efficient queries like:
1. must be in a certain neighborhood or zip code

You should look at paging the data here with the OFFSET portion of the
limit clause

Select * from restaurant [where clause]limit 1000, $offset

where the $offset value can tell you where to start in the 17K rows of
data so that in effect you show records 1-1000, 1001-2000,
2001-3000...then on the page, just provide a set of links of navigate
the recordset by the user  [ << < 1-1000 1001-2000 2001-3000 > >> ]


-- 

Bastien

Cat, the other other white meat

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



Re: [PHP] Imposing a range on what is stored in a session variable

2009-07-27 Thread Shawn McKenzie
Miller, Terion wrote:
> 
> 
> On 7/27/09 9:40 AM, "Jim Lucas"  wrote:
> 
> Miller, Terion wrote:
>> I want to store only 1000 records at a time in the session variable thought 
>> I could use a range(1,1000
>>
>> How would you do this, store the first 1000 , then the second on refresh etc
>>
>> My snippet so far
>>
>> ---
>> // Process all results into 
>> $_SESSION array  
>>  $position = 1;  
>>   while ($row = mysql_fetch_array($result))  
>> {  
>> $_SESSION['fullRestaurantList'][$position] = $row;   
>>$position++;  
>>foreach(range('1','1000') as $c){ 
>>   ($position == $c)
>> 
>> $_SESSION['totalNumberOfRestaurants'] = $c;  
>> }
>> }
>>
> 
> Use the mysql function for this called LIMIT.  It LIMITs the amount of
> data returned.
> 
> SELECT * FROM table_name LIMIT 1000
> 
> 1. it will make your SQL calls much faster
> 2. it will use less memory
> 
> 
> 
> 
> But that limits results right, if a query generated more then 1000 records 
> how would a user be able to access 1001 ..put the query in a loop?

Bastien gave you all the info:

You should look at paging the data here with the OFFSET portion of the
limit clause

Select * from restaurant [where clause]limit 1000, $offset

where the $offset value can tell you where to start in the 17K rows of
data so that in effect you show records 1-1000, 1001-2000,
2001-3000...then on the page, just provide a set of links of navigate
the recordset by the user  [ << < 1-1000 1001-2000 2001-3000 > >> ]

***

So you would generate page that had the first 1000 records and a Next >
link that linked maybe to the same page with ?start=1001.  Then use the
$_GET['start'] to generate the next set of results staring at 1001.


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

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



Re: [PHP] Imposing a range on what is stored in a session variable

2009-07-27 Thread Jim Lucas
Miller, Terion wrote:
> 
> 
> On 7/27/09 9:40 AM, "Jim Lucas"  wrote:
> 
> Miller, Terion wrote:
>> I want to store only 1000 records at a time in the session variable thought 
>> I could use a range(1,1000
>>
>> How would you do this, store the first 1000 , then the second on refresh etc
>>
>> My snippet so far
>>
>> ---
>> // Process all results into 
>> $_SESSION array  
>>  $position = 1;  
>>   while ($row = mysql_fetch_array($result))  
>> {  
>> $_SESSION['fullRestaurantList'][$position] = $row;   
>>$position++;  
>>foreach(range('1','1000') as $c){ 
>>   ($position == $c)
>> 
>> $_SESSION['totalNumberOfRestaurants'] = $c;  
>> }
>> }
>>
> 
> Use the mysql function for this called LIMIT.  It LIMITs the amount of
> data returned.
> 
> SELECT * FROM table_name LIMIT 1000
> 
> 1. it will make your SQL calls much faster
> 2. it will use less memory
> 
> 
> 
> 
> But that limits results right, if a query generated more then 1000 records 
> how would a user be able to access 1001 ..put the query in a loop?

Why don't you read the docs on it and find out.

http://dev.mysql.com/doc/refman/5.1/en/select.html


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



Re: [PHP] Imposing a range on what is stored in a session variable

2009-07-27 Thread Bastien Koert
On Mon, Jul 27, 2009 at 11:25 AM, Shawn McKenzie wrote:
> Miller, Terion wrote:
>>
>>
>> On 7/27/09 9:40 AM, "Jim Lucas"  wrote:
>>
>> Miller, Terion wrote:
>>> I want to store only 1000 records at a time in the session variable thought 
>>> I could use a range(1,1000
>>>
>>> How would you do this, store the first 1000 , then the second on refresh etc
>>>
>>> My snippet so far
>>>
>>> ---
>>>                                             // Process all results into 
>>> $_SESSION array                                                             
>>>           $position = 1;                                                    
>>>                         while ($row = mysql_fetch_array($result))           
>>>                            {                                      
>>> $_SESSION['fullRestaurantList'][$position] = $row;                          
>>>             $position++;                                                    
>>>                          foreach(range('1','1000') as $c){                  
>>>                                  ($position == $c)
>>>                                                     
>>> $_SESSION['totalNumberOfRestaurants'] = $c;                                 
>>>      }                                                                      
>>>                                                                             
>>>   }
>>>
>>
>> Use the mysql function for this called LIMIT.  It LIMITs the amount of
>> data returned.
>>
>> SELECT * FROM table_name LIMIT 1000
>>
>> 1. it will make your SQL calls much faster
>> 2. it will use less memory
>>
>>
>>
>>
>> But that limits results right, if a query generated more then 1000 records 
>> how would a user be able to access 1001 ..put the query in a loop?
>
> Bastien gave you all the info:
>
> You should look at paging the data here with the OFFSET portion of the
> limit clause
>
> Select * from restaurant [where clause]limit 1000, $offset
>
> where the $offset value can tell you where to start in the 17K rows of
> data so that in effect you show records 1-1000, 1001-2000,
> 2001-3000...then on the page, just provide a set of links of navigate
> the recordset by the user  [ << < 1-1000 1001-2000 2001-3000 > >> ]
>
> ***
>
> So you would generate page that had the first 1000 records and a Next >
> link that linked maybe to the same page with ?start=1001.  Then use the
> $_GET['start'] to generate the next set of results staring at 1001.
>
>
> --
> Thanks!
> -Shawn
> http://www.spidean.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

correct

-- 

Bastien

Cat, the other other white meat

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



Re: [PHP] How to pull window to the foreground - Window Focus

2009-07-27 Thread WebPat

Andrew Ballard wrote:


A lot of sites are moving to simulated dialog windows inside the page.
They have a few nice benefits:

1) Since they aren't real windows, they do not interfere with other
tabs or windows you have open in your browser.

2) Since they are actually part of the page itself, they will always
either stay on top of the other page elements or else they will
automatically close (whichever effect is desired).

3) They are not actual pop-up windows, so they won't be blocked by
pop-up blockers.


Granted, they depend on JavaScript, but then so did your other approach.


http://www.google.com/search?q=div+popup+window


Andrew


Thanks, I hadn't thought about that approach. It's certainly an alternative.
I think I have come across some of them on various sites, but I've found 
them to be quite disagreeable. As you scroll, they often scroll down, 
then float back to their assigned position. Weird. And they are usually 
blocking something that I want to see.


I don't know if what I'm doing is javascript or not. I never have that 
identifier on my web page. I do call the Window.Open (function?), so, if 
 that counts then yeah. But I like the separate window better. The user 
can more easily move it out of the way - even off the browser window - 
and continue reading the main page while referring to the popup window.
I'd actually like to allow the user to create multiple popup windows, 
which I create from buttons on my webpage, but right now they all go to 
the same window, and I've had enough trouble trying to get that to work. 
  I'm there now with that last Window.Focus detail - except that 
Firefox seems to be having a problem with that. But, I'm not going to 
worry about that. So, for now I'm good.


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



Re: [PHP] How to pull window to the foreground - Window Focus

2009-07-27 Thread Bastien Koert
On Mon, Jul 27, 2009 at 11:39 AM, WebPat wrote:
> Andrew Ballard wrote:
>>
>> A lot of sites are moving to simulated dialog windows inside the page.
>> They have a few nice benefits:
>>
>> 1) Since they aren't real windows, they do not interfere with other
>> tabs or windows you have open in your browser.
>>
>> 2) Since they are actually part of the page itself, they will always
>> either stay on top of the other page elements or else they will
>> automatically close (whichever effect is desired).
>>
>> 3) They are not actual pop-up windows, so they won't be blocked by
>> pop-up blockers.
>>
>>
>> Granted, they depend on JavaScript, but then so did your other approach.
>>
>>
>> http://www.google.com/search?q=div+popup+window
>>
>>
>> Andrew
>
> Thanks, I hadn't thought about that approach. It's certainly an alternative.
> I think I have come across some of them on various sites, but I've found
> them to be quite disagreeable. As you scroll, they often scroll down, then
> float back to their assigned position. Weird. And they are usually blocking
> something that I want to see.
>
> I don't know if what I'm doing is javascript or not. I never have that
> identifier on my web page. I do call the Window.Open (function?), so, if
>  that counts then yeah. But I like the separate window better. The user can
> more easily move it out of the way - even off the browser window - and
> continue reading the main page while referring to the popup window.
> I'd actually like to allow the user to create multiple popup windows, which
> I create from buttons on my webpage, but right now they all go to the same
> window, and I've had enough trouble trying to get that to work.  I'm there
> now with that last Window.Focus detail - except that Firefox seems to be
> having a problem with that. But, I'm not going to worry about that. So, for
> now I'm good.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

If they are all going to the same window, its likely that you have a
window.open function that names the window. When the window has a
name/id, then any subsequent calls to the window open command will
re-use the same window. if you remove the id attribute (the call is
usually window.open(url,id,parameters) and substitute an empty string
( '' ) then it should open new windows.

Back to the DIVs option, you can write js controls that make the
window dragable, hidable etc to improve the users enjoyment of the
page

-- 

Bastien

Cat, the other other white meat

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



Re: [PHP] How to pull window to the foreground - Window Focus

2009-07-27 Thread Andrew Ballard
On Mon, Jul 27, 2009 at 11:46 AM, Bastien Koert wrote:
> Back to the DIVs option, you can write js controls that make the
> window dragable, hidable etc to improve the users enjoyment of the
> page
>
> --
>
> Bastien
>

Some implementations are definitely better than others. Like any other
software, you just have to take some time to try out different
versions and find the one that has the features that you want for the
price you're willing to pay, or else try your hand at writing your
own.

Andrew

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



[PHP] Single Quotes in Form Inputs

2009-07-27 Thread Ben Miller
Hi,

 

I have a form in which my sales reps can add new clients into the database,
but I'm running into a problem if the client's name includes a single quote,
such as O'Henry, when it comes time to input the form data into the database
table.  I'm guessing I need to use ereg_replace, or something similar, to
change the single quote, but I still can't seem to get the syntax right.
Any help would be appreciated.  For what it's worth, here is a shortened
version of what I have:

 

$ firstName = "$_POST[form_firstName]";

$ lastname = "$_POST[form_lastName]";

 

$query = mysql_query("INSERT INTO customers (`cust_first`,`cust_last`)
VALUES ('$firstName','$lastName')");

 

Ben Miller

 



Re: [PHP] Single Quotes in Form Inputs

2009-07-27 Thread Mari Masuda
You need to sanitize and escape the input before inserting it into  
the db.  You can use http://us.php.net/mysql_real_escape_string to  
escape the input.


On Jul 27, 2009, at 09:35, Ben Miller wrote:


Hi,



I have a form in which my sales reps can add new clients into the  
database,
but I'm running into a problem if the client's name includes a  
single quote,
such as O'Henry, when it comes time to input the form data into the  
database
table.  I'm guessing I need to use ereg_replace, or something  
similar, to
change the single quote, but I still can't seem to get the syntax  
right.
Any help would be appreciated.  For what it's worth, here is a  
shortened

version of what I have:



$ firstName = "$_POST[form_firstName]";

$ lastname = "$_POST[form_lastName]";



$query = mysql_query("INSERT INTO customers (`cust_first`,`cust_last`)
VALUES ('$firstName','$lastName')");



Ben Miller






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



Re: [PHP] How to pull window to the foreground - Window Focus

2009-07-27 Thread WebPat

Bastien Koert wrote:

On Mon, Jul 27, 2009 at 11:39 AM, WebPat wrote:

Andrew Ballard wrote:

A lot of sites are moving to simulated dialog windows inside the page.
They have a few nice benefits:

1) Since they aren't real windows, they do not interfere with other
tabs or windows you have open in your browser.

2) Since they are actually part of the page itself, they will always
either stay on top of the other page elements or else they will
automatically close (whichever effect is desired).

3) They are not actual pop-up windows, so they won't be blocked by
pop-up blockers.


Granted, they depend on JavaScript, but then so did your other approach.


http://www.google.com/search?q=div+popup+window


Andrew

Thanks, I hadn't thought about that approach. It's certainly an alternative.
I think I have come across some of them on various sites, but I've found
them to be quite disagreeable. As you scroll, they often scroll down, then
float back to their assigned position. Weird. And they are usually blocking
something that I want to see.

I don't know if what I'm doing is javascript or not. I never have that
identifier on my web page. I do call the Window.Open (function?), so, if
 that counts then yeah. But I like the separate window better. The user can
more easily move it out of the way - even off the browser window - and
continue reading the main page while referring to the popup window.
I'd actually like to allow the user to create multiple popup windows, which
I create from buttons on my webpage, but right now they all go to the same
window, and I've had enough trouble trying to get that to work.  I'm there
now with that last Window.Focus detail - except that Firefox seems to be
having a problem with that. But, I'm not going to worry about that. So, for
now I'm good.

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




If they are all going to the same window, its likely that you have a
window.open function that names the window. When the window has a
name/id, then any subsequent calls to the window open command will
re-use the same window. if you remove the id attribute (the call is
usually window.open(url,id,parameters) and substitute an empty string
( '' ) then it should open new windows.

Back to the DIVs option, you can write js controls that make the
window dragable, hidable etc to improve the users enjoyment of the
page



You are correct, the Open names the window. That is done in the Onclick 
of the button and becomes the Target for an . I need a name for the 
Target. This works pretty good. I'm not sure many users would open more 
than one anyway - at least not without getting even more confused. 
Probably better.


I've tried to build this with Html and CSS, and just a little PHP.

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



Re: [PHP] Single Quotes in Form Inputs

2009-07-27 Thread Bastien Koert
On Mon, Jul 27, 2009 at 12:41 PM, Mari Masuda wrote:
> You need to sanitize and escape the input before inserting it into the db.
>  You can use http://us.php.net/mysql_real_escape_string to escape the input.
>
> On Jul 27, 2009, at 09:35, Ben Miller wrote:
>
>> Hi,
>>
>>
>>
>> I have a form in which my sales reps can add new clients into the
>> database,
>> but I'm running into a problem if the client's name includes a single
>> quote,
>> such as O'Henry, when it comes time to input the form data into the
>> database
>> table.  I'm guessing I need to use ereg_replace, or something similar, to
>> change the single quote, but I still can't seem to get the syntax right.
>> Any help would be appreciated.  For what it's worth, here is a shortened
>> version of what I have:
>>
>>
>>
>> $ firstName = "$_POST[form_firstName]";
>>
>> $ lastname = "$_POST[form_lastName]";
>>
>>
>>
>> $query = mysql_query("INSERT INTO customers (`cust_first`,`cust_last`)
>> VALUES ('$firstName','$lastName')");
>>
>>
>>
>> Ben Miller
>>
>>
>>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

I like to use http://ca3.php.net/manual/en/function.htmlentities.php

-- 

Bastien

Cat, the other other white meat

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



Re: [PHP] How to pull window to the foreground - Window Focus

2009-07-27 Thread Richard Heyes
Hi,

> A lot of sites are moving to simulated dialog windows inside the page.

There's an updated version of my ModalDialog included in RGraph which
does just this:

http://www.rgraph.net/docs/external.html

It covers the page in a semi transparent DIV to bring attention to
itself (the modal part). It beats the crappy confirm() dialogs. The
older version is here:

http://www.phpguru.org/static/Modal-Dialog.html

-- 
Richard Heyes
HTML5 graphing: RGraph - www.rgraph.net (updated 25th July)
Lots of PHP and Javascript code - http://www.phpguru.org

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



Re: [PHP] Single Quotes in Form Inputs

2009-07-27 Thread Michael A. Peters

Bastien Koert wrote:

On Mon, Jul 27, 2009 at 12:41 PM, Mari Masuda wrote:

You need to sanitize and escape the input before inserting it into the db.
 You can use http://us.php.net/mysql_real_escape_string to escape the input.

On Jul 27, 2009, at 09:35, Ben Miller wrote:


Hi,



I have a form in which my sales reps can add new clients into the
database,
but I'm running into a problem if the client's name includes a single
quote,
such as O'Henry, when it comes time to input the form data into the
database
table.  I'm guessing I need to use ereg_replace, or something similar, to
change the single quote, but I still can't seem to get the syntax right.
Any help would be appreciated.  For what it's worth, here is a shortened
version of what I have:



$ firstName = "$_POST[form_firstName]";

$ lastname = "$_POST[form_lastName]";



$query = mysql_query("INSERT INTO customers (`cust_first`,`cust_last`)
VALUES ('$firstName','$lastName')");



Ben Miller





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




I like to use http://ca3.php.net/manual/en/function.htmlentities.php



htmlentities should not be used on the data before it goes into the 
database. If used it should be used on data coming out of the database.


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



Re: [PHP] Single Quotes in Form Inputs

2009-07-27 Thread Jim Lucas
Michael A. Peters wrote:
> Bastien Koert wrote:
>> On Mon, Jul 27, 2009 at 12:41 PM, Mari Masuda
>> wrote:
>>> You need to sanitize and escape the input before inserting it into
>>> the db.
>>>  You can use http://us.php.net/mysql_real_escape_string to escape the
>>> input.
>>>
>>> On Jul 27, 2009, at 09:35, Ben Miller wrote:
>>>
 Hi,



 I have a form in which my sales reps can add new clients into the
 database,
 but I'm running into a problem if the client's name includes a single
 quote,
 such as O'Henry, when it comes time to input the form data into the
 database
 table.  I'm guessing I need to use ereg_replace, or something
 similar, to
 change the single quote, but I still can't seem to get the syntax
 right.
 Any help would be appreciated.  For what it's worth, here is a
 shortened
 version of what I have:



 $ firstName = "$_POST[form_firstName]";

 $ lastname = "$_POST[form_lastName]";



 $query = mysql_query("INSERT INTO customers (`cust_first`,`cust_last`)
 VALUES ('$firstName','$lastName')");



 Ben Miller



>>>
>>> -- 
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>
>> I like to use http://ca3.php.net/manual/en/function.htmlentities.php
>>
> 
> htmlentities should not be used on the data before it goes into the
> database. If used it should be used on data coming out of the database.
> 

To summarize:

You should prep your data for insertion into the data by using a tool
that formats it strictly for the database.  In the ops case
mysql_real_escape_string() is the correct tool for the job.

htmlentities() is a presentation sanitizing/cleaning tool.  But, it
should only be used for output to the browser, etc...  Same thing with
htmlspecialchars() and all other related function.



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



Re: [PHP] open source forum

2009-07-27 Thread mrfroasty
Sorry if I wasnt clear enough, but I was looking for forum or may be the
way you called it message board for people to discuss topics.
Mostly its going to be a political Forum where people discuss major
political topics/news about their country.

So basically my search ended up with SMF as a software to do the job.

I really appreciate the input

Cheers.

GR
Mrfroasty



Bob McConnell wrote:
> From: mrfroasty
>
>   
>> I need some advice in picking a PHP forum for a group of people, I
>> 
> know
>   
>> there are couple of them but could somebody from here give advice on
>> which one to choose.
>> 
>
> Your request is a bit open ended. Are you looking for blogs, wiki,
> message based, or what?
>
> A couple of years ago we set up Dokuwiki as a grass roots effort in the
> development group. In just over a year we had 1100 pages created. It was
> so popular that management got into the act and decided to replace it
> with an officially supported Confluence server. Very few of us
> considered that an upgrade, but that's what happens when the PHB's get
> involved.
>
> I maintained the Dokuwiki server on a Red Hat system. It took about 30
> minutes a week to keep up. It's all PHP, with numerous add-on features
> and capabilities.
>
> Bob McConnell
>
>   


-- 
Extra details:
OSS:Gentoo Linux
profile:x86
Hardware:msi geforce 8600GT asus p5k-se
location:/home/muhsin
language(s):C/C++,VB,VHDL,bash,PHP,SQL,HTML,CSS
Typo:40WPM
url:http://www.mzalendo.net



Re: [PHP] How to pull window to the foreground - Window Focus

2009-07-27 Thread WebPat

Richard Heyes wrote:

Hi,


A lot of sites are moving to simulated dialog windows inside the page.


There's an updated version of my ModalDialog included in RGraph which
does just this:

http://www.rgraph.net/docs/external.html

It covers the page in a semi transparent DIV to bring attention to
itself (the modal part). It beats the crappy confirm() dialogs. The
older version is here:

http://www.phpguru.org/static/Modal-Dialog.html



But why are we moving to commercial software to do something as simple 
as I'm trying to do here?
I'm not against commercial software in general - I own my own commercial 
software business full-time.
Your dialog might be great and really useful in some situations, with 
plenty of benefits. But, it's a big decision to include ANY software 
package into any project. There are learning curves, questions about who 
will be skilled to support it in the future, cost (?), versions, 
upgrades, survival etc.
And I have to say, as a user, I am very disappointed with many sites 
that have obviously included all the latest and greatest technology.


Perhaps there is a need for change. And maybe the development of these 
alternate solutions will encourage the standards powers that be to take 
a new look at the need for a solution within standards.


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



RE: [PHP] Single Quotes in Form Inputs

2009-07-27 Thread Yuri Yarlei

I think mysql_real_escape_string()  is work well, but if you are use mysql db, 
if you are using another db, the best function is addslashes but for another 
special charactes you will need treat them with another ways

Yuri Yarlei.
Programmer PHP, CSS, Java, PostregreSQL;
Today PHP, tomorrow Java, after the world.
Kyou wa PHP, ashita wa Java, sono ato sekai desu.


 
> Date: Mon, 27 Jul 2009 11:10:08 -0700
> From: li...@cmsws.com
> To: mpet...@mac.com
> CC: phps...@gmail.com; mbmas...@stanford.edu; biprel...@gmail.com; 
> php-general@lists.php.net
> Subject: Re: [PHP] Single Quotes in Form Inputs
> 
> Michael A. Peters wrote:
> > Bastien Koert wrote:
> >> On Mon, Jul 27, 2009 at 12:41 PM, Mari Masuda
> >> wrote:
> >>> You need to sanitize and escape the input before inserting it into
> >>> the db.
> >>> You can use http://us.php.net/mysql_real_escape_string to escape the
> >>> input.
> >>>
> >>> On Jul 27, 2009, at 09:35, Ben Miller wrote:
> >>>
>  Hi,
> 
> 
> 
>  I have a form in which my sales reps can add new clients into the
>  database,
>  but I'm running into a problem if the client's name includes a single
>  quote,
>  such as O'Henry, when it comes time to input the form data into the
>  database
>  table. I'm guessing I need to use ereg_replace, or something
>  similar, to
>  change the single quote, but I still can't seem to get the syntax
>  right.
>  Any help would be appreciated. For what it's worth, here is a
>  shortened
>  version of what I have:
> 
> 
> 
>  $ firstName = "$_POST[form_firstName]";
> 
>  $ lastname = "$_POST[form_lastName]";
> 
> 
> 
>  $query = mysql_query("INSERT INTO customers (`cust_first`,`cust_last`)
>  VALUES ('$firstName','$lastName')");
> 
> 
> 
>  Ben Miller
> 
> 
> 
> >>>
> >>> -- 
> >>> PHP General Mailing List (http://www.php.net/)
> >>> To unsubscribe, visit: http://www.php.net/unsub.php
> >>>
> >>>
> >>
> >> I like to use http://ca3.php.net/manual/en/function.htmlentities.php
> >>
> > 
> > htmlentities should not be used on the data before it goes into the
> > database. If used it should be used on data coming out of the database.
> > 
> 
> To summarize:
> 
> You should prep your data for insertion into the data by using a tool
> that formats it strictly for the database. In the ops case
> mysql_real_escape_string() is the correct tool for the job.
> 
> htmlentities() is a presentation sanitizing/cleaning tool. But, it
> should only be used for output to the browser, etc... Same thing with
> htmlspecialchars() and all other related function.
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

_
Descubra todas as novidades do novo Internet Explorer 8
http://brasil.microsoft.com.br/IE8/mergulhe/?utm_source=MSN%3BHotmail&utm_medium=Tagline&utm_campaign=IE8

RE: [PHP] Single Quotes in Form Inputs

2009-07-27 Thread Bob McConnell
From: Yuri Yarlei

> I think mysql_real_escape_string()  is work well, but if
> you are use mysql db, if you are using another db, the best
> function is addslashes but for another special charactes
> you will need treat them with another ways

Slashes are the wrong character to use. The official SQL escape is a
single quote character. Some database managers accept either, but using
slashes can cause more problems than they solve. Find the correct
escape_string function for your database and use it.

Bob McConnell

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



Re: [PHP] More on "JS alert that links to file"

2009-07-27 Thread tony mount
Thanks very much to all the he's and any she's who answered this.
Tony


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



[PHP] newbie: problem with $_Post[]

2009-07-27 Thread A.a.k

Hello
I have a very simple test form named "pass.php"  :


username : 
password :  





getting "Notice: Undefined index: user" and "Notice: Undefined index: pass".
changing form action to another page will solve the problem but i want to be 
able to use $_POST array on the same page, how can i do it?

thanks in advance

/Arash


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



Re: [PHP] newbie: problem with $_Post[]

2009-07-27 Thread Bastien Koert
On Mon, Jul 27, 2009 at 10:31 PM, A.a.k wrote:
> Hello
> I have a very simple test form named "pass.php"  :
>
> 
> username : 
> password :  
> 
> 
>
>  $user=$_POST['user'];
> $pass=$_POST['pass'];
> if(($user=="myname")&&($pass="mypass"))
> echo "access granted";
> else
> echo "access denied";
> ?>
>
> getting "Notice: Undefined index: user" and "Notice: Undefined index: pass".
> changing form action to another page will solve the problem but i want to be
> able to use $_POST array on the same page, how can i do it?
> thanks in advance
>
> /Arash
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Define them

$user='';
$pass='';

-- 

Bastien

Cat, the other other white meat

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



Fwd: [PHP] newbie: problem with $_Post[]

2009-07-27 Thread Richard S. Crawford
>> 
>> username : 
>> password :  
>> 
>> 
>>
>> > $user=$_POST['user'];
>> $pass=$_POST['pass'];
>> if(($user=="myname")&&($pass="mypass"))
>> echo "access granted";
>> else
>> echo "access denied";
>> ?>
>>
>> getting "Notice: Undefined index: user" and "Notice: Undefined index: pass".
>> changing form action to another page will solve the problem but i want to be
>> able to use $_POST array on the same page, how can i do it?
>> thanks in advance
>>
>> /Arash

Arash,

It's hard to respond when it's unclear exactly what you want to do.
I'm guessing that you want to simply have the same page show both the
form, and also process the form, so that you can cut down on the
number of pages you have to create.

The way I do this is by first checking to see if the $_POST array has
been set; if it has not been set, then I know that the form wasn't
filled out, and so the script needs to print out the form. If the
array has been set, on the other hand, then the script can process the
form data. Here's a real quick example of what I mean:

 // The $_POST array is not set, so display the form
    
    username : 
    password :  
    
    


Hope that helps.

--
Richard S. Crawford (rscrawf...@mossroot.com)
http://www.mossroot.com
Publisher and Editor in Chief, Daikaijuzine (http://www.daikaijuzine.com)

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



Re: Fwd: [PHP] newbie: problem with $_Post[]

2009-07-27 Thread Paul M Foster
On Mon, Jul 27, 2009 at 09:01:16PM -0700, Richard S. Crawford wrote:

> >> 
> >> username : 
> >> password :  
> >> 
> >> 
> >>
> >>  >> $user=$_POST['user'];
> >> $pass=$_POST['pass'];
> >> if(($user=="myname")&&($pass="mypass"))
> >> echo "access granted";
> >> else
> >> echo "access denied";
> >> ?>
> >>
> >> getting "Notice: Undefined index: user" and "Notice: Undefined index: 
> >> pass".
> >> changing form action to another page will solve the problem but i want to 
> >> be
> >> able to use $_POST array on the same page, how can i do it?
> >> thanks in advance
> >>
> >> /Arash
> 
> Arash,
> 
> It's hard to respond when it's unclear exactly what you want to do.
> I'm guessing that you want to simply have the same page show both the
> form, and also process the form, so that you can cut down on the
> number of pages you have to create.
> 
> The way I do this is by first checking to see if the $_POST array has
> been set; if it has not been set, then I know that the form wasn't
> filled out, and so the script needs to print out the form. If the
> array has been set, on the other hand, then the script can process the
> form data. Here's a real quick example of what I mean:
> 
>  if (!isset($_POST)) { ?> // The $_POST array is not set, so display the form
>     
>     username : 
>     password :  
>     
>     
>      $user=$_POST['user'];
>     $pass=$_POST['pass'];
>     if(($user=="myname")&&($pass="mypass")) {
>     echo "access granted";
>     } else {
>     echo "access denied";
>     }
> ?>
> 
> Hope that helps.

Richard's right. This is the best way to do this.

Your original code had two problems. First, you're getting the error
message because you're allowing E_NOTICE level error messages. You can
turn these off with the error_reporting() function.

Second, as written, your page paints the form and then directly tests
the status of the variables before the user can respond; the whole page
of PHP code executes and then waits for user response. It's only when
the user responds and the page is revisited that the variables can
legitimately be tested. That's why Richard's method works. The
variables are only tested when the page is re-entered after the user
responds.

Paul

-- 
Paul M. Foster

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



Re: [PHP] Single Quotes in Form Inputs

2009-07-27 Thread Ben Dunlap

 You can use http://us.php.net/mysql_real_escape_string to escape the
input.

[8<]

You should prep your data for insertion into the data by using a tool
that formats it strictly for the database.  In the ops case
mysql_real_escape_string() is the correct tool for the job.


What about using prepared statements? This is my preferred method of 
"escaping output" when I'm using variables in a database query. Of 
course the ease and convenience of this method will depend to a great 
extent on what version of PHP is available on the server.


For the OP, have you read up much on SQL injection? If not, here's a 
decent place to start: http://www.owasp.org/index.php/SQL_injection


Ben

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



Re: Fwd: [PHP] newbie: problem with $_Post[]

2009-07-27 Thread A.a.k

Hello
Richard, that is exactly what I was looking for. thanks alot
Paul, I didn't know its possible to use error_reporting(), that's a good 
hint thanks.
btw if you guys know any simple php application that I can study and learn 
faster than going through books please let me know. I tried Wordpress but 
its too complicated for a beginner like me.



"Paul M Foster"  wrote in message 
news:20090728043523.gs14...@quillandmouse.com...

On Mon, Jul 27, 2009 at 09:01:16PM -0700, Richard S. Crawford wrote:


>> 
>> username : 
>> password :  
>> 
>> 
>>
>> > $user=$_POST['user'];
>> $pass=$_POST['pass'];
>> if(($user=="myname")&&($pass="mypass"))
>> echo "access granted";
>> else
>> echo "access denied";
>> ?>
>>
>> getting "Notice: Undefined index: user" and "Notice: Undefined index: 
>> pass".
>> changing form action to another page will solve the problem but i want 
>> to be

>> able to use $_POST array on the same page, how can i do it?
>> thanks in advance
>>
>> /Arash

Arash,

It's hard to respond when it's unclear exactly what you want to do.
I'm guessing that you want to simply have the same page show both the
form, and also process the form, so that you can cut down on the
number of pages you have to create.

The way I do this is by first checking to see if the $_POST array has
been set; if it has not been set, then I know that the form wasn't
filled out, and so the script needs to print out the form. If the
array has been set, on the other hand, then the script can process the
form data. Here's a real quick example of what I mean:

if (!isset($_POST)) { ?> // The $_POST array is not set, so display the 
form


username : 
password :  




Hope that helps.


Richard's right. This is the best way to do this.

Your original code had two problems. First, you're getting the error
message because you're allowing E_NOTICE level error messages. You can
turn these off with the error_reporting() function.

Second, as written, your page paints the form and then directly tests
the status of the variables before the user can respond; the whole page
of PHP code executes and then waits for user response. It's only when
the user responds and the page is revisited that the variables can
legitimately be tested. That's why Richard's method works. The
variables are only tested when the page is re-entered after the user
responds.

Paul

--
Paul M. Foster 



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