php-general Digest 16 Apr 2006 06:46:20 -0000 Issue 4074
Topics (messages 234036 through 234059):
Re: refresh PHP page via onclick event
234036 by: tedd
Re: 2 questions: Search in array and detect JS
234037 by: Chrome
234038 by: tedd
234039 by: Chrome
234040 by: cajbecu
234042 by: Chrome
234043 by: fabien champel
234044 by: fabien champel
234045 by: Ryan A
234046 by: Rafael
234051 by: John Wells
Re: Here is a silly question
234041 by: Michelle Konzack
Include Problem
234047 by: Shaun
234048 by: Shaun
234049 by: Chrome
234050 by: Mark Charette
234053 by: Shaun
234054 by: Shaun
234055 by: Al
234057 by: tedd
soapmapper error
234052 by: Alex Duggan
Common Files
234056 by: Shaun
234058 by: chris smith
phpMyAdmin--resetting auto increments to 0
234059 by: alex
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 ---
At 1:40 PM +0200 4/15/06, Alain Roger wrote:
Hi,
Sorry to look like stupid for some of you, but i'm still not able to link to
link (<a> </a>) or to a button via onclick event) the refresh of my page.
i've check META tag and also $PHP_SELF variable, but it does not work.
here is what i would like to do.
i have 1 PHP page on which i have 3 flags (3 images)
if user click on 1 of these flags, $_SESSION['Localization'] is set up to
flag language and the page must be refreshed.
thanks a lot for some help or tutorials.
Alain
Alain:
Try this:
http://www.sperling.com/examples/styleswitch/
The demo jumps from one style sheet to another, but with a little
alteration it could be expanded to solve your problem. It also stores
the user preference in a cookie -- you probably want that as well.
However, it does use a POST in the operation, BUT the switch is so
fast that the user usually doesn't see it added to the url. Try the
above link and see for yourself.
HTH's
tedd
--
--------------------------------------------------------------------------------
http://sperling.com
--- End Message ---
--- Begin Message ---
[snip]
<script language="javascript">
<!--
location.href = '/url/for/ajax/page.php';
-->
</script>
[/snip]
My only concern with this method is that it constitutes an exit trap... For
example, if a user connects to your index page from, say, Google they will
be redirected over to your Ajax page... All good, except if they click Back
to return to the SE page they will immediately bounce back to your Ajax page
Something to consider might be:
<noscript>
Sorry! This page requires Javascript to function properly! Please enable it
or get a decent browser
</noscript>
<!-- Normal page functions -->
I haven't tested it so there is a chance it's fiction :)
Of course, if web standards aren't a concern it makes no difference
HTH
Dan
-------------------
http://chrome.me.uk
-----Original Message-----
From: Ryan A [mailto:[EMAIL PROTECTED]
Sent: 15 April 2006 14:26
To: php
Cc: "Stut"
Subject: Re: [PHP] 2 questions: Search in array and detect JS
Hey Stut,
Thanks for replying.
-------------------
The way I do this is to serve the 'notmal page' first, but with the
following snippet of JS in it...
<script language="javascript">
<!--
location.href = '/url/for/ajax/page.php';
-->
</script>----------------------Makes sense and pretty easy, this was
suggested a while back, since you have supported itI think I'll start using
this method.------------------- You should be able to craft some combination
of array_walk and a custom
function that checks each element with stristr to do what you need.
-------------Actually, I solved this thanks to Richard from the list who
suggested strpos, a function I had never usedbefore ( Tedd from the list
gave me the same suggestion as you to use stristr, I didnt want to use
stristr as its a bit expensive esp with a really large array) the problem I
ran into was that strpos is a php5 function....but reading the user
contributed articles on strpos at thephp site I got the code that does
exactly that in 2-3 linesCheers!
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
__________ NOD32 1.1490 (20060415) Information __________
This message was checked by NOD32 antivirus system.
http://www.eset.com
--- End Message ---
--- Begin Message ---
Something to consider might be:
<noscript>
Sorry! This page requires Javascript to function properly! Please enable it
or get a decent browser
</noscript>
<!-- Normal page functions -->
I haven't tested it so there is a chance it's fiction :)
Of course, if web standards aren't a concern it makes no difference
Dan
It works and if you want it to validate, just enclose the paragraph
in <p></p>, like so:
<noscript>
<p>
Sorry! This page requires Javascript to function properly! Please enable it
or get a decent browser.
</p>
</noscript>
To bad that php within those tags is read regardless or we would have
an easy way to detect js.
tedd
--
--------------------------------------------------------------------------------
http://sperling.com
--- End Message ---
--- Begin Message ---
How about
<?php $js = true; ?>
<noscript>
<?php $js = false; ?>
</noscript>
<?php
if ($js) {
// whizzy Ajax code (or file include)
} else {
// generic warning (or include non-JS base file)
}
?>
I know that would work but does it give the desired effect?
Dan
-------------------
http://chrome.me.uk
-----Original Message-----
From: tedd [mailto:[EMAIL PROTECTED]
Sent: 15 April 2006 15:10
To: Chrome; 'Ryan A'; 'php'
Cc: '"Stut"'
Subject: RE: [PHP] 2 questions: Search in array and detect JS
>Something to consider might be:
>
><noscript>
>Sorry! This page requires Javascript to function properly! Please enable it
>or get a decent browser
></noscript>
>
><!-- Normal page functions -->
>
>I haven't tested it so there is a chance it's fiction :)
>
>Of course, if web standards aren't a concern it makes no difference
>
>Dan
It works and if you want it to validate, just enclose the paragraph
in <p></p>, like so:
<noscript>
<p>
Sorry! This page requires Javascript to function properly! Please enable it
or get a decent browser.
</p>
</noscript>
To bad that php within those tags is read regardless or we would have
an easy way to detect js.
tedd
--
----------------------------------------------------------------------------
----
http://sperling.com
__________ NOD32 1.1490 (20060415) Information __________
This message was checked by NOD32 antivirus system.
http://www.eset.com
--- End Message ---
--- Begin Message ---
In your script, $js will be false false!
Chrome wrote:
> How about
>
> <?php $js = true; ?>
>
> <noscript>
> <?php $js = false; ?>
> </noscript>
>
> <?php
> if ($js) {
> // whizzy Ajax code (or file include)
> } else {
> // generic warning (or include non-JS base file)
> }
> ?>
>
> I know that would work but does it give the desired effect?
>
> Dan
>
>
> -------------------
> http://chrome.me.uk
>
>
> -----Original Message-----
> From: tedd [mailto:[EMAIL PROTECTED]
> Sent: 15 April 2006 15:10
> To: Chrome; 'Ryan A'; 'php'
> Cc: '"Stut"'
> Subject: RE: [PHP] 2 questions: Search in array and detect JS
>
>> Something to consider might be:
>>
>> <noscript>
>> Sorry! This page requires Javascript to function properly! Please enable it
>> or get a decent browser
>> </noscript>
>>
>> <!-- Normal page functions -->
>>
>> I haven't tested it so there is a chance it's fiction :)
>>
>> Of course, if web standards aren't a concern it makes no difference
>>
>> Dan
>
>
> It works and if you want it to validate, just enclose the paragraph
> in <p></p>, like so:
>
> <noscript>
> <p>
> Sorry! This page requires Javascript to function properly! Please enable it
> or get a decent browser.
> </p>
> </noscript>
>
> To bad that php within those tags is read regardless or we would have
> an easy way to detect js.
>
> tedd
--- End Message ---
--- Begin Message ---
Yep just realised my half-witted mistake (and what tedd was getting at)
Sorry about that
Dan
-------------------
http://chrome.me.uk
-----Original Message-----
From: cajbecu [mailto:[EMAIL PROTECTED]
Sent: 15 April 2006 15:40
To: Chrome
Cc: 'tedd'; 'Ryan A'; 'php'; '"Stut"'
Subject: Re: [PHP] 2 questions: Search in array and detect JS
In your script, $js will be false false!
Chrome wrote:
> How about
>
> <?php $js = true; ?>
>
> <noscript>
> <?php $js = false; ?>
> </noscript>
>
> <?php
> if ($js) {
> // whizzy Ajax code (or file include)
> } else {
> // generic warning (or include non-JS base file)
> }
> ?>
>
> I know that would work but does it give the desired effect?
>
> Dan
>
>
> -------------------
> http://chrome.me.uk
>
>
> -----Original Message-----
> From: tedd [mailto:[EMAIL PROTECTED]
> Sent: 15 April 2006 15:10
> To: Chrome; 'Ryan A'; 'php'
> Cc: '"Stut"'
> Subject: RE: [PHP] 2 questions: Search in array and detect JS
>
>> Something to consider might be:
>>
>> <noscript>
>> Sorry! This page requires Javascript to function properly! Please enable
it
>> or get a decent browser
>> </noscript>
>>
>> <!-- Normal page functions -->
>>
>> I haven't tested it so there is a chance it's fiction :)
>>
>> Of course, if web standards aren't a concern it makes no difference
>>
>> Dan
>
>
> It works and if you want it to validate, just enclose the paragraph
> in <p></p>, like so:
>
> <noscript>
> <p>
> Sorry! This page requires Javascript to function properly! Please enable
it
> or get a decent browser.
> </p>
> </noscript>
>
> To bad that php within those tags is read regardless or we would have
> an easy way to detect js.
>
> tedd
__________ NOD32 1.1490 (20060415) Information __________
This message was checked by NOD32 antivirus system.
http://www.eset.com
--- End Message ---
--- Begin Message ---
js is client-side, php server side...
it can't work
fabien
Chrome wrote:
> How about
>
> <?php $js = true; ?>
>
> <noscript>
> <?php $js = false; ?>
> </noscript>
>
> <?php
> if ($js) {
> // whizzy Ajax code (or file include)
> } else {
> // generic warning (or include non-JS base file)
> }
> ?>
>
> I know that would work but does it give the desired effect?
>
> Dan
>
>
> -------------------
> http://chrome.me.uk
--- End Message ---
--- Begin Message ---
for js detection, you can use that in a previous page :
<script type="text/javascript">
document.write('<a href="ajax-page.html">page</a>');
</script>
<noscript><a href="simple-page.html">page</a></noscript>
it is simple, and work fine.
no need to have cookies enable
--- End Message ---
--- Begin Message ---
Hey,
Thanks for replying.
------------------------
for js detection, you can use that in a previous page :
<script type="text/javascript">
document.write('<a href="ajax-page.html">page</a>');
</script>
<noscript><a href="simple-page.html">page</a></noscript>
it is simple, and work fine.
no need to have cookies enable-----------------------------Nice, most of the
methods discussed focuses on the fact that you are sending this person from
a previous page,eg:index.php to-> contact_us.phpbut what if you are using
AJAX on the first page (eg: index.php)then isnt the " location.href =
'/url/for/ajax/index2/page.php';" the best solution?Cheers!Ryan
--- End Message ---
--- Begin Message ---
Ryan A wrote:
Hi,
Like the subject says; I have two questions:
1) Is it possible to detect JavaScript via php... and yes I do know that JS
is client side while PHP is server...but how else to do it?
The reason I ask is before serving an AJAX page I would like to make sure JS
is enabled, if not, serve the other "normal page"... I am sure I am not the
first person to come accross this little problem, how did you solve it?
I have seen some suggestions on google like having a hidden form field and
using js to put a value in it, if it exists when the form is sent then JS
is on..if not, its not... but that method is not the best in an AJAX
situation...right?
You don't specifically what would change in the "AJAX page" (other than
make use of AJAX) If it's possible, I would recommend you to serve the
normal page and include a snippet to modify its behaviour, so you can
"save the page reloads" (tipical use for AJAX), e.g.
window.onload = function( ) {
if ( document.frmTest ) {
document.frmTest.onSubmit = function( ) {
// verify values with ajax before submiting
}
}
}
// "normal version" of the page
This way you only change the behaviour when its supported (of course,
you would also need a verification for Remote Scripting/AJAX support)
And I agree with the others about serving the "normal version" first,
and redirecting via JS (when the behaviour is too different)
2) How can I search in an array for a particular word?
eg: in an array "movie" I have this kind of data:
movie_name=> some movie
cast=> Jim Carrey, Richard Pryor, Eddie Murphy
I want to search on either "Richard" or "Richard Pryor" (must be case
insensitive too)
something like a SELECT with a LIKE %% statement
I have been fooling around with in_array() but not getting anywhere
fast..... am I on the right track?
Links, code examples or advise would be as always....appreciated.
First, I would suggest you to re-analize why are you searching in an
array (of course, you're the only here who knows the reason)
Second, you may encounter array_filter() useful, this function uses a
callback user-defined function to "filter" the elements in a given array
and build a second (which is the value it returns), so you may use this
function along with strpos() (or some other)
http://php.net/manual/en/function.array-filter.php
--
Atentamente,
J. Rafael Salazar MagaƱa
Innox - Innovación Inteligente
Tel: +52 (33) 3615 5348 ext. 205 / 01 800 2-SOFTWARE
http://www.innox.com.mx
--- End Message ---
--- Begin Message ---
On 4/14/06, Ryan A <[EMAIL PROTECTED]> wrote:
> The reason I ask is before serving an AJAX page I would like to make sure JS
> is enabled, if not, serve the other "normal page"... I am sure I am not the
> first person to come accross this little problem, how did you solve it?
Dan eluded to a big problem here, regarding the potential "exit trap"
of redirecting a user to a different page. However there's even more
at stake--this solution would require you to manage *two* versions of
your page. Come on, we can do better than that...
What you should do is create your "normal page" as is, and then write
your javascript to "attach" itself to whatever things you want to
AJAXify on that page. Research "unobtrusive javascript", it should
get you in the right direction.
The idea is, you build your page to function normally without any
javascript. Then you attempt to hook up the javascript via your
page's onload event (there are other methods too I believe, Google
it). If javascript is enabled, then the javascript will be hooked in;
if not, then no AJAX will be loaded, but your page will still function
as needed.
HTH,
John W
--- End Message ---
--- Begin Message ---
Am 2006-04-03 11:58:39, schrieb Wolf:
> I tend to stick "/nav/header.php" in for my includes, since I control
> the server.
>
> As long as the site translates root to the main directory of your
> website and not somewhere else, you can always have your links be
> "/menu.php" as server-speak "/" means rootme.
>
> I also use "/" in my href links in my menus and such so that no matter
> where the script is called from, it always works.
But he is talking about includes,
which mean NOT THE WEB-ROOT but the OS-ROOT.
Greetings
Michelle Konzack
--
Linux-User #280138 with the Linux Counter, http://counter.li.org/
##################### Debian GNU/Linux Consultant #####################
Michelle Konzack Apt. 917 ICQ #328449886
50, rue de Soultz MSM LinuxMichi
0033/3/88452356 67100 Strasbourg/France IRC #Debian (irc.icq.com)
--- End Message ---
--- Begin Message ---
Hi,
I am having problems with an include statement, i am using the following
statement in an effort to include a footer file on my page:
include("/cms/templates/footer.php");
However I get the following error:
Warning: main(/cms/templates/footer.php): failed to open stream: No such
file or directory in /home/m/y/mysite/public_html/cms/news/index.php on line
38
Warning: main(/cms/templates/footer.php): failed to open stream: No such
file or directory in /home/m/y/mysite/public_html/cms/news/index.php on line
38
Warning: main(): Failed opening '/cms/templates/footer.php' for inclusion
(include_path='.:/lib/php') in
/home/m/y/mysite/public_html/cms/news/index.php on line 38
The file is definitely there, the script just doesn't seem to be picking it
up, has anyone else had this problem?
--- End Message ---
--- Begin Message ---
Hi,
I am having problems with an include statement, i am using the following
statement in an effort to include a footer file on my page:
include("/cms/templates/footer.php");
However I get the following error:
Warning: main(/cms/templates/footer.php): failed to open stream: No such
file or directory in /home/m/y/mysite/public_html/cms/news/index.php on line
38
Warning: main(/cms/templates/footer.php): failed to open stream: No such
file or directory in /home/m/y/mysite/public_html/cms/news/index.php on line
38
Warning: main(): Failed opening '/cms/templates/footer.php' for inclusion
(include_path='.:/lib/php') in
/home/m/y/mysite/public_html/cms/news/index.php on line 38
The file is definitely there, the script just doesn't seem to be picking it
up, has anyone else had this problem?
--- End Message ---
--- Begin Message ---
Try
include($_SERVER['DOCUMENT_ROOT'] . "/cms/templates/footer.php");
maybe?
Dan
-------------------
http://chrome.me.uk
-----Original Message-----
From: Shaun [mailto:[EMAIL PROTECTED]
Sent: 15 April 2006 20:05
To: [email protected]
Subject: [PHP] Include Problem
Hi,
I am having problems with an include statement, i am using the following
statement in an effort to include a footer file on my page:
include("/cms/templates/footer.php");
However I get the following error:
Warning: main(/cms/templates/footer.php): failed to open stream: No such
file or directory in /home/m/y/mysite/public_html/cms/news/index.php on line
38
Warning: main(/cms/templates/footer.php): failed to open stream: No such
file or directory in /home/m/y/mysite/public_html/cms/news/index.php on line
38
Warning: main(): Failed opening '/cms/templates/footer.php' for inclusion
(include_path='.:/lib/php') in
/home/m/y/mysite/public_html/cms/news/index.php on line 38
The file is definitely there, the script just doesn't seem to be picking it
up, has anyone else had this problem?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
__________ NOD32 1.1490 (20060415) Information __________
This message was checked by NOD32 antivirus system.
http://www.eset.com
--- End Message ---
--- Begin Message ---
Shaun wrote:
Warning: main(/cms/templates/footer.php): failed to open stream: No such
file or directory in /home/m/y/mysite/public_html/cms/news/index.php on line
38
Most assuredly the file isn't there (do you have the include path set?)
or the permissions are not sufficient to open the file.
--- End Message ---
--- Begin Message ---
"Mark Charette" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Shaun wrote:
>> Warning: main(/cms/templates/footer.php): failed to open stream: No such
>> file or directory in /home/m/y/mysite/public_html/cms/news/index.php on
>> line
>> 38
>>
> Most assuredly the file isn't there (do you have the include path set?) or
> the permissions are not sufficient to open the file.
include_path = .:/lib/php
--- End Message ---
--- Begin Message ---
$_SERVER['DOCUMENT_ROOT'] = /home
this isnt the correct path for the file!
""Chrome"" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Try
>
> include($_SERVER['DOCUMENT_ROOT'] . "/cms/templates/footer.php");
>
> maybe?
>
> Dan
>
> -------------------
> http://chrome.me.uk
>
>
> -----Original Message-----
> From: Shaun [mailto:[EMAIL PROTECTED]
> Sent: 15 April 2006 20:05
> To: [email protected]
> Subject: [PHP] Include Problem
>
> Hi,
>
> I am having problems with an include statement, i am using the following
> statement in an effort to include a footer file on my page:
>
> include("/cms/templates/footer.php");
>
> However I get the following error:
>
> Warning: main(/cms/templates/footer.php): failed to open stream: No such
> file or directory in /home/m/y/mysite/public_html/cms/news/index.php on
> line
> 38
>
> Warning: main(/cms/templates/footer.php): failed to open stream: No such
> file or directory in /home/m/y/mysite/public_html/cms/news/index.php on
> line
> 38
>
> Warning: main(): Failed opening '/cms/templates/footer.php' for inclusion
> (include_path='.:/lib/php') in
> /home/m/y/mysite/public_html/cms/news/index.php on line 38
>
> The file is definitely there, the script just doesn't seem to be picking
> it
> up, has anyone else had this problem?
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
> __________ NOD32 1.1490 (20060415) Information __________
>
> This message was checked by NOD32 antivirus system.
> http://www.eset.com
--- End Message ---
--- Begin Message ---
Check the file's permissions with your ftp utility
Shaun wrote:
Hi,
I am having problems with an include statement, i am using the following
statement in an effort to include a footer file on my page:
include("/cms/templates/footer.php");
However I get the following error:
Warning: main(/cms/templates/footer.php): failed to open stream: No such
file or directory in /home/m/y/mysite/public_html/cms/news/index.php on line
38
Warning: main(/cms/templates/footer.php): failed to open stream: No such
file or directory in /home/m/y/mysite/public_html/cms/news/index.php on line
38
Warning: main(): Failed opening '/cms/templates/footer.php' for inclusion
(include_path='.:/lib/php') in
/home/m/y/mysite/public_html/cms/news/index.php on line 38
The file is definitely there, the script just doesn't seem to be picking it
up, has anyone else had this problem?
--- End Message ---
--- Begin Message ---
At 8:03 PM +0100 4/15/06, Shaun wrote:
Hi,
I am having problems with an include statement, i am using the following
statement in an effort to include a footer file on my page:
include("/cms/templates/footer.php");
However I get the following error:
Warning: main(/cms/templates/footer.php): failed to open stream: No such
file or directory in /home/m/y/mysite/public_html/cms/news/index.php on line
38
Warning: main(/cms/templates/footer.php): failed to open stream: No such
file or directory in /home/m/y/mysite/public_html/cms/news/index.php on line
38
Warning: main(): Failed opening '/cms/templates/footer.php' for inclusion
(include_path='.:/lib/php') in
/home/m/y/mysite/public_html/cms/news/index.php on line 38
The file is definitely there, the script just doesn't seem to be picking it
up, has anyone else had this problem?
With your code, I get the exact same error -- however, I don't have
the file nor the correct path.
So, I think you need to check the path. Try putting the following
code in your footer.php and running it directly:
print_r($_SERVER['SCRIPT_FILENAME']);
That will tell you where the script is located.
My guess is that you have a path error somewhere.
hth's
tedd
--
--------------------------------------------------------------------------------
http://sperling.com
--- End Message ---
--- Begin Message ---
Hello,
I am trying to connect to a webservice with a wsdl. After creating a
new SoapClient, I tried calling one of the methods. It returned this
exception.
Uncaught SoapFault exception: [SOAP-ENV:Server] SoapMapper:Converting
data for SoapMapper failed inside the typemapper
in /home/aldug/soap_test.php
Other methods on this webservice work fine. How do I go about debugging
this problem?
Thanks,
Alex
--- End Message ---
--- Begin Message ---
Hi,
We have a dedicated UNIX server running FreeBSD, is it possible to set a
directory where we can place a set of common files that can be used by all
of our web sites?
Thanks for your advice
--- End Message ---
--- Begin Message ---
> We have a dedicated UNIX server running FreeBSD, is it possible to set a
> directory where we can place a set of common files that can be used by all
> of our web sites?
Sure. Chuck them where-ever you want and then change your include path:
http://www.php.net/manual/en/ini.core.php
http://www.php.net/manual/en/function.set-include-path.php
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
hi everyone
i have delete a few entries in my database as they were entered for testing
purposes and are no longer need (actually 102 entries)... and even thought
that db is empty i noticed that when the next entry went in the id number
went to 103
not 0 so i was wondering is it possible to somehow reset the value to
zero...
it is of int type and auto_increment
i have a few db's which id like to reset to zero i have tried placing a zero
enrty after deleting the lot but it only jumps to its next increment.
does anyone know what i mean...?
any help will be grateful
regards alex
--- End Message ---