php-general Digest 6 Feb 2008 06:48:52 -0000 Issue 5277
Topics (messages 268723 through 268748):
Re: How to download a file (with browser) using fsockopen() ?
268723 by: Richard Lynch
268727 by: szalinski
Re: text messages
268724 by: Richard Lynch
268742 by: blackwater dev
Re: how dod you get to do multiple mysql queries concurrently?
268725 by: Richard Lynch
268726 by: Richard Lynch
268730 by: Paul Scott
268731 by: Paul Scott
Re: Pass Variable Names to a Function
268728 by: Daniel Brown
Re: php competion
268729 by: Daniel Brown
Re: Anyone else doing PHP on Symbian?
268732 by: Daniel Brown
268746 by: Cameron Just
268748 by: Paul Scott
Re: New search related question
268733 by: Daniel Brown
string vs number
268734 by: Hiep Nguyen
268735 by: Nathan Nobbe
268736 by: Eric Butera
268737 by: Nathan Nobbe
268738 by: Casey
268739 by: Nathan Nobbe
268740 by: Daniel Brown
268741 by: Eric Butera
268744 by: Jochem Maas
Re: Tool for programmer team
268743 by: Mr Webber
How could i do this on CURL?
268745 by: Louie Miranda
268747 by: Manuel Lemos
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 ---
On Mon, February 4, 2008 9:28 pm, szalinski wrote:
> Hi
>
> I have been working on this download script for quite a while, and I
> just
> can't find how to download a remote file via a user's browser using
> fsockopen.
>
> Basically I am wondering if anyone can just give me a simple working
> example on how to use fsockopen() to fetch a file on a remote server,
> and
> then pop up a save dialog box in my browser. For example, let's say I
> want
> to download this file from here:
>
> http://remotedomain.com/file.zip
>
> Instead of putting this directly into my browser and then being
> prompted
> to save it to my pc, how can i use fsockopen() to fetch the file, and
> get
> the same prompt on my browser? E.g. I want to be able to do
>
> http://localhost/index.php?url=http://remotedomain.com/file.zip
>
> I know that this does not seem the most obvious and easy way to do it,
> but
> i simply cannot get a file to download myself using fsockopen. I
> specifically want this function, as I need to POST headers to the
> server
> and I haven't as yet been able to download a file using it, without it
> being corrupt, or the connection hanging. I just can't figure it out,
> and
> I'm getting a bit tired with it!
> I don't need a whole hand-made script, I just need the part where
> fsockopen will download this file. Perhaps a working function that
> would
> do it. Please try not to use classes or objects because I haven't
> quite
> figured out object-oriented programming yet!!
>
> Also, I would like if you can do it via HTTP 1.0 because I know HTTP
> 1.1
> is tricky, and might require a chunk decoder, and i don't see the need
> for
> it, unless someone is able to provide a working chunked data decoder.
>
> Thanks to anyone who can help. :)
After you do the fsockopen, to get rid of the headers, insert this bit:
while (($line = fgets($socket, 1000000)) != "\n"){
//skip the headers
}
You may need to change "\n" to "\r\n" if the document is coming from a
broken Windows server. Or gmail, which seems to do everything the
Windows way.
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?
--- End Message ---
--- Begin Message ---
Thanks for this, it seems to work generally ok, but with one problem.
If i get prompted to download the fie, there is no filesize
(content-length is missing), so i wouldn't be able to resume the file if
it was big!
I tried adding another function that gets the headers from the file first,
(to find the content-length), but instead I get an error message stating
'Cannot modify header information - headers already sent...', so I'm
thinking that i am now in a catch-22 situation. I need to get the headers
to find the content-length, and then send it to the browser to prompt the
download of the file with the correct filesize.
Also i noticed u used http 1.1, which i simply changed to 1.0 - hope this
is enough to avoid chunked decoding. I also changed the method to POST as
i need it.
so either is it a paradox, or am i just misunderstanding where the headers
should be placed?
thanks :)
On Tue, 05 Feb 2008 07:16:31 -0000, <[EMAIL PROTECTED]> wrote:
Try this, it should work.
//Get the file from the remote location
function getFile($host, $resource, $port)
{
??? $hdr = '';
??? $file_cont = '';
??? $fh = fsockopen($host, $port, $errno, $errstr, 300);
???
??? if(! $fh)
??? {
??? ??? return "error";
??? } else {
??? ??? $hdr .= "GET /$resource HTTP/1.1 \r\n";
??? ??? $hdr .= "Host: $host\r\n";
??? ??? $hdr .= "Connection: close\r\n\r\n";
??? ??? fwrite($fh, $hdr);
??? ??? while(!feof($fh))
??? ??? {
??? ??? ??? $file_cont .= fgets($fh, 128);
??? ??? }
??? ??? //Return the file as a string
??? ??? return $file_cont;
??? }
}
//Set up essential headers
header("Content-Type: Application/GIF");
header("Content-Disposition: application/gif; filename=one.gif");
//Strip the text headers in the file and print it out.
print preg_replace("/^.*\r\n/m", "", getFile("wisdomleaf.com",
"images/logo.gif", 80));
Anyway, the core of the script is download the file as a string, print
it out as a string with suitable headers.
Cheers,
V
-----Original Message-----
From: szalinski <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
<[EMAIL PROTECTED]>
Sent: Tue, 5 Feb 2008 8:58 am
Subject: [PHP] How to download a file (with browser) using fsockopen() ?
Hi?
?
I have been working on this download script for quite a while, and I
just can't find how to download a remote file via a user's browser using
fsockopen.?
?
Basically I am wondering if anyone can just give me a simple working
example on how to use fsockopen() to fetch a file on a remote server,
and then pop up a save dialog box in my browser. For example, let's say
I want to download this file from here:?
?
http://remotedomain.com/file.zip?
?
Instead of putting this directly into my browser and then being prompted
to save it to my pc, how can i use fsockopen() to fetch the file, and
get the same prompt on my browser? E.g. I want to be able to do?
?
http://localhost/index.php?url=http://remotedomain.com/file.zip?
?
I know that this does not seem the most obvious and easy way to do it,
but i simply cannot get a file to download myself using fsockopen. I
specifically want this function, as I need to POST headers to the server
and I haven't as yet been able to download a file using it, without it
being corrupt, or the connection hanging. I just can't figure it out,
and I'm getting a bit tired with it!?
I don't need a whole hand-made script, I just need the part where
fsockopen will download this file. Perhaps a working function that would
do it. Please try not to use classes or objects because I haven't quite
figured out object-oriented programming yet!!?
?
Also, I would like if you can do it via HTTP 1.0 because I know HTTP 1.1
is tricky, and might require a chunk decoder, and i don't see the need
for it, unless someone is able to provide a working chunked data
decoder.?
?
Thanks to anyone who can help. :)?
?
--PHP General Mailing List (http://www.php.net/)?
To unsubscribe, visit: http://www.php.net/unsub.php?
________________________________________________________________________
You are invited to Get a Free AOL Email ID. - http://webmail.aol.in
--- End Message ---
--- Begin Message ---
On Mon, February 4, 2008 9:15 pm, blackwater dev wrote:
> I know this isn't specific to php but I need to add some code to my
> php
> pages to start sending out text messages. If anyone does this, how do
> you
> do it? Do you simply use a free service like teleflip or do you use a
> paid
> aggregator company?
If you want to do ANY kind of volume or have ANY kind of certainty
that somebody at least tried to deliver the message, then pay an
aggregator.
If you're setting it up to let grandma send you a text, use teleflip.
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?
--- End Message ---
--- Begin Message ---
Thanks,
We are basically just looking to prototype something with about 50 users for
now so I'll check these out.
Thanks again!
On Feb 5, 2008 12:30 PM, Richard Lynch <[EMAIL PROTECTED]> wrote:
> On Mon, February 4, 2008 9:15 pm, blackwater dev wrote:
> > I know this isn't specific to php but I need to add some code to my
> > php
> > pages to start sending out text messages. If anyone does this, how do
> > you
> > do it? Do you simply use a free service like teleflip or do you use a
> > paid
> > aggregator company?
>
> If you want to do ANY kind of volume or have ANY kind of certainty
> that somebody at least tried to deliver the message, then pay an
> aggregator.
>
> If you're setting it up to let grandma send you a text, use teleflip.
>
> --
> Some people have a "gift" link here.
> Know what I want?
> I want you to buy a CD from some indie artist.
> http://cdbaby.com/from/lynch
> Yeah, I get a buck. So?
>
>
--- End Message ---
--- Begin Message ---
On Fri, February 1, 2008 3:55 am, Paul Scott wrote:
>
> Did anyone actually get this mail?
>
> More concrete example? What would you like to see?
>
> I suspect that some of my mail is getting dropped :(
I got the email below, and it made perfect sense...
Though I am not sure it would make sense to somebody who hasn't used
GIS before, or at least read about it...
Ultimately, what you do is have a NEW datatype to play with called a
'geometry' or a 'gis' or whatever the SQL guys chose to call it.
You also have ways to create "points" or "lines" or "polygons" etc,
which are sub-types of geometries.
And, finally, you can put an index on one of these nifty 'geometry'
columns, and it uses a btree to sort the data based on rules that make
sense for the underlying 'geometry' data.
For a concrete example, you might do something like this:
create table store (
store_id int(11) autoincrement unique not null primary key,
address text,
city varchar(255),
state char(2),
postal varchar(15),
longlat gis
);
create index store_gis_index on store(longloat);
inset into store(city, state, postal, longlat)
values ('Chicago', 'IL', '60601', GisLongLat(41.885844, -87.618128));
As far as you're concerned, it just goes really fast by "magic" when
you try to look something up by being "close to" a given LongLat.
Somewhere down in the guts of the DB, there is something to order the
data by both long and lat in a btree to find things quickly that are
"near" each other.
This is actually pretty OT for the PHP list itself, really, unless you
want to try to implement GIS in PHP, which would be a particularly Bad
Idea (tm) due to the scale, scope, and calculations involved.
Perhaps a Postgres GIS list or the MySQL list would be of more use, or
a Geography/Cartography database list.
You could probably achieve a SIMILAR performance level for something
as simple as long lat with:
create table store (
/* same columns as before */
long float,
lat float
);
create index store_long_lat_index on store(long, lat);
It wouldn't be QUITE as efficient, perhaps, as the ordering of the
btree for a GIS column might put more weight on the "lat" part
somehow, rather than just plain sorting by long, and then by lat...
But you have to have an AWFULLY large index for that to matter, since
the depth of the btree the same size, and only for specific clumped
data will it make any difference, I think.
Disclaimer:
I am NOT an expert on this stuff, but I have messed with it a tiny
bit, and this is my best understanding from my research so far.
>
> --Paul
>
> On Fri, 2008-02-01 at 06:33 +0200, Paul Scott wrote:
>> On Fri, 2008-02-01 at 03:40 +0100, Jochem Maas wrote:
>>
>> > I for one would really like to see a concrete example of this kind
>> of
>> > use of geometry columns and spacial indexes as an alternative to
>> the stand
>> > integer based primary keys.
>>
>>
>> On one of my local postGIS tables:
>>
>> CREATE INDEX k1
>> ON kanagawa
>> USING gist
>> (the_geom);
>>
>>
>> A gist index is a GEOS based spatial index. You will need GEOS to
>> create
>> one.
>>
>> When loading spatial data, your geometry column looks like so:
>>
>> 01050000000100000001020000000C00000011ECE564CF7561404A8999CCDABC4140E5C0981ACE75614012901CD641BD4140603C8386BE756140E525611B40BD41405BF216D3BD756140151DC9E53FBD414054DC1A4DBD756140760B997A3FBD414012219BD1BC756140D20823E33EBD41407AB2884EBC7561400F2110243EBD41404571B4D0BB756140CC0C6A213DBD4140F707192ABB7561405DF2A1803CBD4140F0F11CA4BA756140C3D1B7413CBD4140E89CB2ADB97561406F046D233CBD414017D4B7CCA97561406D47AD7F39BD4140
>>
>> Which is WKB (Well Known Binary) data or WKT (Well Known Text) data.
>> The
>> gist index simply indexes this as opposed to the regular gid (which
>> you
>> still use btree indexes on anyways)
>>
>> --Paul
>>
>> All Email originating from UWC is covered by disclaimer
>> http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
> --
> ------------------------------------------------------------.
> | Chisimba PHP5 Framework - http://avoir.uwc.ac.za |
> :------------------------------------------------------------:
>
> All Email originating from UWC is covered by disclaimer
> http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?
--- End Message ---
--- Begin Message ---
On Sun, February 3, 2008 6:08 pm, Jochem Maas wrote:
> of paginated data combined with user defined filters (e.g. a product
> list sorted by price, etc and filter on type/category/keyword/etc)
If you want GIS to be useful for that, you'd have to pretend that
something like "type" was, say, longitude, and "category" was latitude
and keyword was height, and then convert back and forth and...
If you can create ONE index in MySQL that contains ALL your WHERE and
ORDER BY fields, then you are golden.
MySQL can only use ONE index per query.
If your query uses WHERE clauses and/or ORDER BY clauses of fields
that are NOT in your index, then it will be "slow"
create index shopping_index on shopping(type, category, keyword, etc);
is probably going to be far more maintainable and provide a similar
performance boost.
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?
--- End Message ---
--- Begin Message ---
On Tue, 2008-02-05 at 11:53 -0600, Richard Lynch wrote:
> This is actually pretty OT for the PHP list itself, really, unless you
> want to try to implement GIS in PHP, which would be a particularly Bad
> Idea (tm) due to the scale, scope, and calculations involved.
>
Err, sorry, but I must correct you there. PHP is used as one of the more
common GIS (Web mapping at least) languages. I use it extensively with
the UMN Mapserver (mapserver.gis.umn.edu) as PHP/Mapscript which you
compile into PHP as an extension to access your map data. The OT part
comes in with the actual guts of the db transaction, and the AJAX based
interfaces that everyone insists on these days.
PHP in this case is an extremely important aspect of web mapping, and I
have even used PHP to interface to GRASS and other GIS apps (OK now
_this_ is starting to be a Bad Idea(TM)).
Some of the largest web mapping and scientific apps run off
PHP/Mapscript (closest competitor is PythonMapscript).
Just to let you know...
--Paul
All Email originating from UWC is covered by disclaimer
http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm
--- End Message ---
--- Begin Message ---
On Mon, 2008-02-04 at 01:08 +0100, Jochem Maas wrote:
> the column spec. what kind of geomtery column is it? and
A geographical "geometry" i.e. a projected data set of Geo data.
> are you using it as a primary key? or some else
No, the integer gid is usually a primary key still. The geo data is
indexed though.
> ... if so what kind
AFAIK it is a modified bTree index - but I will have to look closer to
give you a more correct answer.
> of stuff are you storing in there? also in what way are you
> using it that gives you such a speed boost with queries?
>
Simply an index that is specific to a geometry.
> I read the mysql docs, I understand the principles but I'm having
> a hard time figuring out how to apply in practice in terms of
> making use of the performance gains you mentione ... specifically
> in a web environment where heavy queries are often along the lines
> of paginated data combined with user defined filters (e.g. a product
> list sorted by price, etc and filter on type/category/keyword/etc)
>
The web environment that we are talking about here is not really all
that webby ;) It is more of a web frontend to a _very_ powerful database
system...
> sorry if I'm sounding like a idiot :-)
>
Not at all, how do we learn if we don't ask questions? There is no such
thing as a stupid question, only stupid answers...
--Paul
All Email originating from UWC is covered by disclaimer
http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm
--- End Message ---
--- Begin Message ---
On Feb 4, 2008 8:24 PM, Richard Lynch <[EMAIL PROTECTED]> wrote:
> function silly($var){
> return isset($_SESSION[$var]) ? $_SESSION[$var] : '';
> }
>
> silly('foo');
There's also <? ipitythe('foo'); ?>
--
</Dan>
Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>
--- End Message ---
--- Begin Message ---
On Feb 5, 2008 2:39 AM, Robert Cummings <[EMAIL PROTECTED]> wrote:
>
> On Mon, 2008-02-04 at 17:43 -0800, Warren Vail wrote:
> > There's probably even a tee-shirt. As in; been there, done that, got the
> > tee-shirt.
>
> Live and learn!
>
> :)
^ I'm With Stupid ^
HA! ;-P
(Sorry.)
--
</Dan>
Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>
--- End Message ---
--- Begin Message ---
On Feb 5, 2008 9:50 AM, Paul Scott <[EMAIL PROTECTED]> wrote:
>
> On Tue, 2008-02-05 at 14:44 +0000, George Pitcher wrote:
>
> > I've recently installed PAMP (PHP, Apache, MySQL & Python) on my Nokia N95.
> > I can do my development in Dreamweaver and move across to the phone and it
> > all works.
> >
>
> Sounds intruiging! Care to share some resources/links as to how to set
> up? I have a Sony/Ericsson P990i that I don't mind destroying with
> insane hacks, and this sounds like fun!
Indeed, it does, but I don't have a spare to help with anymore.
The most I really did on mine was using it as a client (such as with
the Symbian version of PuTTY:
http://s2putty.sourceforge.net/download.html). Still debating what
device I'll get next, but I want to use it as a mobile server myself.
I had been working on a bound-for-trash PDA doing the same a while
back, but with what we'll refer to as "limited results."
(Read: Total destruction.)
--
</Dan>
Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>
--- End Message ---
--- Begin Message ---
More info can be found here... When I get my Nokia N82 I am going to try
it out.
http://wiki.opensource.nokia.com/projects/PAMP
--- End Message ---
--- Begin Message ---
On Tue, 2008-02-05 at 13:29 -0500, Daniel Brown wrote:
> Still debating what
> device I'll get next, but I want to use it as a mobile server myself.
> I had been working on a bound-for-trash PDA doing the same a while
> back, but with what we'll refer to as "limited results."
I think that the key here is
1. A decent ARM processor and a PHP build for ARM specifically (new
project??)
2. Enough RAM to be useful - at least figure out how to use a SD card or
something as a RAMDisk and use like a 2GB card?
3. Getting an entire LAMP stack on there as a package - no use messing
with things - otherwise people won't use it.
Just think of the possibilities though... I do a lot in the eLearning
sphere in PHP, and this type of thing could be a mobile eLearning server
for rural schools in Africa that is actually affordable! Students could
connect to it via thin clients or mobile phones and get an education all
in one.
--Paul
All Email originating from UWC is covered by disclaimer
http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm
--- End Message ---
--- Begin Message ---
On Feb 4, 2008 7:42 PM, Jim Lucas <[EMAIL PROTECTED]> wrote:
> Daniel Brown wrote:
> > On Feb 4, 2008 2:48 PM, Jason Pruim <[EMAIL PROTECTED]> wrote:
> >> Hi Everyone! :)
> >>
> >> Just a quick question, I've done some googling but haven't been able
> >> to find what I need... I am looking at doing a search function for
> >> someone's website, the website is just static HTML files, and she
> >> doesn't want to redo the entire website to make it dynamic.
> >
> > I got bored, so I wrote out a system to handle it. Let me know if
> > you want the source when it's done.
> >
>
> So did I... :)
>
> Has options for searching recursively, case sensitivity, and displayable HTML
> only or the entire file. Also a restriction to limit which filetypes from the
> results it will display.
>
> It only works on *nix, I used grep. Don't have to worry about cron, scheduled
> tasks, etc to refresh a DB. I have it searching about 7000 files that range
> from plain text 2k all the way up to 60meg binary zip files, and it is rather
> quick at it.
I was going to do the same thing, but I started the framework from
a different perspective: portability across platforms to be used to
spider local and remote sites. I can punch in any valid URL and
recursively scan all public links, remove all HTML, put plain text
into the database, and (when it's actually working a bit better) I'm
going to use a Google-style response on search. For example, when
terms are found, show snippets of the terms with four or five words on
each side of the terms.
There are still some things I'd like to add in, should it be of
use to someone, including title searching, META searching, and blah,
blah, blah, but for now I'm just putting together the boring
foundation on which someone else can build the nice-looking house.
--
</Dan>
Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>
--- End Message ---
--- Begin Message ---
hi all,
i have this php statement:
<? if($rowB[$rowA[0]]=='Y') {echo "checked";} ?>
debugging, i got $rowA[0] = 54, but i want $rowB[$rowA[0]] = $rowB['54'].
is this possible? how do i force $rowA[0] to be a string ('54')?
thanks
t. hiep
--- End Message ---
--- Begin Message ---
On Feb 5, 2008 1:36 PM, Hiep Nguyen <[EMAIL PROTECTED]> wrote:
> hi all,
>
> i have this php statement:
>
> <? if($rowB[$rowA[0]]=='Y') {echo "checked";} ?>
>
>
> debugging, i got $rowA[0] = 54, but i want $rowB[$rowA[0]] = $rowB['54'].
>
> is this possible? how do i force $rowA[0] to be a string
> ('54')?<http://www.php.net/unsub.php>
php should handle the conversion internally for you.
if you want to type cast a value to a string, simply do
(string)$varname
-nathan
--- End Message ---
--- Begin Message ---
On Feb 5, 2008 1:40 PM, Nathan Nobbe <[EMAIL PROTECTED]> wrote:
> On Feb 5, 2008 1:36 PM, Hiep Nguyen <[EMAIL PROTECTED]> wrote:
>
> > hi all,
> >
> > i have this php statement:
> >
> > <? if($rowB[$rowA[0]]=='Y') {echo "checked";} ?>
> >
> >
> > debugging, i got $rowA[0] = 54, but i want $rowB[$rowA[0]] = $rowB['54'].
> >
> > is this possible? how do i force $rowA[0] to be a string
> > ('54')?<http://www.php.net/unsub.php>
>
>
> php should handle the conversion internally for you.
> if you want to type cast a value to a string, simply do
>
> (string)$varname
>
> -nathan
>
I was thinking about saying that, but php is loosely typed, so 54 ==
'54'. I'm thinking something else is wrong here.
--- End Message ---
--- Begin Message ---
On Feb 5, 2008 1:43 PM, Eric Butera <[EMAIL PROTECTED]> wrote:
> I was thinking about saying that, but php is loosely typed, so 54 ==
> '54'.
i only mentioned the type cast because it was asked about; actually, there
are rare times in php when type casts are called for, such as pulling a
value
from a SimpleXMLElement. but that is neither here nor there..
> I'm thinking something else is wrong here.
>
ya, like
$rowB['54'] != 'Y'; // ;)
-nathan
--- End Message ---
--- Begin Message ---
On Feb 5, 2008, at 10:43 AM, "Eric Butera" <[EMAIL PROTECTED]>
wrote:
On Feb 5, 2008 1:40 PM, Nathan Nobbe <[EMAIL PROTECTED]> wrote:
On Feb 5, 2008 1:36 PM, Hiep Nguyen <[EMAIL PROTECTED]> wrote:
hi all,
i have this php statement:
<? if($rowB[$rowA[0]]=='Y') {echo "checked";} ?>
debugging, i got $rowA[0] = 54, but i want $rowB[$rowA[0]] = $rowB
['54'].
is this possible? how do i force $rowA[0] to be a string ('54')?<http://www.php.net/unsub.php
>
php should handle the conversion internally for you.
if you want to type cast a value to a string, simply do
(string)$varname
-nathan
I was thinking about saying that, but php is loosely typed, so 54 ==
'54'. I'm thinking something else is wrong here.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
I believe this is the difference with arrays:
$a = array(2 => "foo");
Array(0 => null, 1 => null, 2 => "foo")
$a = array("2" => "foo");
Array("2" => "foo")
--- End Message ---
--- Begin Message ---
On Feb 5, 2008 1:50 PM, Casey <[EMAIL PROTECTED]> wrote:
> I believe this is the difference with arrays:
>
> $a = array(2 => "foo");
> Array(0 => null, 1 => null, 2 => "foo")
>
> $a = array("2" => "foo");
> Array("2" => "foo")
>
i think the implicit type casting applies there as well:
php > $meh = array(2=>4);
php > echo $meh['2'];
4
php > $meh['2'] = 5;
php > echo $meh['2'];
5
php > echo $meh[2];
5
-nathan
--- End Message ---
--- Begin Message ---
On Feb 5, 2008 1:36 PM, Hiep Nguyen <[EMAIL PROTECTED]> wrote:
> hi all,
>
> i have this php statement:
>
> <? if($rowB[$rowA[0]]=='Y') {echo "checked";} ?>
>
>
> debugging, i got $rowA[0] = 54, but i want $rowB[$rowA[0]] = $rowB['54'].
>
> is this possible? how do i force $rowA[0] to be a string ('54')?
Type casting shouldn't be an issue in this case. For example,
you're not trying to convert alphanumeric characters to int() (which
would actually go to boolean - 0/1), so when trying this case, the
condition is True:
<?
$rowA[] = 54;
$rowA[] = 63;
$rowA[] = 72;
$rowB['54'] = "Y";
$rowB['63'] = "N";
$rowB['72'] = "N";
if($rowB[$rowA[0]]=='Y') { echo "checked.\n"; }
?>
Because of the loose-typecasting nature of PHP (done on purpose),
'54' does, in fact, equal 54, unless otherwise specifically stated.
--
</Dan>
Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>
--- End Message ---
--- Begin Message ---
On Feb 5, 2008 1:48 PM, Nathan Nobbe <[EMAIL PROTECTED]> wrote:
> On Feb 5, 2008 1:43 PM, Eric Butera <[EMAIL PROTECTED]> wrote:
>
> > I was thinking about saying that, but php is loosely typed, so 54 ==
> > '54'.
> i only mentioned the type cast because it was asked about; actually, there
> are rare times in php when type casts are called for, such as pulling a
> value
> from a SimpleXMLElement. but that is neither here nor there..
>
>
> > I'm thinking something else is wrong here.
> >
> ya, like
> $rowB['54'] != 'Y'; // ;)
>
> -nathan
>
Yep, I use them all the time. I just meant that I wasn't sure this is
what was going to get the OP fixed.
--- End Message ---
--- Begin Message ---
Casey schreef:
On Feb 5, 2008, at 10:43 AM, "Eric Butera" <[EMAIL PROTECTED]> wrote:
On Feb 5, 2008 1:40 PM, Nathan Nobbe <[EMAIL PROTECTED]> wrote:
On Feb 5, 2008 1:36 PM, Hiep Nguyen <[EMAIL PROTECTED]> wrote:
hi all,
i have this php statement:
<? if($rowB[$rowA[0]]=='Y') {echo "checked";} ?>
debugging, i got $rowA[0] = 54, but i want $rowB[$rowA[0]] =
$rowB['54'].
is this possible? how do i force $rowA[0] to be a string
('54')?<http://www.php.net/unsub.php>
php should handle the conversion internally for you.
if you want to type cast a value to a string, simply do
(string)$varname
-nathan
I was thinking about saying that, but php is loosely typed, so 54 ==
'54'. I'm thinking something else is wrong here.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
I believe this is the difference with arrays:
$a = array(2 => "foo");
Array(0 => null, 1 => null, 2 => "foo")
$a = array("2" => "foo");
Array("2" => "foo")
not true:
alice:~ jochem$ php -r '
$a = array(2 => "foo"); $b = array("2" => "foo"); var_dump($a, $b);'
array(1) {
[2]=>
string(3) "foo"
}
array(1) {
[2]=>
string(3) "foo"
}
php treats anything that is the string equivelant of an integer as an integer
when
it comes to array keys - which comes down to the fact that you cannot therefore
use
a string version of an integer as an associative key.
so $a[2] and $a["2"] are always the same element.
the same is not exactly true for floats - although you can use them as array
keys you'll
notice in the output of code below that they are stripped of their decimal part
(essentially
a floor() seems to be performed on the float value. I have no idea whether this
is intentional,
and whether you can therefore rely on this behaviour:
alice:~ jochem$ php -r '
$a = array(2.5 => "foo"); $b = array("2.5" => "foo"); var_dump($a, $b);'
array(1) {
[2]=>
string(3) "foo"
}
array(1) {
["2.5"]=>
string(3) "foo"
}
alice:~ jochem$ php -r '
$a = array(2.6 => "foo"); $b = array("2.6" => "foo"); var_dump($a, $b);'
array(1) {
[2]=>
string(3) "foo"
}
array(1) {
["2.6"]=>
string(3) "foo"
}
--- End Message ---
--- Begin Message ---
Use Dreamweaver. It has a lo-tech check-in -- check-out capabilities
-----Original Message-----
From: news [mailto:[EMAIL PROTECTED] On Behalf Of Colin Guthrie
Sent: Tuesday, January 22, 2008 4:32 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Re: Tool for programmer team
Ronald Wiplinger wrote:
> What is a good tool to coordinate a team of programmers efficiently?
>
> To give each one a different part of the project is a start, but it needs
to
> get combined at some points to be a working project.
>
> Not to debug code you have written was a hint, to see actually bugs as a
bug
> and not as a feature.
>
> Some hinted let programmer be on different places, others say put them
> together on a big table, ...
>
> Where can I find more information about that subject?
For me:
* SVN (http://www.subversion.org/) for code/VCS
* Trac (http://trac.edgewall.org/) for Wiki, VCS viewing, tickets/tasks
+ more)
* Timing And Estimation Plugin
(http://www.trac-hacks.org/wiki/TimingAndEstimationPlugin) for tracking
time spent on given tasks)
* Work Log Plugin (http://www.trac-hacks.org/wiki/WorkLogPlugin) for
showing at a glance which tickets the devs are currently (or have
recently been) working on (and to add time automatically).
* Clients Plugin (http://www.trac-hacks.org/wiki/ClientsPlugin) To
track tasks specific to different clients and send edited highlights of
development automatically.
* Doxygen Plugin (http://www.trac-hacks.org/wiki/DoxygenPlugin) to show
doxygen generated code docs inside Trac.
Disclaimer: I wrote Work log and Clients. They integrate nicely with
Timing And Estimation which I also hacked on. There are lots of holes
and lots of improvements that could (and will eventually) be made.
Feel free to ask more questions, but the above works for me and my team.
Col
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
I was able to create a working CURL connection and it was great.
Although, i have another problem.
1. file: connect - I connect via a CURL to a URL and sends two
parameters (application, just wait and hangs) -- this is intentional
2. file: connect - Receives a reply of the two parameters that i had
just sent
3. file: connect - sends a XML post to the remote url (remote url,
closes the connection and application)
Could i send two CURL request in one instance? while waiting?
--
Louie Miranda ([EMAIL PROTECTED])
http://www.axishift.com
Security Is A Series Of Well-Defined Steps
chmod -R 0 / ; and smile :)
--- End Message ---
--- Begin Message ---
Hello,
on 02/05/2008 10:34 PM Louie Miranda said the following:
> I was able to create a working CURL connection and it was great.
>
> Although, i have another problem.
>
>
> 1. file: connect - I connect via a CURL to a URL and sends two
> parameters (application, just wait and hangs) -- this is intentional
> 2. file: connect - Receives a reply of the two parameters that i had
> just sent
> 3. file: connect - sends a XML post to the remote url (remote url,
> closes the connection and application)
>
> Could i send two CURL request in one instance? while waiting?
I am not sure how to do that in a simple way with Curl. The few times I
have used Curl directly, I used custom HTTP requests instead of other
options.
Nowadays I use this HTTP client class that wraps the complexity of the
HTTP protocol and uses preferrably fsockopen to send HTTP requests. Take
a look the test_http_soap.php example which seems to do something
similar to what you want:
http://www.phpclasses.org/httpclient
--
Regards,
Manuel Lemos
PHP professionals looking for PHP jobs
http://www.phpclasses.org/professionals/
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
--- End Message ---