php-general Digest 25 Jan 2004 17:09:27 -0000 Issue 2551
Topics (messages 175670 through 175681):
Re: Form variables + sessions, is this how it is supposed to work? - Grammar corrected
175670 by: Paul
Re: RewriteRule REGEX ?
175671 by: Monty
175675 by: Chris Shiflett
175678 by: DvDmanDT
Re: Using templates (Code & User Interface)
175672 by: -{ Rene Brehmer }-
175677 by: rush
Re: Sample code
175673 by: Paul
Re: porting perl scripts to php
175674 by: David T-G
Re: what PHP really needs
175676 by: electroteque
175679 by: rouvas
cyrillic case converting with ru_RU.utf8 locale
175680 by: Agri
Session not working...
175681 by: Vernon
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
I figured out my problem but I am not sure why this is.
I am trying to implement a back button to allow the user to go back and
change form values.
If I use sessions and register $test then this does not work, the value of
$test does not change if the user re-submits:
<input name="test" type="text" value="<?php echo $test;?>"/>
Thanks for any help!
--- End Message ---
--- Begin Message ---
Actually, it's not the reverse that I want to do.
Right now the pages on my site use this form of URL:
domain.com/articles.php?id=999
Now that I have upgraded my server to Apache 2, I'm going to use the
ForceType and FollowSymLinks options to change the entire site to use this
search-engine-friendly form of URL to access all pages:
domain.com/articles/999
But I don't want the old links to be broken once I change the site to this
new type of URL. So, if someone types in "domain.com/articles.php?id=999",
instead of getting a 404 error, I'd like to use the RewriteEngine to rewrite
that URL to the valid new URL format: domain.com/articles/999.
So, I thought this would work in my .htaccess file, but it doesn't:
RewriteRule articles\.php?id=([0-9]+) articles/$1 [R]
Do I have to escape the ? before id \? I tried it, but it didn't make a
difference. I also tried /articles... but that didn't work, either.
Monty
> From: [EMAIL PROTECTED] (Paul Chvostek)
> Newsgroups: php.general
> Date: Sat, 24 Jan 2004 13:39:25 -0500
> To: Monty <[EMAIL PROTECTED]>
> Subject: Re: RewriteRule REGEX ?
>
>
> On Sat, Jan 24, 2004 at 12:18:36PM -0500, Monty wrote:
>>
>> From This: articles.php?id=999
>> To This: articles/999
> ...
>> What am I doing wrong??
>
> I suspect you may not be looking at the problem the right way.
>
> What exactly do you want to do?
>
> Normally, you'd go the other direction; that is, you'd have mod_rewrite
> recognize ^/articles/([0-9]+)$ and translate it to /articles.php?id=$1
> ... so that a request to the "pretty" URL gets served as an HTTP GET on
> the PHP script.
>
> I get the impression that you're expecting mod_rewrite to translate copy
> from inside your HTML files, as well as recognize and reverse the
> translation when the request comes back in. Is that it?
>
>> RewriteEngine on
>> RewriteRule ^articles\.php\?id=([0-9]+)$ articles/$1 [R]
>
>> But I keep getting a 404 error for articles.php, which means that something
>> must be wrong with my RewriteRule because it's not matching. I've tried
>> various tweaks and just can't get it to work.
>
> I bet if you create an "articles" directory in your documentroot, with
> with files named things like "999" in it, you'll stop seeing the 404's.
> Check your apache error_log.
>
> If what you're trying to achieve is to have existing HTML files get
> their embedded URLs translated, you're going to have to do that with an
> output filter. You can do it with PHP, or use mod_sed ... lots of
> options. But a rewrite rule won't change page content, it'll only
> rewrite the *requests* that come in.
>
> Of course, if you know all this already, and really are trying to point
> requests for /articles.php?id=123 to a file named "123" in the directory
> "articles", then you'll still need to inspect your error_log.
>
> --
> Paul Chvostek <[EMAIL PROTECTED]>
> it.canada http://www.it.ca/
> Free PHP web hosting! http://www.it.ca/web/
--- End Message ---
--- Begin Message ---
--- Monty <[EMAIL PROTECTED]> wrote:
> Right now the pages on my site use this form of URL:
>
> domain.com/articles.php?id=999
>
> Now that I have upgraded my server to Apache 2, I'm going to use
> the ForceType and FollowSymLinks options to change the entire site
> to use this search-engine-friendly form of URL to access all pages:
>
> domain.com/articles/999
>
> But I don't want the old links to be broken once I change the site
> to this new type of URL.
Rather than rewriting URLs like you're attempting, I think you might find
it easier to just use a 404 handler to decide what the best URL is for the
user. This is a good idea in general anyway, since it can help more than
just old URLs, but also typos and the like.
You mention ForceType, so I can assume you're using Apache. Try this in
your httpd.conf or in a .htaccess file:
ErrorDocument 404 /404.php
Then, in /404.php, use $_SERVER['REDIRECT_URL'] to determine where you
should send the user. You can use:
header('Location: http://domain.com/articles/999');
In addition, you can send your own response status code that indicates
that this is a permanent redirect, not a temporary one.
Hope that helps.
Chris
=====
Chris Shiflett - http://shiflett.org/
PHP Security Handbook
Coming mid-2004
HTTP Developer's Handbook
http://httphandbook.org/
--- End Message ---
--- Begin Message ---
Are you sure you have both mod_rewrite and .htaccess installed on the new
apache then? Things like this is often very silly you know, you look past
the problem (I've done that several times)...
RewriteRule "/articles\.php\?id=([0-9]+)$" "/articles/$1"
Although, I've never even used mod_rewrite so I'm not the right person to
ask...
Check the news server news.gmane.org, there you can find most of the Apache
lists..
gmane.comp.apache.user for example... Or on any server, try
alt.apache.configuration, comp.infosystems.www.servers.****
You'll most likely get alot more help there, since those are pointed towards
apache rather than PHP...
--
// DvDmanDT
MSN: dvdmandt€hotmail.com
Mail: dvdmandt€telia.com
"Monty" <[EMAIL PROTECTED]> skrev i meddelandet
news:[EMAIL PROTECTED]
> Actually, it's not the reverse that I want to do.
>
> Right now the pages on my site use this form of URL:
>
> domain.com/articles.php?id=999
>
> Now that I have upgraded my server to Apache 2, I'm going to use the
> ForceType and FollowSymLinks options to change the entire site to use this
> search-engine-friendly form of URL to access all pages:
>
> domain.com/articles/999
>
> But I don't want the old links to be broken once I change the site to this
> new type of URL. So, if someone types in "domain.com/articles.php?id=999",
> instead of getting a 404 error, I'd like to use the RewriteEngine to
rewrite
> that URL to the valid new URL format: domain.com/articles/999.
>
> So, I thought this would work in my .htaccess file, but it doesn't:
>
> RewriteRule articles\.php?id=([0-9]+) articles/$1 [R]
>
> Do I have to escape the ? before id \? I tried it, but it didn't make a
> difference. I also tried /articles... but that didn't work, either.
>
> Monty
>
> > From: [EMAIL PROTECTED] (Paul Chvostek)
> > Newsgroups: php.general
> > Date: Sat, 24 Jan 2004 13:39:25 -0500
> > To: Monty <[EMAIL PROTECTED]>
> > Subject: Re: RewriteRule REGEX ?
> >
> >
> > On Sat, Jan 24, 2004 at 12:18:36PM -0500, Monty wrote:
> >>
> >> From This: articles.php?id=999
> >> To This: articles/999
> > ...
> >> What am I doing wrong??
> >
> > I suspect you may not be looking at the problem the right way.
> >
> > What exactly do you want to do?
> >
> > Normally, you'd go the other direction; that is, you'd have mod_rewrite
> > recognize ^/articles/([0-9]+)$ and translate it to /articles.php?id=$1
> > ... so that a request to the "pretty" URL gets served as an HTTP GET on
> > the PHP script.
> >
> > I get the impression that you're expecting mod_rewrite to translate copy
> > from inside your HTML files, as well as recognize and reverse the
> > translation when the request comes back in. Is that it?
> >
> >> RewriteEngine on
> >> RewriteRule ^articles\.php\?id=([0-9]+)$ articles/$1 [R]
> >
> >> But I keep getting a 404 error for articles.php, which means that
something
> >> must be wrong with my RewriteRule because it's not matching. I've tried
> >> various tweaks and just can't get it to work.
> >
> > I bet if you create an "articles" directory in your documentroot, with
> > with files named things like "999" in it, you'll stop seeing the 404's.
> > Check your apache error_log.
> >
> > If what you're trying to achieve is to have existing HTML files get
> > their embedded URLs translated, you're going to have to do that with an
> > output filter. You can do it with PHP, or use mod_sed ... lots of
> > options. But a rewrite rule won't change page content, it'll only
> > rewrite the *requests* that come in.
> >
> > Of course, if you know all this already, and really are trying to point
> > requests for /articles.php?id=123 to a file named "123" in the directory
> > "articles", then you'll still need to inspect your error_log.
> >
> > --
> > Paul Chvostek <[EMAIL PROTECTED]>
> > it.canada http://www.it.ca/
> > Free PHP web hosting! http://www.it.ca/web/
--- End Message ---
--- Begin Message ---
I wrote my own template system that works very well... I've got an outer
control file that handles the user input, sets the variables for what the
template should use of stylesheets and menus and such, and a variable for
what body to use. All my body files are either PHP programs in themselves
mixed with HTML presentation (I try to keep near all the PHP in the start,
and the actual presentation generation at the end).
Basically it means that the template only holds the basic table structure of
the site, and a little code to include the files that are needed to make it
into what it's suppose to look like.
The way I made it I can use the same template file all over the site, or
make another template and tell the control scripts to use that instead. I
still haven't made it possible for the menu system to change looks though,
but I plan to add that in the future...
It would be very easy to change my system to allow it to use different
templates or other elements based on various conditions....
FWIW
Rene
Fate would have it, that on Sat, 24 Jan 2004 09:53:16 +0300, Hamid Hossain
wrote:
>Hi,
>
>Always I have a problem that I don't know how to make my code away from the
>user interface files.
>
>I tried to use some template classes, but I did'nt like what I tired because
>some if statments are used inside the template.
>
>How can I prepare my code to be working in more that one template? Should I
>use some methodology like FuseBox.org
>
>Regards,
>Hamid Hossain
--
Rene Brehmer
aka Metalbunny
http://metalbunny.net/
References, tools, and other useful stuff...
--- End Message ---
--- Begin Message ---
"Robert Cummings" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> A common misconception is that templates provide complete separation
> from logic, this is untrue. Template frameworks (the best ones) provide
> separation of business logic from presentation logic. So using an "if"
> statement inside a template is completely normal if it pertains to the
> display logic.
My opinon on that is that template system role is to separate presentation
logic from the html which can be considered as resource. Therefore I do not
prefer template systems with embeded control structures in it. But I guess
it is a matter of ones own preferences, and what is "right approach" for
them it is not necessary right for me and other way around.
I completely agree that it is also necessary to separate bussines logic from
the presentation, but I do not think this is a job of template system.
rush
--
http://www.templatetamer.com/
--- End Message ---
--- Begin Message ---
Thanks for any help. Even if I remove the specific default value for the
text input, only the first posted value seems to be accepted and stays
regardless of whether I change it :(
test10.php
-----------
<?php session_register("test");?>
<body>
<a href="test11.php">NEXT</a>
</body>
test11.php
-----------
<?php session_start();?>
<body>
<form name="form1" id="form1" method="post" action="test12.php">
<input name="test" type="text" value="<?php echo $test;?>"/>
<input type="submit" name="Submit" value="Submit" />
</form>
test12.php
-----------
<?php session_start();?>
<body>
<?php echo "HELLO: ".$test ; ?>
<p><a href="test11.php">START OVER</a> </p>
</body>
"Paul" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I figured out my problem but I am not sure why this is.
>
>
>
> I am trying to implement a back button to allow the user to go back and
> change form values.
>
>
>
> If I use sessions and register $test then this does not work, the value of
> $test does not change if the user re-submits:
>
>
>
> <input name="test" type="text" value="<?php echo $test;?>"/>
>
>
>
> Thanks for any help!
--- End Message ---
--- Begin Message ---
Al --
You have started a new thread by taking an existing message and replying to
it while merely changing the Subject: line.
That is bad, because it breaks threading. Whenever you reply to a message,
your mail client generates a "References:" header that tells all recipients
to which posting(s) your posting refers. A mail client uses this information
to build a "thread tree" of the postings so that it is easy to see just how
they relate to each other.
With your posting style you successfully torpedoed this useful feature; your
posting shows up within an existing thread even though it is completely
unrelated.
Always do a fresh post when you want to start a new thread. That means that
you do not select any sort of "Reply" when you start your message. You can
save the list address in your address book (or equivalent) for convenience.
...and then [EMAIL PROTECTED] said...
%
% Hi,
Hi!
%
% I was wondering if there is an easy way to port perl scripts to php, or
% maybe someone could recommend someone who could help me?
The two languages are not terribly different; you may be able to do the
porting on your own if you know php.
You could exec the perl script and get the result if that setup works for
you.
I would be happy to be of service if you would like. Feel free to drop
me a reply.
%
% Thanks,
% Al
HTH & HAND
:-D
--
David T-G * There is too much animal courage in
(play) [EMAIL PROTECTED] * society and not sufficient moral courage.
(work) [EMAIL PROTECTED] -- Mary Baker Eddy, "Science and Health"
http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!
pgp00000.pgp
Description: PGP signature
--- End Message ---
--- Begin Message ---
A database server by nature must assume that all data is equally mutable.
An application developer, however, knows by design how "fresh" any one
piece of data needs to be and can cache accordingly. E.g., don't hit the
database for your site's navigational structure or news articles every
single time, if these things don't change more than a few times per week.
I have found SQL_CACHE to work ok ?
--- End Message ---
--- Begin Message ---
On Friday 23 January 2004 22:33, John W. Holmes wrote:
> From: "Chris Boget" <[EMAIL PROTECTED]>
>
> > >>[snip]
> > >>....
> > >>[/snip]
> > >
> > >Learn and use C++
> >
> > Or sessions.
> > Along with serialize() and deserialize(), all are your friends in this
>
> case.
>
> He's talking about the same set of data being available to all instances of
> PHP, though. I think they're called Application Variables. So if I set
> $instance=1 as an application variable, any other PHP script that runs can
> read that value. I imagine the same thing could be done with an object.
>
> Either that or I'm way off base. It does sound useful, but I see how it
> could be overused and abused.
check "pete M"'s mail in this list, sent at 25 NOV 2003.
As written in that mail
<quote>
Another idea would ne to use an "application" variable..
This is like a Session variable but is site wide
http://0x00.org/php/phpApplication/
regards
Pete
</quote>
-Stathis.
PS: Whatever you need, there is a PHP solution for it. Never doubt about it:-)
>
> ---John Holmes...
--- End Message ---
--- Begin Message ---
all internal strings in my scripts and database are utf-8 encoded
i want to convert case of cyrillic characters in the utf-8 string
i'm setting setlocale (LC_ALL, 'ru_RU.utf8')
using for example ucfirst () and got no any conversion,
case of characters remains the same.
latin characters are succesfully converting.
locale ru_RU.uft8 exist on my system.
did i miss smth? did i get smth wrong?
Agri
PS: i suppose that it is a problem of libc... but i hope...
that smbd had solved the problem here....
--- End Message ---
--- Begin Message ---
I'm in the process of moving to a new server and no sessions are working.
Does something need to be set in the php.ini file? Why would sessions not be
working?
Thanks
--- End Message ---