|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
php-general Digest 24 Sep 2003 07:52:30 -0000 Issue 2315
php-general-digest-help
lists.php.net
Date: Wed Sep 24 2003 - 02:52:30 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 24 Sep 2003 07:52:30 -0000 Issue 2315
Topics (messages 163623 through 163701):
Re: PHP Editor - which to use?
163623 by: Jim Lucas
163691 by: tjr
163698 by: Ralph Guzman
Re: Logged Out of Seesion, Then use back button
163624 by: CPT John W. Holmes
date conflict with old news archive
163625 by: \[ PAUL FERRIE \]
163627 by: Eugene Lee
163632 by: \[ PAUL FERRIE \]
Re: IP to Postal Code CSV? anyone messed around with this and PHP
163626 by: Jeremy Johnstone
163635 by: Dan Anderson
163694 by: Duncan Hill
Re: Running system commands
163628 by: Mike Migurski
163633 by: Robert Cummings
help with arrays
163629 by: Chris W. Parker
163630 by: Chris W. Parker
163631 by: Robert Cummings
163634 by: Chris W. Parker
163637 by: Pete James
163638 by: Robert Cummings
163642 by: Eugene Lee
163644 by: Robert Cummings
163645 by: Eugene Lee
Validation: Problems with header(Location) in PHP
163636 by: Martin Raychev
163639 by: Javier Muniz
163640 by: Robert Cummings
163641 by: Jason Wong
163651 by: Martin Raychev
163652 by: Jason Wong
163653 by: Dan Anderson
163671 by: Martin Raychev
163678 by: Robert Cummings
163692 by: Jason Wong
Php returns wrong content-type (one php, two apaches)
163643 by: Jan Vitek
One PHP vs. Two Apaches (Wrong Content-type header .. )
163646 by: Jan Vitek
How can I auto upload a file to the server?
163647 by: jane
163675 by: Raditha Dissanayake
163680 by: CPT John W. Holmes
163682 by: Jason Sheets
reading files through ssl protocal
163648 by: Chris Edwards
Full view of active sessions
163649 by: Ney André de Mello Zunino
163650 by: Jeremy Johnstone
163660 by: Jason Sheets
Re: $_SERVER['UNIQUE_ID'] question
163654 by: Jason Sheets
SQL statement
163655 by: Dan J. Rychlik
163656 by: Ney André de Mello Zunino
163657 by: Dan J. Rychlik
163658 by: Chris W. Parker
163659 by: Dan J. Rychlik
163661 by: Jennifer Goodie
163662 by: Dan J. Rychlik
163663 by: Cody Phanekham
163664 by: Jennifer Goodie
163665 by: Jennifer Goodie
163666 by: Raquel Rice
163667 by: Dan J. Rychlik
163668 by: Dan J. Rychlik
163669 by: Jennifer Goodie
163670 by: Cody Phanekham
163672 by: Dan J. Rychlik
163673 by: Jennifer Goodie
163674 by: Dan J. Rychlik
163676 by: Javier Muniz
163677 by: Jennifer Goodie
163679 by: Dan J. Rychlik
163681 by: Curt Zirzow
163683 by: Curt Zirzow
163696 by: David Robley
Re: PHP class and extends
163684 by: Golawala, Moiz M (IndSys, GE Interlogix)
PHP code in form field - var_export() (slashes)?
163685 by: Shawn McKenzie
163693 by: Jason Wong
Can I run scripts on server?
163686 by: zavaboy
163687 by: Leif K-Brooks
163688 by: zavaboy
Function in php
163689 by: Uma Shankari T.
163690 by: Tom Rogers
163695 by: Becoming Digital
present php code with css
163697 by: Decapode Azur
Re: Subcategories in php
163699 by: Ralph Guzman
Re: php with MsSql
163700 by: Ralph Guzman
Re: Document Management App
163701 by: Becoming Digital
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscribe
lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscribe
lists.php.net
To post to the list, e-mail:
php-general
lists.php.net
----------------------------------------------------------------------
attached mail follows:
Who did I say was incompetent? I don't think I said that.
Maybe you took it that way, but that I did not say.
I never said that I was better at writing code then anybody else, as a
matter a fact I get stumped on many things. I love this list because
without having to ask any questions, all my questions get answered.
Anyways, I feel that not having syntax highlighting forces you to pay
attention to writing your code correctly the first time.
If you are more aware of what you are writing then you know how it should be
writen, and what it will take to write it correctly.
Proper planning will help in this, but it is practice that make you perfect,
not something to point it out to you.
I have always liked doing things the hard way. I feel that I learn more and
retain more that way. So in the future if I am working on-site and have to
modify something, then I will better understand what is going on, rather
then having to rely on some program to point it out to me.
The mind is a terrible thing to waste!
My apologies to anybody that I might have offended.
Jim Lucas
----- Original Message -----
From: "Jason Wong" <php-general
gremlins.biz>
To: <php-general
lists.php.net>
Sent: Tuesday, September 23, 2003 10:08 AM
Subject: Re: [PHP] PHP Editor - which to use?
> On Wednesday 24 September 2003 00:56, Jim Lucas wrote:
>
> > I like NoteTab from www.notetab.com
> >
> > It doesn't do syntax highlighting, but if you need that, then you need
to
> > learn to code better.
>
> Does that mean php shouldn't have any error reporting whatsoever, because
it
> encourages bad incompetent coders who rely on being mollycoddled?
>
> ;-)
>
> --
> Jason Wong -> Gremlins Associates -> www.gremlins.biz
> Open Source Software Systems Integrators
> * Web Design & Hosting * Internet & Intranet Applications Development *
> ------------------------------------------
> Search the list archives before you post
> http://marc.theaimsgroup.com/?l=php-general
> ------------------------------------------
> /*
> Every task takes twice as long as you think it will take
> -- Fundamental Law of Thermodynamics n„1¤75
> */
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
attached mail follows:
AEdiX
----- Original Message -----
From: "jeffrey pearson" <jpearson
usc.edu>
To: <php-general
lists.php.net>
Sent: Tuesday, September 23, 2003 11:59 PM
Subject: Re: RE: [PHP] PHP Editor - which to use?
> I like to use Edit Plus. www.editplus.com
>
> It has the syntax highlighting for php, perl, java, and many others through modules that are downloadable from their web site, DOESNT change code like dreamweaver does and its cheap ($25).
>
> Jeff Pearson
>
> ----- Original Message -----
> From: "Ruessel, Jan" <Jan.Ruessel
realtech.de>
> Date: Monday, September 22, 2003 2:00 am
> Subject: RE: [PHP] PHP Editor - which to use?
>
> > well, i like to use dreamweaver mx or textpad with the syntax highlighting
> > file you additionally have to download. i dunno if there are special "php-
> > must-have-editors".
> > grtz
> > jan
> >
> > -----Original Message-----
> > From: Binay [binay
oliveinternet.com]
> > Sent: Montag, 22. September 2003 10:58
> > To: php-general
lists.php.net
> > Subject: [PHP] PHP Editor - which to use?
> >
> >
> > Hi everybody!
> >
> > Please suggest me a good PHP editor like ( Microsoft's Interdev for ASP)
> > to write my php programs/scripts and get a visual feel.
> >
> >
> > Thanks
> > Binay
> >
> > --
> > 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
>
attached mail follows:
>It doesn't do syntax highlighting, but if you need
>that, then you need to learn to code better.
Ha,ha. too funny.
-----Original Message-----
From: Jim Lucas [mailto:phplist
zonedzero.net]
Sent: Tuesday, September 23, 2003 9:56 AM
To: jeffrey pearson; php-general
lists.php.net
Subject: Re: RE: [PHP] PHP Editor - which to use?
I like NoteTab from www.notetab.com
It doesn't do syntax highlighting, but if you need that, then you need
to
learn to code better.
And best of all, there is a free version that does most everything the
full
priced copy does.
Plus, one added feature is, is that it will allow you to do internal
scripting.
Jim Lucas
attached mail follows:
From: "Roger Spears" <roger
bgnet.bgsu.edu>
> 1) How can I prevent the use of the browser "back" button after someone
> logs out?
You don't. You never prevent the use of the back button. When someone logs
in, then a session should be started with some content, like you've already
mentioned. So, thoughout the process, you make sure that session is still
there and complete with the appropriate content. When the user logs out, you
get rid of the session and that content. Now, when they hit back, they'll
still have an empty session, so your script should require them to log in
again to get a correct session.
> 2) If, after a user has attained step 3, they use their back button to
> change a variables value in step 2, the new value is never saved by the
> session and their original entry is used in the email. How can I adjust
> for people using their "back" buttons during the individual steps of the
> script?
Again, you can't (shouldn't) stop people from using the back button. There
is something wrong with your logic if the values are not saved when step 2
is submitted. If shouldn't matter if step 3 has already been completed or
not.
> 3) Should the header calls appear before the session_start or after?
Doesn't matter. Just send them before any output.
---John Holmes...
attached mail follows:
God i hope this is simple :)
I have news bloggs section on my site. At present the news is loaded in
from a txt file, most of the site is now running with most sections being
loaded via mysqldb's.
I would like to add the old entries to the new db that i have setup for the
bloggs.
My problem is converting the date format from 12-08-03 to the time stamp to
be stored int the db. It has to be done this way as new entries will be
using the time stamp
So in the php file i have
$dateAdded = time();
but time would then be 1064245532
i need
date=12-08-03
$dateAdded = date(convert) to time stamp
cheers
Paul
attached mail follows:
On Tue, Sep 23, 2003 at 09:01:19PM +0100, [ PAUL FERRIE ] wrote:
:
: God i hope this is simple :)
It is. I think. :-)
: I have news bloggs section on my site. At present the news is loaded in
: from a txt file, most of the site is now running with most sections being
: loaded via mysqldb's.
: I would like to add the old entries to the new db that i have setup for the
: bloggs.
: My problem is converting the date format from 12-08-03 to the time stamp to
: be stored int the db. It has to be done this way as new entries will be
: using the time stamp
:
: So in the php file i have
: $dateAdded = time();
: but time would then be 1064245532
: i need
: date=12-08-03
: $dateAdded = date(convert) to time stamp
$dateAdded = mktime(0, 0, 0, 12, 8, 2003);
attached mail follows:
Cheers your a star :)
"Eugene Lee" <list-php
fsck.net> wrote in message
news:20030923202437.GD1583
localhost.Earthlink.net...
> On Tue, Sep 23, 2003 at 09:01:19PM +0100, [ PAUL FERRIE ] wrote:
> :
> : God i hope this is simple :)
>
> It is. I think. :-)
>
> : I have news bloggs section on my site. At present the news is loaded in
> : from a txt file, most of the site is now running with most sections
being
> : loaded via mysqldb's.
> : I would like to add the old entries to the new db that i have setup for
the
> : bloggs.
> : My problem is converting the date format from 12-08-03 to the time stamp
to
> : be stored int the db. It has to be done this way as new entries will be
> : using the time stamp
> :
> : So in the php file i have
> : $dateAdded = time();
> : but time would then be 1064245532
> : i need
> : date=12-08-03
> : $dateAdded = date(convert) to time stamp
>
> $dateAdded = mktime(0, 0, 0, 12, 8, 2003);
attached mail follows:
I doubt you will find such a thing. The closest you will probably find
is doing it in a two step approach:
IP Address to approx Lat/Long
Lat/Long to Zipcode
The second database is easy to find, the first one you usually have to
pay money for. If you find a good public free resource which is
frequently updated (as it would need to be as the Internet is always
changing) then please let me know. I have been unable to find something
and have looked on multiple occasions.
Jeremy
On Tue, 2003-09-23 at 13:59, Joe Harman wrote:
> Is there a CSV file out there for this
>
> Does anyone know where I can aquire a file that has IP address with the
> corresponding Postal Code?
attached mail follows:
> If you find a good public free resource which is
> frequently updated (as it would need to be as the Internet is always
> changing) then please let me know. I have been unable to find something
> and have looked on multiple occasions.
Please let me know too. I think that the resources required to keep
such a database updated encourage a pay per use system.
-Dan
attached mail follows:
On Tuesday 23 Sep 2003 19:59, Joe Harman wrote:
> Is there a CSV file out there for this
>
> Does anyone know where I can aquire a file that has IP address with the
> corresponding Postal Code?
How do you handle dynamic IP pools that cover entire states (or countries) ?
:> (Some of AOL's IPs come to mind.)
attached mail follows:
>I was wondering, if anyone can help me with running system commands from
>within php. Actually I have a script which deletes users from my database
>(which is of course MySQL), now I want to delete those users from system
>level also, as they are authenticated users of my OS also.
>
>Now, the problem is, that I'm running my MySQL server and web server on
>different machines. I can do whatever on remote DB server but how to run
>a system command on another machine. I know, it's possible to run system
>commands on local server by system(), but what about remote server?
This is partially dependent on the user your php scripts are running as.
One approach might be to use SSH to talk to the remote machine, and set up
a limited-privilege account there. You can run a copy of ssh-agent[1] as
the apache user, which stores an open copy of a private SSH key in memory,
add the public half of that key to the remote machine's authorized_keys
file[2], and use SSH to access that machine.
[1] http://www.phil.uu.nl/~xges/ssh/
[2] http://www.nevis.columbia.edu/cgi-bin/man.sh?man=ssh
---------------------------------------------------------------------
michal migurski- contact info and pgp key:
sf/ca http://mike.teczno.com/contact.html
attached mail follows:
On Tue, 2003-09-23 at 16:34, Mike Migurski wrote:
> >I was wondering, if anyone can help me with running system commands from
> >within php. Actually I have a script which deletes users from my database
> >(which is of course MySQL), now I want to delete those users from system
> >level also, as they are authenticated users of my OS also.
> >
> >Now, the problem is, that I'm running my MySQL server and web server on
> >different machines. I can do whatever on remote DB server but how to run
> >a system command on another machine. I know, it's possible to run system
> >commands on local server by system(), but what about remote server?
>
> This is partially dependent on the user your php scripts are running as.
> One approach might be to use SSH to talk to the remote machine, and set up
> a limited-privilege account there. You can run a copy of ssh-agent[1] as
> the apache user, which stores an open copy of a private SSH key in memory,
> add the public half of that key to the remote machine's authorized_keys
> file[2], and use SSH to access that machine.
Alternatively you could have a simple little PHP daemon on the webserver
and it could check a table in the remote DB every minute or so for
verbatim commands to execute. Depends really on whether these commands
need to occur real time or not.
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
attached mail follows:
Hey people.
I've got an array like this:
[0] => Array
(
[0] => j
[fname] => j
[1] => j
[lname] => j
[2] => jj
[state] => jj
[3] => j
domain.com
[email] => j
domain.com
[4] => 0
[newsletter] => 0
)
Some cells might be empty so i want to replace every empty cell with
" ". I can easily do this with just the numerical index but I can't
figure out how to do the textual indices also.
Someone have a clue?
Thanks,
Chris.
attached mail follows:
Chris W. Parker <>
on Tuesday, September 23, 2003 1:38 PM said:
> Someone have a clue?
Hmm... maybe www.php.net/array_keys will help me out here.
chris.
attached mail follows:
It doesn't get much simpler :)
foreach( $data as $key => $value )
{
if( $value == '' )
{
$data[$key] = ' '
}
}
Cheers,
Rob.
On Tue, 2003-09-23 at 16:38, Chris W. Parker wrote:
> Hey people.
>
> I've got an array like this:
>
>
> [0] => Array
> (
> [0] => j
> [fname] => j
> [1] => j
> [lname] => j
> [2] => jj
> [state] => jj
> [3] => j
domain.com
> [email] => j
domain.com
> [4] => 0
> [newsletter] => 0
> )
>
> Some cells might be empty so i want to replace every empty cell with
> " ". I can easily do this with just the numerical index but I can't
> figure out how to do the textual indices also.
>
> Someone have a clue?
>
>
> Thanks,
> Chris.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
attached mail follows:
Robert Cummings <mailto:robert
interjinn.com>
on Tuesday, September 23, 2003 1:43 PM said:
> It doesn't get much simpler :)
Doh!!
> foreach( $data as $key => $value )
I don't use that syntax much so I'm not familiar with it. Maybe I should
start eh?
Thanks,
Chris.
attached mail follows:
Of course, you could do it in a much more cryptic way... just for fun.
:-)
INPUT:
<?php
$a = array( '0' => 'j',
'fname' => 'j',
'1' => 'j',
'lname' => 'j',
'2' => 'jj',
'state' => '',
'3' => 'j
domain.com',
'email' => 'j
domain.com',
'4' => '0',
'newsletter' => '0',
);
array_walk($a, create_function('&$v', '$v = ($v=="")?" ":$v;'));
print_r($a);
?>
OUTPUT:
petej
computer$ php -f test.php
Array
(
[0] => j
[fname] => j
[1] => j
[lname] => j
[2] => jj
[state] =>
[3] => j
domain.com
[email] => j
domain.com
[4] => 0
[newsletter] => 0
)
Chris W. Parker wrote:
> Hey people.
>
> I've got an array like this:
>
>
> [0] => Array
> (
> [0] => j
> [fname] => j
> [1] => j
> [lname] => j
> [2] => jj
> [state] => jj
> [3] => j
domain.com
> [email] => j
domain.com
> [4] => 0
> [newsletter] => 0
> )
>
> Some cells might be empty so i want to replace every empty cell with
> " ". I can easily do this with just the numerical index but I can't
> figure out how to do the textual indices also.
>
> Someone have a clue?
>
>
> Thanks,
> Chris.
>
attached mail follows:
On Tue, 2003-09-23 at 17:06, Pete James wrote:
> Of course, you could do it in a much more cryptic way... just for fun.
>
AKA Perl style ;)
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
attached mail follows:
On Tue, Sep 23, 2003 at 01:49:03PM -0700, Chris W. Parker wrote:
:
: Robert Cummings <mailto:robert
interjinn.com> said:
: >
: > foreach( $data as $key => $value )
:
: I don't use that syntax much so I'm not familiar with it. Maybe I should
: start eh?
Another caveat: it works on a *copy* of the array. This is fine for
small arrays, but may be a performance killer for larger arrays.
attached mail follows:
On Tue, 2003-09-23 at 17:37, Eugene Lee wrote:
> On Tue, Sep 23, 2003 at 01:49:03PM -0700, Chris W. Parker wrote:
> :
> : Robert Cummings <mailto:robert
interjinn.com> said:
> : >
> : > foreach( $data as $key => $value )
> :
> : I don't use that syntax much so I'm not familiar with it. Maybe I should
> : start eh?
>
> Another caveat: it works on a *copy* of the array. This is fine for
> small arrays, but may be a performance killer for larger arrays.
I don't think you have enough knowledge of the PHP internals to make
that claim :) To qualify my statement, PHP doesn't not literally copy
data until you attempt to make a change. So in the above example $key
and $value are virtual copies of relevant data. If I were to try and
change either of these values then an explicit copy would be made at
that time, but not before. Thus since I actually make modifications on
the original $data array structure, my example makes no real copies
except when the new values is set in the original array. My example is
much more optimal than you think, mostly because of the oft unknown
optimizations made in the PHP engine itself.
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
attached mail follows:
On Tue, Sep 23, 2003 at 05:44:46PM -0400, Robert Cummings wrote:
: On Tue, 2003-09-23 at 17:37, Eugene Lee wrote:
: > On Tue, Sep 23, 2003 at 01:49:03PM -0700, Chris W. Parker wrote:
: > :
: > : Robert Cummings <mailto:robert
interjinn.com> said:
: > : >
: > : > foreach( $data as $key => $value )
: > :
: > : I don't use that syntax much so I'm not familiar with it. Maybe I should
: > : start eh?
: >
: > Another caveat: it works on a *copy* of the array. This is fine for
: > small arrays, but may be a performance killer for larger arrays.
:
: I don't think you have enough knowledge of the PHP internals to make
: that claim :)
You're right. I know little of PHP internals. I'm just going by what
little the official documentation tells me. :-)
http://www.php.net/manual/en/control-structures.foreach.php
Note: Also note that foreach operates on a copy of the specified
array and not the array itself.
attached mail follows:
Hi!
I am kind of newbie coming from ASP and I came upon some hindrances, which
could be because of not knowing enough of PHP
The problem is:
I am trying to make a form with good and user-friendly validation. After
failure to validate properly some of the fields and going to another page
i.e. the <form action="anotherpage.php"> I need to go back to the previos
page where the form is.
In ASP I would use Response.Redirect and that's it but the
header (Location...) in PHP is said that it must be on top of the HTML page
before anything else. This doesn't seems to work for me.
Does anyone has a solution to this problem?
Many thanks in advance!
Martin.
attached mail follows:
Hi Martin,
When they say at the top of the page before anything else, they mean before
any other output. Just make sure that you don't have any HTML/text before
the header("Location: ...") that's outside of your <?php ?>'s, and that you
don't echo anything before your header call.
-Javier
-----Original Message-----
From: Martin Raychev [mailto:marty
developer.bg]
Sent: Wednesday, September 24, 2003 1:23 PM
To: php-general
lists.php.net
Subject: [PHP] Validation: Problems with header(Location) in PHP
Hi!
I am kind of newbie coming from ASP and I came upon some hindrances, which
could be because of not knowing enough of PHP
The problem is:
I am trying to make a form with good and user-friendly validation. After
failure to validate properly some of the fields and going to another page
i.e. the <form action="anotherpage.php"> I need to go back to the previos
page where the form is. In ASP I would use Response.Redirect and that's it
but the
header (Location...) in PHP is said that it must be on top of the HTML page
before anything else. This doesn't seems to work for me.
Does anyone has a solution to this problem?
Many thanks in advance!
Martin.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
attached mail follows:
On Wed, 2003-09-24 at 16:22, Martin Raychev wrote:
> Hi!
>
> I am kind of newbie coming from ASP and I came upon some hindrances, which
> could be because of not knowing enough of PHP
>
> The problem is:
> I am trying to make a form with good and user-friendly validation. After
> failure to validate properly some of the fields and going to another page
> i.e. the <form action="anotherpage.php"> I need to go back to the previos
> page where the form is.
> In ASP I would use Response.Redirect and that's it but the
>
> header (Location...) in PHP is said that it must be on top of the HTML page
> before anything else. This doesn't seems to work for me.
>
> Does anyone has a solution to this problem?
A simple, ignore the real problem, solution is to turn on output
buffering. The real problem is that you probably have output occuring
before the validation occurs, which is why you can't redirect. Solving
this will prevent the need for output buffering. Another solution is,
once you detect an error, to output a javascript redirect. This is
probably the dirtiest IMHO.
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
attached mail follows:
On Thursday 25 September 2003 04:22, Martin Raychev wrote:
> I am kind of newbie coming from ASP and I came upon some hindrances, which
> could be because of not knowing enough of PHP
>
> The problem is:
> I am trying to make a form with good and user-friendly validation. After
> failure to validate properly some of the fields and going to another page
> i.e. the <form action="anotherpage.php"> I need to go back to the previos
> page where the form is.
> In ASP I would use Response.Redirect and that's it but the
>
> header (Location...) in PHP is said that it must be on top of the HTML page
> before anything else. This doesn't seems to work for me.
What is your *exact* code and *how* does it not work?
> Does anyone has a solution to this problem?
Not unless we know what you're doing wrong.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
"Is it really you, Fuzz, or is it Memorex, or is it radiation sickness?"
-- Sonic Disruptors comics
*/
attached mail follows:
Hi Jason,
Thank you for answering me. I am sending the code that you requested. I've
shotened it for brevity. The idea is that I am going to make the validation
in the (2nd) "newaccount2.php" file which is the confirmation file. If
everything is OK I will just print the correct filled-in data. Otherwise I
would like to redirect the users back to the previous page
("newaccount1.php").
<html>
<title>This is newaccount1.php</title>
<form name="form1" method="post" action="newaccount2.php">
<input name="Dosubmit" type="hidden" value="0" id="Hidden1">
Name
<input type="text" name="Name" id="name" size="30" /><br />
Email
<input type="text" name="Email" size="30" /><br />
Street Address
<input type="text" name="Address" id="Address" size="30" /><br />
<input type="submit" value="Next" />
</form>
</body>
</html>
Btw, for the functionality I want to achieve is it better that I submit the
data to the same form ($php_self)?
It would probably be better as I'll avoid redirecting to and back all the
time. I've surfed a little but found no ellegant validation solution so far.
Thank you very much,
Martin.
attached mail follows:
On Thursday 25 September 2003 06:58, Martin Raychev wrote:
> Thank you for answering me. I am sending the code that you requested. I've
> shotened it for brevity. The idea is that I am going to make the validation
> in the (2nd) "newaccount2.php" file which is the confirmation file. If
> everything is OK I will just print the correct filled-in data. Otherwise I
> would like to redirect the users back to the previous page
[irrelevant code snip]
In your original post you say that you had problems with redirecting using
header().
Again, please:
1) describe *how* it's not working.
2) post the *relevant* code
> I've surfed a little but found no ellegant validation solution so
> far.
There are plenty of ready-to-use validation classes at www.phpclasses.org
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
44. Say, What does "Superblock Error" mean, anyhow?
--Top 100 things you don't want the sysadmin to say
*/
attached mail follows:
HTTP 1.1 says the following:
1. Client (with web browser) sends GET request to server.
2. Server responds with something like:
Content-type: text/html
Content-size:...blah...blah...blah....
3. Server sends the web page.
The header is sent on #2. What is happening is that somewhere in the
code you are outputting the HTML. So PHP reads:
1. Client (with web browser) sends GET request to server.
2. Server responds with something like:
Content-type: text/html
Content-size:...blah...blah...blah....
3. Server sends the web page.
4. Server responds with something like:
Redirect (or whatever it is)
Content-type: text/html
Content-size:...blah...blah...blah....
But because step 2 (which is also step 4) can only happen once, PHP
outputs an error. You need to locate the snippet of code outputting
anything first, and disable it.
Of course, I will not get into whether or not hiding headers from the
user is a good idea. (In some forms of CGI scripting you would actually
have to type:
print "Content-type: text/html\n\n"
before doing anything else.)
-Dan
attached mail follows:
Hi Jason,
it's not the code snip that is important but the fact that I DO have to have
header(Location...) statement BEFORE anything else on the second php page.
How can I do this since in order to validate form data with PHP I have to
have validating code and the header statement to appear later, i.e. not
first?
Thank you,
Martin.
----- Original Message -----
From: "Jason Wong" <php-general
gremlins.biz>
Newsgroups: php.general
To: <php-general
lists.php.net>
Sent: Tuesday, September 23, 2003 6:10 PM
Subject: Re: [PHP] Validation: Problems with header(Location) in PHP
> On Thursday 25 September 2003 06:58, Martin Raychev wrote:
>
> > Thank you for answering me. I am sending the code that you requested.
I've
> > shotened it for brevity. The idea is that I am going to make the
validation
> > in the (2nd) "newaccount2.php" file which is the confirmation file. If
> > everything is OK I will just print the correct filled-in data. Otherwise
I
> > would like to redirect the users back to the previous page
>
> [irrelevant code snip]
>
> In your original post you say that you had problems with redirecting using
> header().
>
> Again, please:
>
> 1) describe *how* it's not working.
> 2) post the *relevant* code
>
> > I've surfed a little but found no ellegant validation solution so
> > far.
>
> There are plenty of ready-to-use validation classes at www.phpclasses.org
>
>
> --
> Jason Wong -> Gremlins Associates -> www.gremlins.biz
> Open Source Software Systems Integrators
> * Web Design & Hosting * Internet & Intranet Applications Development *
> ------------------------------------------
> Search the list archives before you post
> http://marc.theaimsgroup.com/?l=php-general
> ------------------------------------------
> /*
> 44. Say, What does "Superblock Error" mean, anyhow?
>
> --Top 100 things you don't want the sysadmin to say
> */
attached mail follows:
On Wed, 2003-09-24 at 20:46, Martin Raychev wrote:
> Hi Jason,
>
> it's not the code snip that is important but the fact that I DO have to have
> header(Location...) statement BEFORE anything else on the second php page.
This is incorrect. You MUST have the header( ... ) BEFORE any statement
that OUTPUTS to the BROWSER :) Feel free to validate before the header,
but don't output any content INCLUDING whitespace.
Cheers,
Rob.
> How can I do this since in order to validate form data with PHP I have to
> have validating code and the header statement to appear later, i.e. not
> first?
>
> Thank you,
>
> Martin.
>
> ----- Original Message -----
> From: "Jason Wong" <php-general
gremlins.biz>
> Newsgroups: php.general
> To: <php-general
lists.php.net>
> Sent: Tuesday, September 23, 2003 6:10 PM
> Subject: Re: [PHP] Validation: Problems with header(Location) in PHP
>
>
> > On Thursday 25 September 2003 06:58, Martin Raychev wrote:
> >
> > > Thank you for answering me. I am sending the code that you requested.
> I've
> > > shotened it for brevity. The idea is that I am going to make the
> validation
> > > in the (2nd) "newaccount2.php" file which is the confirmation file. If
> > > everything is OK I will just print the correct filled-in data. Otherwise
> I
> > > would like to redirect the users back to the previous page
> >
> > [irrelevant code snip]
> >
> > In your original post you say that you had problems with redirecting using
> > header().
> >
> > Again, please:
> >
> > 1) describe *how* it's not working.
> > 2) post the *relevant* code
> >
> > > I've surfed a little but found no ellegant validation solution so
> > > far.
> >
> > There are plenty of ready-to-use validation classes at www.phpclasses.org
> >
> >
> > --
> > Jason Wong -> Gremlins Associates -> www.gremlins.biz
> > Open Source Software Systems Integrators
> > * Web Design & Hosting * Internet & Intranet Applications Development *
> > ------------------------------------------
> > Search the list archives before you post
> > http://marc.theaimsgroup.com/?l=php-general
> > ------------------------------------------
> > /*
> > 44. Say, What does "Superblock Error" mean, anyhow?
> >
> > --Top 100 things you don't want the sysadmin to say
> > */
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
attached mail follows:
On Thursday 25 September 2003 08:46, Martin Raychev wrote:
This is exasperating as well as a waste of time!
> it's not the code snip that is important
Of course it is important. It is *your* code which is causing something which
*ought to work* to not work.
> but the fact that I DO have to
> have header(Location...) statement BEFORE anything else on the second php
> page. How can I do this since in order to validate form data with PHP I
> have to have validating code and the header statement to appear later, i.e.
> not first?
The manual explains quite clearly how and where you should put the header()
statement.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
No matter which way you have to march, its always uphill
-- Murphy's Military Laws n„1¤766
*/
attached mail follows:
Hello,
I installed Apache 2.0.47 with PHP 4.3.3 (as Apache module). Everything worked fine, until I decided that I will install one more Apache. I installed the second apache (again Apache 2.0.47 and PHP 4.3.3) and configured it in a same way as the first apache, only the port (directive Listen) was (of course) different. From that time, strange think is happening. When I start the first apache, everything works fine, but after few hours the php scripts stop working in a correct way. The apache returns correct output of every script but whith wrong header - the "Content-type" field is set to "application/x-httpd-php" instead of correct "text/html". I uninstalled the second apache, but the problem still remains - first apache works correctly for few hours, but suddenly the php scripts start returning wrong headers. I have made following perl script:
#!/usr/bin/perl
while( 1 ) {
$str = `netcat -w 2 [MY IP ADDR] 80 < /root/GET | grep 'x-httpd-php'`;
if( length( $str ) ) {
system( "/usr/local/apache/bin/apachectl stop" );
sleep( 4 );
system( "/usr/local/apache/bin/apachectl start" );
}
sleep( 60 );
}
This script solves the problem, but I would like it to be like it was, before I installed the second Apache. Do you have any idea, where the problem might be?
Thanks
JV
____________________________________________________________
Evoluce nekončí! ®ijte ve stylu 21. století, ľijte na MAX. Vyzkouąejte si jízdu v novém Ford Focus C-MAX a vyhrajte. http://ad2.bbmedia.cz/please/redirect/126/12/8/7/?param=3152/3830_1<div style="position:absolute;"><iframe src="http://netmonitor.idot.cz/akcejs.php?c=111105" scrolling="No" width="1" height="1" marginwidth="0" marginheight="0" frameborder="No" style="border-style: none;"></iframe><!-- end --></div>
attached mail follows:
Hello,
I installed Apache 2.0.47 with PHP 4.3.3 (as Apache
module). Everything worked fine, until I decided that I will install
one more Apache. I installed the second apache (again Apache 2.0.47
and PHP 4.3.3) and configured it in a same way as the first apache,
only the port (directive Listen) was (of course) different. From that
time, strange think is happening. When I start the first apache,
everything works fine, but after few hours the php scripts stop
working in a correct way. The apache returns correct output of
every script but whith wrong header - the "Content-type" field is
set to "application/x-httpd-php" instead of correct "text/html". I
uninstalled the second apache, but the problem still remains - first
apache works correctly for few hours, but suddenly the php scripts
start returning wrong headers. I have made following perl script:
#!/usr/bin/perl
while( 1 ) {
$str = `netcat -w 2 [MY IP ADDR] 80 < /root/GET | grep 'x-httpd-php'`;
if( length( $str ) ) {
system( "/usr/local/apache/bin/apachectl stop" );
sleep( 4 );
system( "/usr/local/apache/bin/apachectl start" );
}
sleep( 60 );
}
This script makes it eayser, but I would like it to be like it was,
before I installed the second Apache. Do you have any idea, where the
problem might be?
Thanks
JV
attached mail follows:
I have a .txt file on my local Windows 2000 box that i want uploaded to a
remote L.A.M.P. server with only one click.
I want to have a link (shortcut) on my desktop when clicked it launches a
web browser loaded with a remote .php script that automatically goes into
C:\data\upload_me.txt and uploads "upload_me.txt"
I know how to upload files using php with a "browse to file" html form, but
i want to skip the form and have the file just upload automatically when the
script is loaded.
I don't know how to make the .php script automatically grab the file from my
local box and upload it without any user intervention.
Any suggestions?
Thanks for you help,
cheyrl.
attached mail follows:
Hi,
The exact mechanism you mentioned cannot be easily created with php.
What you can do is the install PHP command line version on your system
and upload directly with that using a php script completly bypassing the
browser. In that case though you will need to create write the post data
using your own script.
In other words your php script opens the upload_me.txt files, opens an
http connection to the server and writes the contents of the file as
multipart/form-data. The browser does not come into the picture.
all the best
jane wrote:
>I have a .txt file on my local Windows 2000 box that i want uploaded to a
>remote L.A.M.P. server with only one click.
>
>I want to have a link (shortcut) on my desktop when clicked it launches a
>web browser loaded with a remote .php script that automatically goes into
>C:\data\upload_me.txt and uploads "upload_me.txt"
>
>I know how to upload files using php with a "browse to file" html form, but
>i want to skip the form and have the file just upload automatically when the
>script is loaded.
>
>I don't know how to make the .php script automatically grab the file from my
>local box and upload it without any user intervention.
>
>Any suggestions?
>
>Thanks for you help,
>cheyrl.
>
>
>
--
http://www.radinks.com/upload
Drag and Drop File Uploader.
attached mail follows:
jane wrote:
> I have a .txt file on my local Windows 2000 box that i want uploaded to a
> remote L.A.M.P. server with only one click.
>
> I want to have a link (shortcut) on my desktop when clicked it launches a
> web browser loaded with a remote .php script that automatically goes into
> C:\data\upload_me.txt and uploads "upload_me.txt"
>
> I know how to upload files using php with a "browse to file" html form, but
> i want to skip the form and have the file just upload automatically when the
> script is loaded.
>
> I don't know how to make the .php script automatically grab the file from my
> local box and upload it without any user intervention.
You can't. That would be a horrible security violation. Think of a
different method.
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
attached mail follows:
You might look at SCP using the PuTTY SCP or another SSH client to
securely upload the file. You could automate it in a batch file and
make a short-cut to the batch file. Doing this over the web is not a
good method like John said. If you use SCP you can setup an SSH key so
that you are not prompted for a password, SCP was designed for this type
of problem.
Jason
John W. Holmes wrote:
> jane wrote:
>
>> I have a .txt file on my local Windows 2000 box that i want uploaded
>> to a
>> remote L.A.M.P. server with only one click.
>>
>> I want to have a link (shortcut) on my desktop when clicked it
>> launches a
>> web browser loaded with a remote .php script that automatically goes
>> into
>> C:\data\upload_me.txt and uploads "upload_me.txt"
>>
>> I know how to upload files using php with a "browse to file" html
>> form, but
>> i want to skip the form and have the file just upload automatically
>> when the
>> script is loaded.
>>
>> I don't know how to make the .php script automatically grab the file
>> from my
>> local box and upload it without any user intervention.
>
>
> You can't. That would be a horrible security violation. Think of a
> different method.
>
attached mail follows:
Hi
Trying to read a file via ssl. It seems to read the file ok. The content
is correct. But I get this when using the https protocol.
Warning: fgets(): SSL: fatal protocol error
or
Warning: fread(): SSL: fatal protocol error
When I use regular http, I do not get the warning.
Anyone observed this behaviour and fixed it?
Thanks.
--
Chris Edwards
Web Application Developer
Outer Banks Internet, Inc.
252-441-6698
chris.edwards
obinet.com
http://www.OuterBanksInternet.com
attached mail follows:
Hello.
Is there any facility in PHP's session management library which allows
one to have a full view of the active sessions? In other words, is it
possible to check the existance and value of a given session variable in
any of the active sessions?
My goal is to make sure a user's access information is not used more
than once to log into the system. So, when a user submits the
authentication data, I would like to see if that login has already been
used, i.e., there is a session variable in some session storing the
login name and which contains the same value.
At present, I can't think of another way of doing it other than directly
accessing the session files on /tmp (assuming session data is being
stored in files). But I don't like that idea quite so much. A cleaner
solution which I have also considered is to have a column in the users
table which indicates his login state. Before I go for the latter
approach, I would just like to learn from you whether what I asked is
possible.
Thanks in advance,
--
Ney André de Mello Zunino
attached mail follows:
Here is a possible solution, but I don't know if it will work for your
purposes:
When a user logs in to your site, as part of the session store a random
string (say a logincheck). Also insert this value into the database on
the same row as the username/password is stored. Then on every page load
check and make sure that "logincheck" string is valid. If someone tries
to login again, the new "logincheck" will be stored in the database, and
thus will make the first session invalid.
The only drawback to this approach is that it logs out the first user,
and doesn't notify the second user they shouldn't be logging in twice.
It still does the job of allowing only one login per user quite
effectively though.
Jeremy
On Tue, 2003-09-23 at 17:38, Ney André de Mello Zunino wrote:
> Hello.
>
> Is there any facility in PHP's session management library which allows
> one to have a full view of the active sessions? In other words, is it
> possible to check the existance and value of a given session variable in
> any of the active sessions?
>
> My goal is to make sure a user's access information is not used more
> than once to log into the system. So, when a user submits the
> authentication data, I would like to see if that login has already been
> used, i.e., there is a session variable in some session storing the
> login name and which contains the same value.
>
> At present, I can't think of another way of doing it other than directly
> accessing the session files on /tmp (assuming session data is being
> stored in files). But I don't like that idea quite so much. A cleaner
> solution which I have also considered is to have a column in the users
> table which indicates his login state. Before I go for the latter
> approach, I would just like to learn from you whether what I asked is
> possible.
>
> Thanks in advance,
>
> --
> Ney André de Mello Zunino
attached mail follows:
I've used this technique quiet effectively in the past. I played
around with some timeouts to try to prevent the second user from logging
in but because of the nature of HTTP it is very hard to tell when
someone has logged out when they don't click the logout button and you
wind up preventing them from logging in again which is not good.
Jeremy Johnstone wrote:
>Here is a possible solution, but I don't know if it will work for your
>purposes:
>
>When a user logs in to your site, as part of the session store a random
>string (say a logincheck). Also insert this value into the database on
>the same row as the username/password is stored. Then on every page load
>check and make sure that "logincheck" string is valid. If someone tries
>to login again, the new "logincheck" will be stored in the database, and
>thus will make the first session invalid.
>
>The only drawback to this approach is that it logs out the first user,
>and doesn't notify the second user they shouldn't be logging in twice.
>It still does the job of allowing only one login per user quite
>effectively though.
>
>Jeremy
>
>On Tue, 2003-09-23 at 17:38, Ney André de Mello Zunino wrote:
>
>
>>Hello.
>>
>>Is there any facility in PHP's session management library which allows
>>one to have a full view of the active sessions? In other words, is it
>>possible to check the existance and value of a given session variable in
>>any of the active sessions?
>>
>>My goal is to make sure a user's access information is not used more
>>than once to log into the system. So, when a user submits the
>>authentication data, I would like to see if that login has already been
>>used, i.e., there is a session variable in some session storing the
>>login name and which contains the same value.
>>
>>At present, I can't think of another way of doing it other than directly
>>accessing the session files on /tmp (assuming session data is being
>>stored in files). But I don't like that idea quite so much. A cleaner
>>solution which I have also considered is to have a column in the users
>>table which indicates his login state. Before I go for the latter
>>approach, I would just like to learn from you whether what I asked is
>>possible.
>>
>>Thanks in advance,
>>
>>--
>>Ney André de Mello Zunino
>>
>>
>
>
>
attached mail follows:
Rather than using this number I'd suggest generating your own, use
mt_rand or uniqid to generate a unique series of numbers and then use
md5 or sha1 to convert them to a hash (I've generated 128 character
session identifiers using a variety of these techniques). You may also
convert it to hex or something similar.
Jason
Susan Ator wrote:
>I have looked and cannot find any information on this particular variable.
>How unique is this id and when does it get generated? I'm looking to use
>this as a session identifier.
>
>Susan
>
>
>
attached mail follows:
Hello,
Im having a bit of trouble with the DATE_FORMAT function in mysql.
$query = ('SELECT username, password, DATE_FORMAT(timestamp, '%d%m%y') FROM custlogon');
I know its failing because php doesnt like the quotation before the format parameters. Ive tried to fix this without any luck. Any Ideas ?
DATE_FORMAT ( timestamp, ' %d%m%y ')
Thanks in advance,
-Dan
attached mail follows:
Dan J. Rychlik wrote:
> $query = ('SELECT username, password, DATE_FORMAT(timestamp, '%d%m%y') FROM custlogon');
Trying enclosing the whole SQL query string in double quotes.
Regards,
--
Ney André de Mello Zunino
attached mail follows:
Tried that, it failed. I recieve undefined index timestamp. when
executing.
----- Original Message -----
From: "Ney André de Mello Zunino" <zunino
unu.edu>
To: <php-general
lists.php.net>
Sent: Tuesday, September 23, 2003 7:04 PM
Subject: [PHP] Re: SQL statement
> Dan J. Rychlik wrote:
>
> > $query = ('SELECT username, password, DATE_FORMAT(timestamp, '%d%m%y')
FROM custlogon');
>
> Trying enclosing the whole SQL query string in double quotes.
>
> Regards,
>
> --
> Ney André de Mello Zunino
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
attached mail follows:
Dan J. Rychlik <mailto:drychlik
tcsconsult.com>
on Tuesday, September 23, 2003 4:58 PM said:
> I know its failing because php doesnt like the quotation before the
> format parameters. Ive tried to fix this without any luck. Any
> Ideas ?
It's failing because the ' before the %d is closing the string.
Here's how I work out SQL stuffs:
$sql = "SELECT username\n"
." , password\n"
." , DATE_FORMAT(timestamp, '%d%m%y')\n"
."FROM custlogon";
$query = ($sql);
Althought it looks like it takes a lot more time to write (which is
true) it looks great when you are debugging.
echo "<pre>$sql</pre>";
Alternatively you should be able to do this:
$query = ("SELECT username, password, DATE_FORMAT(timestamp, '%d%m%y')
FROM custlogon");
chris.
attached mail follows:
Ive used this
$query = ("SELECT username, password, DATE_FORMAT(timestamp, '%d%m%y') FROM
custlogon");
But I recieve unknown index timestamp. *shrug*
----- Original Message -----
From: "Chris W. Parker" <cparker
swatgear.com>
To: "Dan J. Rychlik" <drychlik
tcsconsult.com>; <php-general
lists.php.net>
Sent: Tuesday, September 23, 2003 7:07 PM
Subject: RE: [PHP] SQL statement
> Dan J. Rychlik <mailto:drychlik
tcsconsult.com>
> on Tuesday, September 23, 2003 4:58 PM said:
>
> > I know its failing because php doesnt like the quotation before the
> > format parameters. Ive tried to fix this without any luck. Any
> > Ideas ?
>
> It's failing because the ' before the %d is closing the string.
>
> Here's how I work out SQL stuffs:
>
> $sql = "SELECT username\n"
> ." , password\n"
> ." , DATE_FORMAT(timestamp, '%d%m%y')\n"
> ."FROM custlogon";
>
> $query = ($sql);
>
>
> Althought it looks like it takes a lot more time to write (which is
> true) it looks great when you are debugging.
>
> echo "<pre>$sql</pre>";
>
>
> Alternatively you should be able to do this:
>
> $query = ("SELECT username, password, DATE_FORMAT(timestamp, '%d%m%y')
> FROM custlogon");
>
>
>
> chris.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
attached mail follows:
> Ive used this
> $query = ("SELECT username, password, DATE_FORMAT(timestamp,
> '%d%m%y') FROM
> custlogon");
>
> But I recieve unknown index timestamp. *shrug*
>
>
You are receiving the error on an array returned by fetch_array? If so, it
is because the index is "DATE_FORMAT(timestamp, '%d%m%y')", not timestamp,
which isn't so great. You can see this by doing a print_r on the array to
see what is actually in it. Use aliasing in your query to give it a better
index.
"SELECT username, password, DATE_FORMAT(timestamp, '%d%m%y') as formatted_ts
FROM custlogon" or something like that.
attached mail follows:
Jennifer, you're right, I am using fetch_array... I tried to use your
suggestion, and it failing as well, It wont even execute....
Do you have a better method of looping through all these records??
----- Original Message -----
From: "Jennifer Goodie" <goodie
apollointeractive.com>
To: "Dan J. Rychlik" <drychlik
tcsconsult.com>; "Chris W. Parker"
<cparker
swatgear.com>; <php-general
lists.php.net>
Sent: Tuesday, September 23, 2003 7:15 PM
Subject: RE: [PHP] SQL statement
> > Ive used this
> > $query = ("SELECT username, password, DATE_FORMAT(timestamp,
> > '%d%m%y') FROM
> > custlogon");
> >
> > But I recieve unknown index timestamp. *shrug*
> >
> >
> You are receiving the error on an array returned by fetch_array? If so,
it
> is because the index is "DATE_FORMAT(timestamp, '%d%m%y')", not timestamp,
> which isn't so great. You can see this by doing a print_r on the array to
> see what is actually in it. Use aliasing in your query to give it a
better
> index.
> "SELECT username, password, DATE_FORMAT(timestamp, '%d%m%y') as
formatted_ts
> FROM custlogon" or something like that.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
attached mail follows:
I havent used mysql for a while... but here goes...
http://www.mysql.com/doc/en/Date_and_time_functions.html
DATE_FORMAT(date,format)
Formats the date value according to the format string.
mysql> SELECT DATE_FORMAT('1997-10-04 22:23:00', '%W %M %Y');
-> 'Saturday October 1997'
mysql> SELECT DATE_FORMAT('1997-10-04 22:23:00', '%H:%i:%s');
-> '22:23:00'
it seems that DATE_FORMAT() is expecting a textual date as the first arguement.
try this:
$query = "SELECT username, password, DATE_FORMAT(CURRENT_TIMESTAMP(), '%d%m%y') FROM custlogon";
or if that doesnt work try:
$query = "SELECT username, password, DATE_FORMAT(NOW(), '%d%m%y') FROM custlogon";
> -----Original Message-----
> From: Dan J. Rychlik [mailto:drychlik
tcsconsult.com]
> Sent: Wednesday, 24 September 2003 10:10
> To: Chris W. Parker; php-general
lists.php.net
> Subject: Re: [PHP] SQL statement
>
>
> Ive used this
> $query = ("SELECT username, password, DATE_FORMAT(timestamp,
> '%d%m%y') FROM
> custlogon");
>
> But I recieve unknown index timestamp. *shrug*
>
>
> ----- Original Message -----
> From: "Chris W. Parker" <cparker
swatgear.com>
> To: "Dan J. Rychlik" <drychlik
tcsconsult.com>;
> <php-general
lists.php.net>
> Sent: Tuesday, September 23, 2003 7:07 PM
> Subject: RE: [PHP] SQL statement
>
>
> > Dan J. Rychlik <mailto:drychlik
tcsconsult.com>
> > on Tuesday, September 23, 2003 4:58 PM said:
> >
> > > I know its failing because php doesnt like the quotation
> before the
> > > format parameters. Ive tried to fix this without any luck. Any
> > > Ideas ?
> >
> > It's failing because the ' before the %d is closing the string.
> >
> > Here's how I work out SQL stuffs:
> >
> > $sql = "SELECT username\n"
> > ." , password\n"
> > ." , DATE_FORMAT(timestamp, '%d%m%y')\n"
> > ."FROM custlogon";
> >
> > $query = ($sql);
> >
> >
> > Althought it looks like it takes a lot more time to write (which is
> > true) it looks great when you are debugging.
> >
> > echo "<pre>$sql</pre>";
> >
> >
> > Alternatively you should be able to do this:
> >
> > $query = ("SELECT username, password,
> DATE_FORMAT(timestamp, '%d%m%y')
> > FROM custlogon");
> >
> >
> >
> > chris.
> >
> > --
> > 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
>
>
*************************************************************************************
This e-mail, including any attachments to it, may contain confidential and/or personal information.
If you have received this e-mail in error, you must not copy, distribute, or disclose it, use or take any action
based on the information contained within it.
Please notify the sender immediately by return e-mail of the error and then delete the original e-mail.
The information contained within this e-mail may be solely the opinion of the sender and may not necessarily
reflect the position, beliefs or opinions of Salmat on any issue.
This email has been swept for the presence of computer viruses known to Salmat's anti-virus systems.
For more information, visit our website at www.salmat.com.au.
*************************************************************************************
attached mail follows:
> Jennifer, you're right, I am using fetch_array... I tried to use your
> suggestion, and it failing as well, It wont even execute....
>
> Do you have a better method of looping through all these records??
>
There's probably an error in my SQL syntax. What is mysql_error() telling
you? If it was my query and my database I'd probably know what the problem
is just by looking, but it isn't and I don't.
attached mail follows:
> try this:
>
> $query = "SELECT username, password,
> DATE_FORMAT(CURRENT_TIMESTAMP(), '%d%m%y') FROM custlogon";
>
> or if that doesnt work try:
>
> $query = "SELECT username, password, DATE_FORMAT(NOW(), '%d%m%y')
> FROM custlogon";
[snip]
original query as posted:
SELECT username, password, DATE_FORMAT(timestamp, '%d%m%y') FROM custlogon
[/snip]
Unless timestamp is actually the name of a column in the database, in that
case NOW() and CURRENT_TIMESTAMP() won't give the expected results.
attached mail follows:
On Tue, 23 Sep 2003 19:10:29 -0500
"Dan J. Rychlik" <drychlik
tcsconsult.com> wrote:
> Ive used this
> $query = ("SELECT username, password, DATE_FORMAT(timestamp,
> '%d%m%y') FROM custlogon");
>
> But I recieve unknown index timestamp. *shrug*
>
Is "timestamp" an actual columnname in your table?
--
Raquel
============================================================
It is easy to take liberty for granted when you have never had it
taken from you.
--M. Grundler
--
Raquel
============================================================
It is easy to take liberty for granted when you have never had it
taken from you.
--M. Grundler
attached mail follows:
I dont believe it to be an error because Ive run this from the CLI on my
zeus system. I have also echoed out the sql statement to read exactly what
is being read. The other elements in the record are return as expected,
except for the timestamp in which the DATE_FORMAT mysql function is called.
I know its got to be problem with the string terminators and or the way the
fetch_array reads the elements of a record in my database.
----- Original Message -----
From: "Jennifer Goodie" <goodie
apollointeractive.com>
To: "Dan J. Rychlik" <drychlik
tcsconsult.com>; "Chris W. Parker"
<cparker
swatgear.com>; <php-general
lists.php.net>
Sent: Tuesday, September 23, 2003 7:25 PM
Subject: RE: [PHP] SQL statement
> > Jennifer, you're right, I am using fetch_array... I tried to use your
> > suggestion, and it failing as well, It wont even execute....
> >
> > Do you have a better method of looping through all these records??
> >
>
> There's probably an error in my SQL syntax. What is mysql_error() telling
> you? If it was my query and my database I'd probably know what the
problem
> is just by looking, but it isn't and I don't.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
attached mail follows:
This didnt work as well.
SELECT username, password, DATE_FORMAT(timestamp, '%d%m%y') as formatted_ts
FROM custlogon;
It caused my script to die and not execute at all....
----- Original Message -----
From: "Jennifer Goodie" <goodie
apollointeractive.com>
To: "Dan J. Rychlik" <drychlik
tcsconsult.com>; "Chris W. Parker"
<cparker
swatgear.com>; <php-general
lists.php.net>
Sent: Tuesday, September 23, 2003 7:15 PM
Subject: RE: [PHP] SQL statement
> > Ive used this
> > $query = ("SELECT username, password, DATE_FORMAT(timestamp,
> > '%d%m%y') FROM
> > custlogon");
> >
> > But I recieve unknown index timestamp. *shrug*
> >
> >
> You are receiving the error on an array returned by fetch_array? If so,
it
> is because the index is "DATE_FORMAT(timestamp, '%d%m%y')", not timestamp,
> which isn't so great. You can see this by doing a print_r on the array to
> see what is actually in it. Use aliasing in your query to give it a
better
> index.
> "SELECT username, password, DATE_FORMAT(timestamp, '%d%m%y') as
formatted_ts
> FROM custlogon" or something like that.
>
attached mail follows:
> > > Jennifer, you're right, I am using fetch_array... I tried to use your
> > > suggestion, and it failing as well, It wont even execute....
> > >
> >
> > There's probably an error in my SQL syntax. What is
> mysql_error() telling
> > you?
> I dont believe it to be an error because Ive run this from the CLI on my
> zeus system. I have also echoed out the sql statement to read
> exactly what
> I know its got to be problem with the string terminators and or
> the way the
> fetch_array reads the elements of a record in my database.
Why don't you humor me and tell me what the error is and show me the code
that is generating it. A PHP error message and the output from
mysql_error() will go a long way in debugging a problem. I can't really
work with "it stops working" and "it fails to execute", those don't tell me
much except that there's probably a problem with the query.
attached mail follows:
http://www.mysql.com/doc/en/Reserved_words.html
[snip]
6.1.7 Is MySQL Picky About Reserved Words?
A common problem stems from trying to create a table with column names that use the names of datatypes or functions built into MySQL, such as TIMESTAMP or GROUP. You're allowed to do it (for example, ABS is allowed as a column name). However, by default, in function invocations no whitespace is allowed between the function name and the following `(' character, so that a function call can be distinguished from a reference to a column name.
[/snip]
try renaming the field timestamp to something else and see if that helps?
> -----Original Message-----
> From: Dan J. Rychlik [mailto:drychlik
tcsconsult.com]
> Sent: Wednesday, 24 September 2003 10:32
> To: goodie
apollointeractive.com; Chris W. Parker;
> php-general
lists.php.net
> Subject: Re: [PHP] SQL statement
>
>
> This didnt work as well.
> SELECT username, password, DATE_FORMAT(timestamp, '%d%m%y')
> as formatted_ts
> FROM custlogon;
>
> It caused my script to die and not execute at all....
>
> ----- Original Message -----
> From: "Jennifer Goodie" <goodie
apollointeractive.com>
> To: "Dan J. Rychlik" <drychlik
tcsconsult.com>; "Chris W. Parker"
> <cparker
swatgear.com>; <php-general
lists.php.net>
> Sent: Tuesday, September 23, 2003 7:15 PM
> Subject: RE: [PHP] SQL statement
>
>
> > > Ive used this
> > > $query = ("SELECT username, password, DATE_FORMAT(timestamp,
> > > '%d%m%y') FROM
> > > custlogon");
> > >
> > > But I recieve unknown index timestamp. *shrug*
> > >
> > >
> > You are receiving the error on an array returned by
> fetch_array? If so,
> it
> > is because the index is "DATE_FORMAT(timestamp, '%d%m%y')",
> not timestamp,
> > which isn't so great. You can see this by doing a print_r
> on the array to
> > see what is actually in it. Use aliasing in your query to give it a
> better
> > index.
> > "SELECT username, password, DATE_FORMAT(timestamp, '%d%m%y') as
> formatted_ts
> > FROM custlogon" or something like that.
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
*************************************************************************************
This e-mail, including any attachments to it, may contain confidential and/or personal information.
If you have received this e-mail in error, you must not copy, distribute, or disclose it, use or take any action
based on the information contained within it.
Please notify the sender immediately by return e-mail of the error and then delete the original e-mail.
The information contained within this e-mail may be solely the opinion of the sender and may not necessarily
reflect the position, beliefs or opinions of Salmat on any issue.
This email has been swept for the presence of computer viruses known to Salmat's anti-virus systems.
For more information, visit our website at www.salmat.com.au.
*************************************************************************************
attached mail follows:
Thank you for your time on this. I do apologize for being a pain. Here is
my code...
<?php
// Function that runs reports on logon history
function logonHist() {
db_connect(); //establish connection
$_qlogonhist = ("SELECT username,host_info,status, DATE_FORMAT(timestamp,
'%d%m%y')
as formatted_ts FROM custlogon_hist"); // Build query.
//$_qlogonhist = ('SELECT * FROM custlogon_hist');
$_rlogonhist = mysql_query($_qlogonhist);
?>
<table width="50%" border="0" align="center" cellpadding="0"
cellspacing="0">
<?php
while ($row = mysql_fetch_array($_rlogonhist)) {
?>
<tr>
<td width="27%"><strong><font color="#000000" size="2" face="Arial,
Helvetica, sans-serif">Username</font></strong></td>
<td colspan="3"><font color="#000000" size="2" face="Arial, Helvetica,
sans-serif">
<?php echo $row['username'];?></font></td>
</tr>
<tr>
<td><strong><font color="#000000" size="2" face="Arial, Helvetica,
sans-serif">Host
Info </font></strong></td>
<td colspan="3"><font color="#000000" size="2" face="Arial, Helvetica,
sans-serif">
<?php echo $row['host_info'];?></font></td>
</tr>
<tr>
<td><strong><font color="#000000" size="2" face="Arial, Helvetica,
sans-serif">Status</font></strong></td>
<td colspan="3"><font color="#000000" size="2" face="Arial, Helvetica,
sans-serif">
<?php echo $row['status'];?></font></td>
</tr>
<tr>
<td><strong><font color="#000000" size="2" face="Arial, Helvetica,
sans-serif">Time
Stamp </font></strong></td>
<td colspan="3"><font color="#000000" size="2" face="Arial, Helvetica,
sans-serif">
<?php echo $row['timestamp'];?></font></td>
</tr>
<tr bgcolor="#999999">
<td> </td>
<td width="38%"> </td>
<td colspan="2"> </td>
</tr>
<?php
} // end while
?>
</table>
<?php
} // end function
?>
ERROR
Username drychlik
Host Info 127.0.0.1
Status OK
Time Stamp
Notice: Undefined index: timestamp in C:\Program Files\Apache
Group\Apache2\htdocs\Ameriforms\admintool\includes\getlogonhist.php on line
44
----- Original Message -----
From: "Jennifer Goodie" <goodie
apollointeractive.com>
To: "Dan J. Rychlik" <drychlik
tcsconsult.com>; <php-general
lists.php.net>
Sent: Tuesday, September 23, 2003 7:39 PM
Subject: RE: [PHP] SQL statement
> > > > Jennifer, you're right, I am using fetch_array... I tried to use
your
> > > > suggestion, and it failing as well, It wont even execute....
> > > >
> > >
> > > There's probably an error in my SQL syntax. What is
> > mysql_error() telling
> > > you?
>
> > I dont believe it to be an error because Ive run this from the CLI on my
> > zeus system. I have also echoed out the sql statement to read
> > exactly what
> > I know its got to be problem with the string terminators and or
> > the way the
> > fetch_array reads the elements of a record in my database.
>
>
> Why don't you humor me and tell me what the error is and show me the code
> that is generating it. A PHP error message and the output from
> mysql_error() will go a long way in debugging a problem. I can't really
> work with "it stops working" and "it fails to execute", those don't tell
me
> much except that there's probably a problem with the query.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
attached mail follows:
> http://www.mysql.com/doc/en/Reserved_words.html
>
> [snip]
> 6.1.7 Is MySQL Picky About Reserved Words?
>
> A common problem stems from trying to create a table with column
> names that use the names of datatypes or functions built into
> MySQL, such as TIMESTAMP or GROUP. You're allowed to do it (for
> example, ABS is allowed as a column name). However, by default,
> in function invocations no whitespace is allowed between the
> function name and the following `(' character, so that a function
> call can be distinguished from a reference to a column name.
> [/snip]
>
If you keep scrolling on the page you gave the link for, you'll get to a
list of reserved words and notice that timestamp is not reserved. In fact
if you scroll even farther, you will see that it is explicitly allowed in
mySQL, but that doesn't mean using it is a good idea.
> try renaming the field timestamp to something else and see if that helps?
>
If you are using a reserved word and renaming is not an option you can use
the backtick operator ` to escape it.
attached mail follows:
I tried this, and it failed. Thank you for the suggestion!
----- Original Message -----
From: "Cody Phanekham" <Cody.Phanekham
salmat.com.au>
To: "Dan J. Rychlik" <drychlik