php-general Digest 20 Jan 2010 15:22:20 -0000 Issue 6548
Topics (messages 301235 through 301261):
Re: Cookies & sessions
301235 by: Phpster
301236 by: clancy_1.cybec.com.au
301238 by: clancy_1.cybec.com.au
301251 by: Ashley Sheridan
how to retrieve a dom from innerHTML......
301237 by: I am on the top of the world! Borlange University
301247 by: Pete Ford
How do I remove unused GET parameters from the URL?
301239 by: Daevid Vincent
301240 by: Michael A. Peters
301241 by: Michael A. Peters
301248 by: Rene Veerman
301252 by: Ashley Sheridan
Re: 304 Not Modified header not working within a class
301242 by: Camilo Sperberg
301245 by: Rene Veerman
301246 by: richard gray
Re: PHP and javascript
301243 by: Rene Veerman
301244 by: Rene Veerman
could use some suggestions to speed this short piece of code up
301249 by: Rene Veerman
301253 by: tedd
Re: Object Oriented Programming question
301250 by: Jay Blanchard
301259 by: tedd
301261 by: Paul M Foster
Re: 64 Bit IIS 6 ( 32 Bit mode ) + 32Bit php connect with MS-SQL Server
301254 by: Edward S.P. Leong
301255 by: Richard Quadling
301256 by: Richard Quadling
301257 by: Edward S.P. Leong
301258 by: Richard Quadling
301260 by: Edward S.P. Leong
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 ---
The first setcookie call is empty which produces the errors that cause
the second cookie to fail.
Bastien
Sent from my iPod
On Jan 19, 2010, at 10:16 PM, [email protected] wrote:
On Tue, 19 Jan 2010 09:12:17 -0200, [email protected] (Bruno
Fajardo) wrote:
2010/1/19 <[email protected]>:
I am trying for the first time to use cookies. The manual contains
the statement "Cookies
are part of the HTTP header, so setcookie() must be called before
any output is sent to
the browser."
When I first started using sessions, I was alarmed to read a very
similar statement about
sessions, but I soon found that if I started my program with the
statement
"session_start();" I could then set up, access, modify or clear
any session variable at
any time in my program. This is enormously useful, as I can put
the session handling at
any convenient point in my program, and can precede them with
diagnostics if I need to.
However I have almost immediately found that while I appear to be
able to read cookies at
any time, I cannot set them when I would like to. Is there any
similar trick which will
work with cookies?
The only trick is that you have to call setcookie() before any output
is sent to the browser, just like the session_start() behavior.
......
Thank you all for your suggestions. Unfortunately I have already
tried this, and it
doesn't work for me (I am running PHP: 5.1.6). I have only tested
this on my own PC, but
if it doesn't work here, I would be very surprised if it would work
on the remote server.
Index.php starts:
<?php //;V;;; Cypalda/Index.php Printed:
session_start ();
setcookie ();
setcookie ('user_id', 'Wilma*Witgenstein', time()+3600);
And this produces the following output:
Warning: setcookie() expects at least 1 parameter, 0 given in
D:\Websites\cypalda.com\index.php on line 4
Warning: Cannot modify header information - headers already sent by
(output started at
D:\Websites\cypalda.com\index.php:4) in D:\Websites\cypalda.com
\index.php on line 5
It is interesting to note that the second diagnostic is generated
because the first
diagnostic is taken to have initiated the headers. I think I can
live with this
limitation, but this diagnostic is a warning of the hassles I am
likely to face if I
cannot find a way around it.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
On Tue, 19 Jan 2010 16:45:37 +0530, [email protected] (kranthi) wrote:
>> When I first started using sessions, I was alarmed to read a very similar
>> statement about
>> sessions, but I soon found that if I started my program with the statement
>> "session_start();" I could then set up, access, modify or clear any session
>> variable at
>> any time in my program. This is enormously useful, as I can put the session
>> handling at
>> any convenient point in my program, and can precede them with diagnostics if
>> I need to.
>
>are you looking for ob_* functions ?
Yes, thank you; I was!
I read this, and said "what the hell are they?", before I tried Bruno's
setcookie() again,
and verified it didn't work. Then I noticed a textbook buried on my desk opened
to the
section on cookies, saw "output buffering", and realised what you were talking
about. And,
yes, they do seem to let me do what I want.
Unfortunately they don't do one thing I would have liked them to, which is to
enable me to
see diagnostics buried in CSS code. The only way to discover these is to use
the Explorer
'View source' option, and examine the HTML very carefully. While I was fiddling
with the
setcookie suggestion some diagnostics went missing (because I was running the
wrong
version), and when I looked at the HTML I found some error messages relating to
an
undefined variable in the CSS, which I fear have been there for a long time.
--- End Message ---
--- Begin Message ---
On Tue, 19 Jan 2010 22:45:14 -0500, [email protected] (Phpster) wrote:
>The first setcookie call is empty which produces the errors that cause
>the second cookie to fail.
I'm afraid not. I modified the program started to read:
<?php //;V;;; Cypalda/Index.php Printed: 21/3/09
session_start ();
setcookie ('Try_1', 'Works', time()+3600);
echo ' ';
setcookie ('Try_2', 'Doesnt', time()+3600);
With the result
Warning: Cannot modify header information - headers already sent by (output
started at
D:\Websites\cypalda.com\index.php:6) in D:\Websites\cypalda.com\index.php on
line 7
And cookie 'Try_2' is not set.
I suspect you have been running with output buffering on, but I had left it in
the default
state, which is off.
--- End Message ---
--- Begin Message ---
On Wed, 2010-01-20 at 15:45 +1100, [email protected] wrote:
> On Tue, 19 Jan 2010 22:45:14 -0500, [email protected] (Phpster) wrote:
>
> >The first setcookie call is empty which produces the errors that cause
> >the second cookie to fail.
>
> I'm afraid not. I modified the program started to read:
>
> <?php //;V;;; Cypalda/Index.php Printed: 21/3/09
>
> session_start ();
>
> setcookie ('Try_1', 'Works', time()+3600);
> echo ' ';
> setcookie ('Try_2', 'Doesnt', time()+3600);
>
> With the result
>
> Warning: Cannot modify header information - headers already sent by (output
> started at
> D:\Websites\cypalda.com\index.php:6) in D:\Websites\cypalda.com\index.php on
> line 7
>
> And cookie 'Try_2' is not set.
>
> I suspect you have been running with output buffering on, but I had left it
> in the default
> state, which is off.
>
>
Well the problem here is obvious, you just changed the line that was
causing the error to another line that causes another error! Why do you
need to echo a space character? Remove that line and you will get rid of
this new error.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
hello, i can obnot retrieve a select ject from div innerHTML.
what i want to do is that when a page is loaded, first selector,say #1,
would be shown in the first div by sending a request.then i choose one
option from #1, fire change event of #1, the second selector #2 will be
shown in div two, then choose option from #2 .............blabla..
but the problem is when selector #1 was loaded, the object #1 could not be
obtained.
codes:
window.addEvent('domready', function() {
var option=1;
var result = new Request({
url:'getInfo_gx.php'<https://mail.google.com/mail/html/compose/static_files/'getInfo_gx.php'>
,
method:'get',
onSuccess:function(response)
{
if(option==1) $('list_sch').innerHTML = response; //response =
"<select id='sch_list><.......'";
else if(option==2) $('list_gg').innerHTML = response;
else $('list_gx').innerHTML = response;
}
});
result.send('type=1'); // page loaded,sending a request.
$('list_sch').innerHTML = "<select id='sch_list'><option
value='123'>123312</option></select>";
if($('sch_list')) // heres the problem... object can not
be obtained.
{
$('sch_list').addEvent('change',function(){ // events
can not be fired
option=2;
result.send('type=2'+'&sch='+$('sch_list').value.replace('+','%2B'));
});
}
});
--- End Message ---
--- Begin Message ---
I am on the top of the world! Borlange University wrote:
hello, i can obnot retrieve a select ject from div innerHTML.
what i want to do is that when a page is loaded, first selector,say #1,
would be shown in the first div by sending a request.then i choose one
option from #1, fire change event of #1, the second selector #2 will be
shown in div two, then choose option from #2 .............blabla..
but the problem is when selector #1 was loaded, the object #1 could not be
obtained.
codes:
window.addEvent('domready', function() {
var option=1;
var result = new Request({
url:'getInfo_gx.php'<https://mail.google.com/mail/html/compose/static_files/'getInfo_gx.php'>
,
method:'get',
onSuccess:function(response)
{
if(option==1) $('list_sch').innerHTML = response; //response =
"<select id='sch_list><.......'";
else if(option==2) $('list_gg').innerHTML = response;
else $('list_gx').innerHTML = response;
}
});
result.send('type=1'); // page loaded,sending a request.
$('list_sch').innerHTML = "<select id='sch_list'><option
value='123'>123312</option></select>";
if($('sch_list')) // heres the problem... object can not
be obtained.
{
$('sch_list').addEvent('change',function(){ // events
can not be fired
option=2;
result.send('type=2'+'&sch='+$('sch_list').value.replace('+','%2B'));
});
}
});
You probably ought to ask a Javascript forum about javascript problems...
--- End Message ---
--- Begin Message ---
I have an HTML form with a hundred or so elements on it, used for searching
a database.
When the user submits the form (via GET) the URL is loaded with ALL of
these fields, and many of them are not even actually used in the search
criteria.
https://mypse/dart2/ps_search.php?enter_date=2009-11-30&id_incident=&incide
nt_date=&incident_hh=0&incident_mm=0&id_urgency_level=0&problem_description
=&immediate_action=&unit_opened=&unit_authorized=&customer=&customer_contac
t=&customer_address=&customer_country=&id_location=0&passengers_onboard=&su
bmit=Search&part_number=&serial_number=&nomenclature=&manufacture_date=&mod
_level=&id_lru_condition=&repair_history=&ac_type=&tail_number=&id_system_t
ype=&id_lru_location=0&circuit_breaker=&circuit_breaker_amps=&seat_number=&
seat_vendor=&seat_column_zone=&seat_zone=&tc_holder=&stc_holder=&asr_mor=&i
mpounded=&id_authority=&id_region=&reported_by=&prepared_by=&preparer_locat
ion=&field_engineer=&id_attach_pictures=&id_attach_mlr=&id_attach_lopa=&cab
in_log=&parts_inspect=&id_organization=0&id_quality_engineer=0&car_number=&
close_date=&closed_by=&qa_comment=&id_priority=&id_action=0&id_incident_sta
tus=3&id_failure_type=&detail_status=&investigation_result=&osaka_action=&o
saka_request=&newvsrepeat=&related_incident=&unit_received_date=&unit_retur
ned_date=&tdr_to_pso_date=&tdr_date=&dcr_date=&dcr_reference_number=&ecr_da
te=&ecr_reference_number=&eco_date=&eco_reference_number=&service_bulletin_
date=&sb_reference_number=&sil_issue_date=&sil_reference_number=&til_issue_
date=&til_reference_number=&customer_letter_issue_date=&subassembly=&rdm=&p
svector=&oemmanuf=&defective_part_1=&defective_part_2=&defective_part_3=&de
fective_part_4=
Is there some way via PHP/Apache Mod/Javascript to remove all the keys that
don't have any value in them and just distill this down to the
elements/keys that the user actually entered some input for? ie. defaulting
all the rest to 'blank'.
In PHP, this would look something like this:
foreach ($_GET as $k => $v) if ($v == '') unset($_GET[$k]);
The problem as I see it, is that this "magic" happens when the user hits
"Submit", so not sure PHP has any way to intercept at that point.
Javascript might be able to do something on the "onClick" event or
"onSubmit" I suspect. But this seems like something that someone should
have solved before and common enough that I would think Apache could handle
it transparently with a directive or module enabled so I don't have to code
some hack on every page.
I guess I could always redirect to some 'scrubber' page that strips them
out and redirects on to the refering page again, but that seems klunky.
BTW, I want to use GET so that the page can be bookmarked for future
searches of the same data (or modified easily with different dates, etc.),
so that's why I don't use POST.
--- End Message ---
--- Begin Message ---
Daevid Vincent wrote:
*snip*
The problem as I see it, is that this "magic" happens when the user hits
"Submit", so not sure PHP has any way to intercept at that point.
Javascript might be able to do something on the "onClick" event or
"onSubmit" I suspect. But this seems like something that someone should
have solved before and common enough that I would think Apache could handle
it transparently with a directive or module enabled so I don't have to code
some hack on every page.
I guess I could always redirect to some 'scrubber' page that strips them
out and redirects on to the refering page again, but that seems klunky.
BTW, I want to use GET so that the page can be bookmarked for future
searches of the same data (or modified easily with different dates, etc.),
so that's why I don't use POST.
JavaScript is the only client side way I know of.
Use document.getelementbyid() and yank the unused nodes before submit.
server side, redirect - it shouldn't be that clunky.
Put in a hidden input that tells your action script to redirect to
itself without the unused get variables (and w/o the hidden input).
That's how I would do it personally (opposed to js).
--- End Message ---
--- Begin Message ---
Daevid Vincent wrote:
I guess I could always redirect to some 'scrubber' page that strips them
out and redirects on to the refering page again, but that seems klunky.
BTW, I want to use GET so that the page can be bookmarked for future
searches of the same data (or modified easily with different dates, etc.),
so that's why I don't use POST.
Another option is to use post in the form, and when your action page
receives post, it redirects to itself with the used variables as get.
--- End Message ---
--- Begin Message ---
Michael, while i respect your choices, i think you should know that
jquery.com is pretty good at minimizing browser-incompatibility
headaches (and keeping js apps small), and the quircks that are left
are easy enough to learn about.
for things whereby
- the server needs to generate tons of HTML for a small(ish) dataset, or
- the client generates data (also to be translated to html) that the
server doesnt really need to know about (yet)
js can really take some stress off the server.
On Wed, Jan 20, 2010 at 9:31 AM, Michael A. Peters <[email protected]> wrote:
> Rene Veerman wrote:
>>>
>>> That's how I would do it personally (opposed to js).
>>
>> wtf??! js = less server stress :)
>>
>
> Many (myself included) surf with script blockers due to XSS and js is more
> difficult to thoroughly test because the implementation is done by browsers
> without a good standards body for validating the the code.
>
> I've run into a couple situations where scripts worked perfectly for me in
> Firefox, Opera, and Konq only to find out they failed in IE either because
> IE did things differently (like attaching events) or something as stupid as
> IE not liking a space that the other browsers worked fine with.
>
> window.open(url,'Download
> Media','width=620,height=200,toolbar=0,location=0,directories=0,menubar=0,resizable=0');
>
> failed in IE because of the space between Download and Media, yet worked in
> all other browsers I tried, and didn't even give a warning in Firefox with
> the firebug plugin.
>
> Thus for me to implement a solution in JavaScript, the testing time goes way
> up because I have to test it in several versions of several different
> browsers.
>
> If I can do it server side, the only issues are CSS and appropriate
> fallbacks for bleeding edge tags (like the html5 tags), but I have to test
> for those anyway so doing it server side doesn't cost me any extra testing
> time and doesn't end up with failures because I didn't test a particular
> version of a particular browser.
>
> Also, by minimizing the JavaScript, I minimize the amount of fallback
> testing I need to still keep viewers who have scripting disabled.
>
> Until there is some kind of a proper standard that the major browser vendors
> adhere to with a validator I can check my JS against that will pretty much
> guarantee any validating JS works in the various browsers, I will continue
> to do stuff server side as much as possible.
>
> I do use JavaScript for things like form validation (validated server side
> as well), upload progress, dynamic select menus where the content of one
> depends upon what was selected in another, etc. - but if I can do it server
> side I do, that's my philosophy. I understand it is a minority philosophy,
> but I get less headaches that way.
>
--- End Message ---
--- Begin Message ---
On Tue, 2010-01-19 at 20:55 -0800, Daevid Vincent wrote:
> I have an HTML form with a hundred or so elements on it, used for searching
> a database.
>
> When the user submits the form (via GET) the URL is loaded with ALL of
> these fields, and many of them are not even actually used in the search
> criteria.
>
> https://mypse/dart2/ps_search.php?enter_date=2009-11-30&id_incident=&incide
> nt_date=&incident_hh=0&incident_mm=0&id_urgency_level=0&problem_description
> =&immediate_action=&unit_opened=&unit_authorized=&customer=&customer_contac
> t=&customer_address=&customer_country=&id_location=0&passengers_onboard=&su
> bmit=Search&part_number=&serial_number=&nomenclature=&manufacture_date=&mod
> _level=&id_lru_condition=&repair_history=&ac_type=&tail_number=&id_system_t
> ype=&id_lru_location=0&circuit_breaker=&circuit_breaker_amps=&seat_number=&
> seat_vendor=&seat_column_zone=&seat_zone=&tc_holder=&stc_holder=&asr_mor=&i
> mpounded=&id_authority=&id_region=&reported_by=&prepared_by=&preparer_locat
> ion=&field_engineer=&id_attach_pictures=&id_attach_mlr=&id_attach_lopa=&cab
> in_log=&parts_inspect=&id_organization=0&id_quality_engineer=0&car_number=&
> close_date=&closed_by=&qa_comment=&id_priority=&id_action=0&id_incident_sta
> tus=3&id_failure_type=&detail_status=&investigation_result=&osaka_action=&o
> saka_request=&newvsrepeat=&related_incident=&unit_received_date=&unit_retur
> ned_date=&tdr_to_pso_date=&tdr_date=&dcr_date=&dcr_reference_number=&ecr_da
> te=&ecr_reference_number=&eco_date=&eco_reference_number=&service_bulletin_
> date=&sb_reference_number=&sil_issue_date=&sil_reference_number=&til_issue_
> date=&til_reference_number=&customer_letter_issue_date=&subassembly=&rdm=&p
> svector=&oemmanuf=&defective_part_1=&defective_part_2=&defective_part_3=&de
> fective_part_4=
>
> Is there some way via PHP/Apache Mod/Javascript to remove all the keys that
> don't have any value in them and just distill this down to the
> elements/keys that the user actually entered some input for? ie. defaulting
> all the rest to 'blank'.
>
> In PHP, this would look something like this:
>
> foreach ($_GET as $k => $v) if ($v == '') unset($_GET[$k]);
>
> The problem as I see it, is that this "magic" happens when the user hits
> "Submit", so not sure PHP has any way to intercept at that point.
> Javascript might be able to do something on the "onClick" event or
> "onSubmit" I suspect. But this seems like something that someone should
> have solved before and common enough that I would think Apache could handle
> it transparently with a directive or module enabled so I don't have to code
> some hack on every page.
>
> I guess I could always redirect to some 'scrubber' page that strips them
> out and redirects on to the refering page again, but that seems klunky.
>
> BTW, I want to use GET so that the page can be bookmarked for future
> searches of the same data (or modified easily with different dates, etc.),
> so that's why I don't use POST.
You can't remove the empty fields server-side, as they never reach the
server. GET has a limit on the amount of data it may carry, which is
reduced the longer the base URL is. If you need to send large amounts of
data like that, you need to send it via POST. You can make minimal
changes to your PHP code to allow for this. If you use $_GET in your
PHP, swap it for $_REQUEST which contains both GET and POST data.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
On Wed, Jan 20, 2010 at 02:33, Rene Veerman <[email protected]> wrote:
> if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) AND
> strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $last_modified) {
>
>
> shouldn't that be
>
> strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $last_modified)
>
> ?
>
Now that I think about it... yes; but I send the last modified header anyway
the first time (when $_SERVER['HTTP_IF_MODIFIED_SINCE'] == null):
header('Last-Modified: '.gmdate('D, d M Y H:i:s',$last_modified).' GMT');
So if it isn't exactly equal, then the browser cache simply doesn't have the
latest version. It is impossible anyway that the browser can have a newer
version that doesn't previously exist on the server.
My best guess is that it doesn't affect the process: when I implement that
code in my class, it enters that part (meaning all the comparisons are ok)
but afterwards it keeps sending an "200 OK" header when I explicitly tell
Apache to send the "304 Not Modified" one.
Greetings and thanks for sharing :)
--
Mailed by:
UnReAl4U - unreal4u
ICQ #: 54472056
www1: http://www.chw.net/
www2: http://unreal4u.com/
--- End Message ---
--- Begin Message ---
ok, you might wanna re-ask on an apache list in that case..
On Wed, Jan 20, 2010 at 6:48 AM, Camilo Sperberg <[email protected]> wrote:
>
>
> On Wed, Jan 20, 2010 at 02:33, Rene Veerman <[email protected]> wrote:
>>
>> if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) AND
>> strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $last_modified) {
>>
>>
>> shouldn't that be
>>
>> strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $last_modified)
>>
>> ?
>
> Now that I think about it... yes; but I send the last modified header anyway
> the first time (when $_SERVER['HTTP_IF_MODIFIED_SINCE'] == null):
> header('Last-Modified: '.gmdate('D, d M Y H:i:s',$last_modified).' GMT');
>
> So if it isn't exactly equal, then the browser cache simply doesn't have the
> latest version. It is impossible anyway that the browser can have a newer
> version that doesn't previously exist on the server.
> My best guess is that it doesn't affect the process: when I implement that
> code in my class, it enters that part (meaning all the comparisons are ok)
> but afterwards it keeps sending an "200 OK" header when I explicitly tell
> Apache to send the "304 Not Modified" one.
>
> Greetings and thanks for sharing :)
>
> --
> Mailed by:
> UnReAl4U - unreal4u
> ICQ #: 54472056
> www1: http://www.chw.net/
> www2: http://unreal4u.com/
>
--- End Message ---
--- Begin Message ---
Camilo Sperberg wrote:
Hi list, my first message here :)
To the point: I'm programming a class that takes several CSS files, parses,
compresses and saves into a cache file. However, I would like to go a step
further and also use the browser cache, handling the 304 and 200 header
types myself.
Now, what is the problem? If I do it within a function, there is absolutely
no problem, everything works like a charm. However, when I implement that
same concept into my class, there is no way I can send a 304 Not Modified
header, when the data is *over* ~100 bytes.
Hi Camilo
For what it is worth I have implemented cacheing in a class and for me
the 304 not modified header gets sent fine ... some example headers
output is below together with the relevant code snippet..
// See if client sent a page modified header to see if we can
// just send a not modified header instead
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) &&
$_SERVER['HTTP_IF_MODIFIED_SINCE'] == self::$_gmmodtime) {
header('HTTP/1.1 304 Not Modified');
return null;
}
if (isset($_SERVER['HTTP_IF_NONE_MATCH']) &&
stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) == self::$_etag) {
header('HTTP/1.1 304 Not Modified');
return null;
}
HTTP/1.x 304 Not Modified
Date: Wed, 20 Jan 2010 07:21:32 GMT
Server: Apache/2.2.11 (Ubuntu)
Connection: Keep-Alive
Keep-Alive: timeout=5, max=1000
Etag: 444fbd9951f540ec1b6928db864c10dc
Expires: Sun, 24 Jan 2010 06:16:06 GMT
Cache-Control: public, must-revalidate
Vary: Accept-Encoding
I hope it helps..
Regards
Rich
--- End Message ---
--- Begin Message ---
To do what you want that new httpd server should at least be able to
call up PHP via cli / whatever, and retrieve the output.
It also needs to provide what's in php called $_GET and $_POST.
Assuming you got that covered, then yes, you could route the calls via
ajax (i recommend jquery.com for that) to your non-php httpd, which
then forwards it (and the results back).
What i'd do if it HAD to be done this way, is pass a couple of extra
variables in each call from javascript. It's best to route all the
ajax calls to php to the same script on the non-php httpd, so you'd
need at least the "relative path (from serverside defined absolute
base-path for your php subsystem) to the script being called" (or even
an MD5/SHA256 of this rel path, if you're on the paranoid side; you
then inform (via an array) the non-php httpd about all the scripts
that may be called from javascript, without giving up the scripts
names to spies along the line)
But tbh, whoever thought of changing the type of server used and
thereby giving you this new problem, should have also thought of how
to not-dump tons of existing code. Not to mention developer experience
with a specific language.
If this new httpd is so damn good at something that it has to be used,
it still doesn't mean it has to be used for the entire system either.
You might be giving it more work than it is comfortable with, that
way.
So depending on your backend size (in terms of number of machines
used) & setup, you might even campaign to keep an apache in the
picture and let it perform work on the database / file storage
system..
On Fri, Jan 15, 2010 at 8:07 PM, Andres Gonzalez <[email protected]> wrote:
> How do I call PHP code that will run server side, from javascript code that
> is running client side?
>
> I have a lot of PHP server side code written and working within CodeIgniter.
> Now, my project
> has changed and (for reasons unimportant to this discussion) we are now NOT
> going to
> use apache and CodeIgniter, but instead, we are going to have to use an http
> server that does
> not support PHP internally. But I want to reuse my original PHP code. So I
> am thinking that I
> can execute the PHP code via a command line interface using the PHP cli
> interface instead of
> the PHP cgi interface. But, I will have to initiate this serversid call via
> javascript code running
> on the client.
>
> I know...kind of convoluted. But how would one do this if necessary?
>
> -Andres
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
oh, and if you're going to use ajax->non-phphttpd->php->andback, then
check if your dear non-php httpd abuses the CPU while waiting for PHP
to return the results...
--- End Message ---
--- Begin Message ---
Hi, for http://mediabeez.ws/htmlMicroscope/ (lgpl) i need to make
large & complex but _randomly filled_ test-arrays.
The code i wrote (hastily) for this is taking over 2 hours to generate
65k array values.
I wonder if any of you see a way to improve it's speed.
global $hmGenKeys;
$hmGenKeys = 0;
function htmlMicroscope_generateRandomArray ($maxKeys, $maxDepth,
$maxDuration=-1) {
global $hmGenKeys;
$r = array();
if ($maxKeys!==null) {
$hmGenKeys = $maxKeys;
}
$hmGenKeys--;
if ($hmGenKeys<=0) return false;
if ($maxDepth==0) return false;
srand(htmlMicroscope_randMakeSeed());
while ($hmGenKeys > 0) {
$range = rand(0,40);
file_put_contents('countdown.txt', $hmGenKeys);
for ($i=0; $i<$range && $hmGenKeys>=0; $i++) {
$hmGenKeys--;
if ($maxDuration!=-1 && $maxDuration < getDuration()) {
$r = array();
} else {
switch (rand(1,2)) {
case 1 :
$next = htmlMicroscope_generateRandomArray (null,
$maxDepth-1, $maxDuration);
if ($next!==false)
$r = array_merge ($r, array(
htmlMicroscope_randomValue(3) => $next
));
break;
case 2 :
$r = array_merge ($r, array(
htmlMicroscope_randomValue(3) =>
htmlMicroscope_randomValue(20)
));
break;
}
}
}
// echo $hmGenKeys.'<br/>';
}
return $r;
}
function htmlMicroscope_randomValue($maxLength) {
$r = '';
switch (rand(0,9)) {
case 0 : $r = rand (0,100000000); break;
case 1 : $r = rand (0,100000000) / rand(1,100) / 3; break;
default:
for ($i = 0; $i < $maxLength; $i++) {
switch (rand(0,1)) {
case 0:
$r.= unichr(rand(0,hexdec('ffff')));
break;
case 1:
$r.=chr(rand(ord('a'),ord('z')));;
break;
}
}
break;
}
//echo $r.'<br/>'.$maxLength.'<br/>';
return $r;
}
function unichr($u) {
return mb_convert_encoding('&#' . intval($u) . ';', 'UTF-8',
'HTML-ENTITIES');
}
--- End Message ---
--- Begin Message ---
At 12:42 PM +0100 1/20/10, Rene Veerman wrote:
Hi, for http://mediabeez.ws/htmlMicroscope/ (lgpl) i need to make
large & complex but _randomly filled_ test-arrays.
Sometimes it's good to look at some of php's built in functions, like
shuffle() and array_rand().
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---
[snip]
> Another advantage of OOP that is difficult to
> provide via the procedural paradigm is polymorphism.
Agreed. Though the advantages of polymorphism are questionable,
depending on your viewpoint.
[/snip]
In a loosely typed language like PHP that advantages of polymorphism far
outweigh any potential disadvantages, especially where virtual functions
are concerned.
--- End Message ---
--- Begin Message ---
At 10:26 AM -0500 1/19/10, Bob McConnell wrote:
Some problems will fit into it, some don't.
I teach OOP thinking at the local college and haven't run into a
problem that doesn't fit. For example, in my last class I had a woman
who wanted to pick out a blue dress for her upcoming wedding
anniversary. The class worked out the problem with a OOP solution.
----
Some people can look at problems and see objects and some can't.
That's for certain -- but in time just about everyone can understand
the basic concepts of OOP.
----
But in most cases, it is not easy to take an
existing procedural program and re-map it into objects. It would be
easier to start over from the specification and write it from scratch in
the object model.
I agree with that because part of OOP is understanding/defining the
problem through an object oriented perspective -- it's a paradigm
shift in thinking.
However, a programmer who is good in procedural also understands
problem solving. OOP and Procedural are just two different approaches
and each brings it's own set of tools/problems to the table.
---
If you have been doing procedural programming, don't worry if you don't
figure it out right away. It is not an easy transition to make. Many of
us with decades of programming behind us will never be able to make that
switch. Our brains are too tightly locked into the previous thought
patterns.
Bob McConnell
While I teach OOP, I don't write any OOP for clients. My charge is to
do things quickly and OOP requires a considerable amount of analysis
before creating a solution. In most cases, I don't have the time.
Besides, I'm more of an agile programmer and that doesn't lend itself
well to OOP, IMO.
Also IMO, one can argue the advantages that OOP and Design Patterns
bring to the table over procedural, but after all is said and done,
if you know your stuff in procedural, OOP is not going to provide you
with much that you don't already have.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---
On Wed, Jan 20, 2010 at 06:47:04AM -0600, Jay Blanchard wrote:
> [snip]
> > Another advantage of OOP that is difficult to
> > provide via the procedural paradigm is polymorphism.
>
> Agreed. Though the advantages of polymorphism are questionable,
> depending on your viewpoint.
> [/snip]
>
> In a loosely typed language like PHP that advantages of polymorphism far
> outweigh any potential disadvantages, especially where virtual functions
> are concerned.
My viewpoint may be jaundiced from having programmed in C++, but the
polymorphism of PHP seems a little crippled by comparison.
Paul
--
Paul M. Foster
--- End Message ---
--- Begin Message ---
Richard Quadling wrote:
>2010/1/19 Edward S.P. Leong <[email protected]>:
>
>
>>Richard Quadling wrote:
>>
>>
>>
>>>But having said all of that, the php_mssql.dll uses a very old library
>>>which may give you issues.
>>>
>>>For the time being, using ODBC (php_odbc is built in for PHP on
>>>Windows) is a much safer solution. You can also use the latest SQL
>>>Native Client driver so you can talk to SQL7, 2000, 2005, 2008.
>>>
>>>If you are used to using a DNS-less connection, then ...
>>>
>>>$Conn = odbc_pconnect("Driver={SQL Server Native Client
>>>10.0};Server={$Server};Database={$Database};MARS_Connection=Yes;",
>>>$User, $Password, SQL_CUR_USE_DRIVER);
>>>
>>>will give you the connection without the need to have a DNS entry.
>>>
>>>
>>>
>>>
>>Hello to you,
>>
>>Where can we download the SQL Native Client driver for talking to MS-SQL
>>( eg : 2000 ) ?
>>
>>Thanks !
>>
>>--
>>PHP General Mailing List (http://www.php.net/)
>>To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>>
>>
>
>http://www.microsoft.com/downloads/details.aspx?FamilyId=C6C3E9EF-BA29-4A43-8D69-A2BED18FE73C&displaylang=en
>
>
Sorry,
Would you mind to tell me which for connecting MS-SQL 2000 and PHP ?
Thanks !
Edward.
--- End Message ---
--- Begin Message ---
2010/1/20 Edward S.P. Leong <[email protected]>:
> Richard Quadling wrote:
>
> 2010/1/19 Edward S.P. Leong <[email protected]>:
>
>
> Richard Quadling wrote:
>
>
>
> But having said all of that, the php_mssql.dll uses a very old library
> which may give you issues.
>
> For the time being, using ODBC (php_odbc is built in for PHP on
> Windows) is a much safer solution. You can also use the latest SQL
> Native Client driver so you can talk to SQL7, 2000, 2005, 2008.
>
> If you are used to using a DNS-less connection, then ...
>
> $Conn = odbc_pconnect("Driver={SQL Server Native Client
> 10.0};Server={$Server};Database={$Database};MARS_Connection=Yes;",
> $User, $Password, SQL_CUR_USE_DRIVER);
>
> will give you the connection without the need to have a DNS entry.
>
>
>
>
> Hello to you,
>
> Where can we download the SQL Native Client driver for talking to MS-SQL
> ( eg : 2000 ) ?
>
> Thanks !
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
>
> http://www.microsoft.com/downloads/details.aspx?FamilyId=C6C3E9EF-BA29-4A43-8D69-A2BED18FE73C&displaylang=en
>
>
> Sorry,
>
> Would you mind to tell me which for connecting MS-SQL 2000 and PHP ?
>
> Thanks !
>
> Edward.
>
Either ODBC or the MS SQL driver for PHP. Which ever suits you.
Both require the MS SQL Native Client (go for the latest).
That's it really.
--
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling
--- End Message ---
--- Begin Message ---
2010/1/20 Richard Quadling <[email protected]>:
> 2010/1/20 Edward S.P. Leong <[email protected]>:
>> Richard Quadling wrote:
>>
>> 2010/1/19 Edward S.P. Leong <[email protected]>:
>>
>>
>> Richard Quadling wrote:
>>
>>
>>
>> But having said all of that, the php_mssql.dll uses a very old library
>> which may give you issues.
>>
>> For the time being, using ODBC (php_odbc is built in for PHP on
>> Windows) is a much safer solution. You can also use the latest SQL
>> Native Client driver so you can talk to SQL7, 2000, 2005, 2008.
>>
>> If you are used to using a DNS-less connection, then ...
>>
>> $Conn = odbc_pconnect("Driver={SQL Server Native Client
>> 10.0};Server={$Server};Database={$Database};MARS_Connection=Yes;",
>> $User, $Password, SQL_CUR_USE_DRIVER);
>>
>> will give you the connection without the need to have a DNS entry.
>>
>>
>>
>>
>> Hello to you,
>>
>> Where can we download the SQL Native Client driver for talking to MS-SQL
>> ( eg : 2000 ) ?
>>
>> Thanks !
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>>
>>
>> http://www.microsoft.com/downloads/details.aspx?FamilyId=C6C3E9EF-BA29-4A43-8D69-A2BED18FE73C&displaylang=en
>>
>>
>> Sorry,
>>
>> Would you mind to tell me which for connecting MS-SQL 2000 and PHP ?
>>
>> Thanks !
>>
>> Edward.
>>
>
> Either ODBC or the MS SQL driver for PHP. Which ever suits you.
>
> Both require the MS SQL Native Client (go for the latest).
>
> That's it really.
>
> --
> -----
> Richard Quadling
> "Standing on the shoulders of some very clever giants!"
> EE : http://www.experts-exchange.com/M_248814.html
> Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
> ZOPA : http://uk.zopa.com/member/RQuadling
>
Microsoft SQL Server 2008 Native Client
Microsoft SQL Server 2008 Native Client (SQL Native Client) is a
single dynamic-link library (DLL) containing both the SQL OLE DB
provider and SQL ODBC driver. It contains run-time support for
applications using native-code APIs (ODBC, OLE DB and ADO) to connect
to Microsoft SQL Server 2000, 2005, or 2008. SQL Native Client should
be used to create new applications or enhance existing applications
that need to take advantage of new SQL Server 2008 features. This
redistributable installer for SQL Native Client installs the client
components needed during run time to take advantage of new SQL Server
2008 features, and optionally installs the header files needed to
develop an application that uses the SQL Native Client API.
Audience(s): Customer, Partner, Developer
X86 Package (sqlncli.msi) - 4549 KB -
http://go.microsoft.com/fwlink/?LinkId=123717&clcid=0x409
X64 Package (sqlncli.msi) - 7963 KB -
http://go.microsoft.com/fwlink/?LinkId=123718&clcid=0x409
IA64 Package (sqlncli.msi) - 11112 KB -
http://go.microsoft.com/fwlink/?LinkId=123719&clcid=0x409
Microsoft SQL Server 2005 Driver for PHP
The SQL Server 2005 Driver for PHP is a PHP 5 extension that allows
for accessing data in all Editions of SQL Server 2005 and SQL Server
2008 (including Express Editions) from within PHP scripts. The driver
provides a procedural interface for accessing data and makes use of
PHP features, including PHP streams to read and write large objects.
With this release, the source code for the driver is available here:
http://go.microsoft.com/fwlink/?LinkID=123842&clcid=0x409 . The SQL
Server 2005 Driver for PHP relies on the Microsoft SQL Server Native
Client to communicate with SQL Server. For more information about SQL
Server Native Client, visit the SQL Server Native Client page on MSDN.
Audience(s): Developer, DBA
Download site - http://go.microsoft.com/fwlink/?LinkID=123470
--
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling
--- End Message ---
--- Begin Message ---
Richard Quadling wrote:
>>http://www.microsoft.com/downloads/details.aspx?FamilyId=C6C3E9EF-BA29-4A43-8D69-A2BED18FE73C&displaylang=en
>>
>>
>>Sorry,
>>
>>Would you mind to tell me which for connecting MS-SQL 2000 and PHP ?
>>
>>Thanks !
>>
>>Edward.
>>
>>
>>
>
>Either ODBC or the MS SQL driver for PHP. Which ever suits you.
>
>Both require the MS SQL Native Client (go for the latest).
>
>That's it really.
>
Sorry,
My means is which package support for connecting MS-SQL 2000 from php ?
Due to I don't know which package ( file name ) I download it on the
download site is suitable for me to use...
Thanks !
Edward.
--- End Message ---
--- Begin Message ---
2010/1/20 Edward S.P. Leong <[email protected]>:
> Richard Quadling wrote:
>
> http://www.microsoft.com/downloads/details.aspx?FamilyId=C6C3E9EF-BA29-4A43-8D69-A2BED18FE73C&displaylang=en
>
>
> Sorry,
>
> Would you mind to tell me which for connecting MS-SQL 2000 and PHP ?
>
> Thanks !
>
> Edward.
>
>
>
> Either ODBC or the MS SQL driver for PHP. Which ever suits you.
>
> Both require the MS SQL Native Client (go for the latest).
>
> That's it really.
>
> Sorry,
>
> My means is which package support for connecting MS-SQL 2000 from php ?
> Due to I don't know which package ( file name ) I download it on the
> download site is suitable for me to use...
>
> Thanks !
>
> Edward.
>
As you are running IIS + PHP in 32bit mode, I'd stick with the x86 packages.
--
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling
--- End Message ---
--- Begin Message ---
Richard Quadling wrote:
>2010/1/20 Edward S.P. Leong <[email protected]>:
>
>
>>Richard Quadling wrote:
>>
>>http://www.microsoft.com/downloads/details.aspx?FamilyId=C6C3E9EF-BA29-4A43-8D69-A2BED18FE73C&displaylang=en
>>
>>
>>Sorry,
>>
>>Would you mind to tell me which for connecting MS-SQL 2000 and PHP ?
>>
>>Thanks !
>>
>>Edward.
>>
>>
>>
>>Either ODBC or the MS SQL driver for PHP. Which ever suits you.
>>
>>Both require the MS SQL Native Client (go for the latest).
>>
>>That's it really.
>>
>>Sorry,
>>
>>My means is which package support for connecting MS-SQL 2000 from php ?
>>Due to I don't know which package ( file name ) I download it on the
>>download site is suitable for me to use...
>>
>>Thanks !
>>
>>Edward.
>>
>>
>>
>
>As you are running IIS + PHP in 32bit mode, I'd stick with the x86 packages.
>
>
>
Hello,
Do you means the x86 is suitable for me now ?
Thanks !
Edward.
--- End Message ---