php-general Digest 10 Jan 2008 02:38:49 -0000 Issue 5226
Topics (messages 266966 through 266991):
Re: Posting Summary for Week Ending 4 January, 2008: [EMAIL PROTECTED]
266966 by: Michelle Konzack
266967 by: Daniel Brown
266970 by: Daniel Brown
266974 by: Jochem Maas
266975 by: Daniel Brown
Re: First stupid post of the year. [SOLVED]
266968 by: tedd
266976 by: Nisse Engström
Re: Can't find .php3 files
266969 by: Jim
Re: PHPInfo - the application
266971 by: Lester Caine
Re: http_request
266972 by: peeyush gulati
Re: [PHP-DB] forms and method POST - variables
266973 by: Daniel Brown
PHP SOAP Client formats
266977 by: Tim Traver
266990 by: Bastien Koert
Unable to override status code in certain installations..?
266978 by: RavenWorks
fgetcsv
266979 by: Danny Brow
266980 by: Jim Lucas
266981 by: Daniel Brown
266982 by: Chris
266983 by: Danny Brow
266985 by: Jim Lucas
266988 by: Bastien Koert
PHP Jpeg Uploads Corrupting
266984 by: Scott Wilcox
266986 by: Jim Lucas
266987 by: Scott Wilcox
266989 by: Scott Wilcox
Get Parameters in Includes?
266991 by: Liam
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 ---
Hi Daniel,
Am 2008-01-04 18:31:00, schrieb Daniel Brown:
> Ignore that. It's a new script that is going to start running as
> of 4:00p EST on 11 January, 2008. It will summarize the number of
> messages to the list, then tell who posted how many, what size, et
> cetera.
>
> There may be one or two more messages that will wind up getting
> sent because I accidentally manually ran the live script while testing
> it for the cron.
Is this a Joke? -- I have gotten over 100 of them...
Thanks, Greetings and nice Day
Michelle Konzack
Systemadministrator
Tamay Dogan Network
Debian GNU/Linux Consultant
--
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 MSN LinuxMichi
0033/6/61925193 67100 Strasbourg/France IRC #Debian (irc.icq.com)
signature.pgp
Description: Digital signature
--- End Message ---
--- Begin Message ---
No, go back over the archives or digests and you'll see that it
was supposed to be a once-per-week email for post tracking on the list
that went haywire. It wound up sending over a hundred messages to the
list, which - in my opinion - also indicates a flaw in the mailing
list software.
On Jan 8, 2008 4:57 PM, Michelle Konzack <[EMAIL PROTECTED]> wrote:
> Hi Daniel,
>
> Am 2008-01-04 18:31:00, schrieb Daniel Brown:
> > Ignore that. It's a new script that is going to start running as
> > of 4:00p EST on 11 January, 2008. It will summarize the number of
> > messages to the list, then tell who posted how many, what size, et
> > cetera.
> >
> > There may be one or two more messages that will wind up getting
> > sent because I accidentally manually ran the live script while testing
> > it for the cron.
>
> Is this a Joke? -- I have gotten over 100 of them...
>
> Thanks, Greetings and nice Day
> Michelle Konzack
> Systemadministrator
> Tamay Dogan Network
> Debian GNU/Linux Consultant
>
>
> --
> 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 MSN LinuxMichi
> 0033/6/61925193 67100 Strasbourg/France IRC #Debian (irc.icq.com)
>
--
</Dan>
Daniel P. Brown
Senior Unix Geek and #1 Rated "Year's Coolest Guy" By Self Since 1979.
--- End Message ---
--- Begin Message ---
On Jan 9, 2008 2:01 AM, Wolf <[EMAIL PROTECTED]> wrote:
> Looks like your cron job is set for every minute Don! Please disable it
> until you get the kinks worked out of it!
That was all fixed last week, and no more messages have been sent
since that night.
My apologies once again to everyone for (what was supposed to be)
a surprise with good intentions in mind. It should work just fine
now.... if the datacenter gets the dead hard drive swapped out soon
enough.
2008 is fun!
--
</Dan>
Daniel P. Brown
Senior Unix Geek and #1 Rated "Year's Coolest Guy" By Self Since 1979.
--- End Message ---
--- Begin Message ---
Daniel Brown schreef:
> No, go back over the archives or digests and you'll see that it
> was supposed to be a once-per-week email for post tracking on the list
> that went haywire. It wound up sending over a hundred messages to the
> list, which - in my opinion - also indicates a flaw in the mailing
> list software.
so do we call you 'PostTrack' or "PassTheBuck" from now on? ;-)
>
> On Jan 8, 2008 4:57 PM, Michelle Konzack <[EMAIL PROTECTED]> wrote:
>> Hi Daniel,
>>
>> Am 2008-01-04 18:31:00, schrieb Daniel Brown:
>>> Ignore that. It's a new script that is going to start running as
>>> of 4:00p EST on 11 January, 2008. It will summarize the number of
>>> messages to the list, then tell who posted how many, what size, et
>>> cetera.
>>>
>>> There may be one or two more messages that will wind up getting
>>> sent because I accidentally manually ran the live script while testing
>>> it for the cron.
>> Is this a Joke? -- I have gotten over 100 of them...
>>
>> Thanks, Greetings and nice Day
>> Michelle Konzack
>> Systemadministrator
>> Tamay Dogan Network
>> Debian GNU/Linux Consultant
>>
>>
>> --
>> 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 MSN LinuxMichi
>> 0033/6/61925193 67100 Strasbourg/France IRC #Debian (irc.icq.com)
>>
>
>
>
--- End Message ---
--- Begin Message ---
On Jan 9, 2008 1:45 PM, Jochem Maas <[EMAIL PROTECTED]> wrote:
> Daniel Brown schreef:
> > No, go back over the archives or digests and you'll see that it
> > was supposed to be a once-per-week email for post tracking on the list
> > that went haywire. It wound up sending over a hundred messages to the
> > list, which - in my opinion - also indicates a flaw in the mailing
> > list software.
>
> so do we call you 'PostTrack' or "PassTheBuck" from now on? ;-)
No, you call me The Moron Who Commented-Out The Wrong Line And
Flooded The List With Test Data.
It's a long name, but it's accurate. When I was running the cron
to see why the piped response wasn't working (as it turned out, I had
simply mistyped the address in valiases), it was supposed to send the
data directly to my email address only. However, I commented out the
wrong line, and uncommented the line containing the
[EMAIL PROTECTED] address.
Then, because I didn't know that it was working the whole time,
when I discovered the bugs and repaired them, the messages - sent
every minute by the cron for testing - were queued in the mailing list
database, pending confirmation of the sending address. THIS is the
part I believe is a serious flaw in the mailing list software, because
it's been proven that all a malicious user would have to do is flood
the list, then confirm the address from which they sent the messages
after the queue has been flooded, and the messages will be dispatched.
It should only hold a maximum of two messages in the queue, in my
[very] humble opinion.
The problem was that all of the messages were sitting in the queue
without my knowledge. They were not being sent from the server when
they were being received by subscribers to the list, they were being
sent by the mailing list software. This also identifies an issue that
would suggest that the mailing list system could be vulnerable to a
denial-of-service style of attack, where the queue is flooded with
thousands - even millions - of messages and doesn't dispose of them
properly.
So once again, my apologies, but I do think that the exercise
accidentally identified a security and stability issue with the list
software that should be addressed. Maybe it can be done with a
setting, but it may require a hard-coded patch. I don't know, but
hopefully someone else here does.
--
</Dan>
Daniel P. Brown
Senior Unix Geek and #1 Rated "Year's Coolest Guy" By Self Since 1979.
--- End Message ---
--- Begin Message ---
At 1:19 PM +0100 1/9/08, Nisse Engström wrote:
On Mon, 7 Jan 2008 10:29:45 -0500, tedd wrote:
At 12:03 PM +0100 1/7/08, Nisse Engström wrote:
How does the following pages compare? The display
should be identical:
>><http://luden.se/test/t-1252.html>
>><http://luden.se/test/t-utf8.html>
Nisse:
No, there is quite a difference depending upon
the text encoding used in my browser (Safari).
You said that there was no windows-1252 setting
in Safari, so I am curious to know if it is capable
of mapping the 1252-encoded page to the correct
characters. If you set your browser to detect the
encoding *automatically*, does the two pages display
identically, or are there differences?
According to the mappings at unicode.org, there
are a lot of difference between MACROMAN and CP1252,
for instance, the first character on the page (0x80)
is A-DIARESIS in MACROMAN and EURO SIGN in 1252.
Nisse:
Yes, I said that there is no "windows-1252"
setting for Safari. It does not offer that
"named" setting in it's list of text encodings
available. There is no 1252 mentioned either --
however, that does not mean that it's not there
under a different name. Understandably, I don't
think Apple wants to use the term "windows" in
it's list of text encodings.
There is no Automatic setting. You set whatever
you want the default to be and that's it.
The:
<http://luden.se/test/t-utf8.html>
looks good ONLY under UTF-8 setting.
The:
<http://luden.se/test/t-1252.html>
looks good ONLY under Western (ISO Latin 1).
If I use Western (Mac OS Roman) there is
considerable difference, but it's not gibberish.
HTH's
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---
On Wed, 9 Jan 2008 10:30:59 -0500, tedd wrote:
> Yes, I said that there is no "windows-1252"
> setting for Safari. It does not offer that
> "named" setting in it's list of text encodings
> available. There is no 1252 mentioned either --
> however, that does not mean that it's not there
> under a different name. Understandably, I don't
> think Apple wants to use the term "windows" in
> it's list of text encodings.
>
> There is no Automatic setting. You set whatever
> you want the default to be and that's it.
Interesting. Would you be kind enough to compare
the following pages (with <meta> headers):
<http://luden.se/test/charmap/1252-1252-m.html>
<http://luden.se/test/charmap/1252-utf8-m.html>
For what it's worth, the pages look identical when
viewed with Browsrcamp[1], both with and without[2]
<meta> headers.
/Nisse
- - -
[1]: <http://www.browsrcamp.com/>
[2]: <http://luden.se/test/charmap/1252-1252-t.html>
<http://luden.se/test/charmap/1252-utf8-t.html>
--- End Message ---
--- Begin Message ---
Ford, Mike wrote:
On 09 January 2008 12:18, Anup Shukla wrote:
Jim wrote:
Hi, Mike,
The include is more like
require "../admin/admin.php3" I don't know exactly how Apache
performs its magic so I wasn't sure that the request for an include
file would even pass through Apache's hands. In my limited world,
an include wouldn't have to involve Apache, just the file systems.
The admin.php3 seems to be 2 levels above the current dir.
What about
print realpath("../admin/admin.php3")
in the same script?
That's quite a good suggestion.
Just to be clear about the other point, an include or require is purely file
system based, *unless* you give it a full URL beginning with a protocol name
such as http:// or ftp:// (which, as a general rule, is somewhat
disrecommended!).
Thank you, that confirmed what I suspected.
Jim.
Cheers!
Mike
--- End Message ---
--- Begin Message ---
Richard Heyes wrote:
Do you mean phpsysinfo? http://phpsysinfo.sf.net/
Bingo, thanks.
I bet google works as well now :)
THAT looks a very useful package and it's been sitting in the package list on
all my Linux machines un-found.
I've already got it set up on the local network!
--
Lester Caine - G8HFL
-----------------------------
Contact - http://home.lsces.co.uk/lsces/wiki/?page=contact
L.S.Caine Electronic Services - http://home.lsces.co.uk
MEDW - http://home.lsces.co.uk/ModelEngineersDigitalWorkshop/
Firebird - http://www.firebirdsql.org/index.php
--- End Message ---
--- Begin Message ---
Thank you all for your replies.
We just solved it down using HTTP_REQUEST.
1.What we did was using HTTP_REQUEST a request was send to login page with
post
data credentials like username, password and some other field if required.
2. Then using HTTP_RESPONSE the cookies that were being sent from the
application(viz wordpress,mediawiki) to the layer were retrieved into local
variables.
3. Finally the cookies were set using setcookie() depending what all cookies
were
to be set like sessionid, username and so on.
4. Then using header('Location:URL'); the page was directed to desired
loggedin
page and since the cookies were also set now so the user would not have any
issues in navigating through the application.
If anyone is still not clear or has some doubts please do tell also suggest
if this would have some loop holes.
Thanks once again all.
Peeyush
On Jan 5, 2008 10:18 PM, Daniel Brown <[EMAIL PROTECTED]> wrote:
> On Jan 5, 2008 11:41 AM, peeyush gulati <[EMAIL PROTECTED]> wrote:
> > Thank you will do that
> >
> > Ok can i redirect the response to the browser from the layer after my
> layer
> > has recieved the response from the application.
>
> Absolutely. That's the same premise under which the PayPal IPN
> works. The script ("layer") sends a request to the application, and
> receives a response, parses it if necessary, and feeds that data back
> to the client.
>
> --
> Daniel P. Brown
> [Phone Numbers Go Here!]
> [They're Hidden From View!]
>
> If at first you don't succeed, stick to what you know best so that you
> can make enough money to pay someone else to do it for you.
>
--
Thanks and Regards
Peeyush Gulati
+91-9916304135
--- End Message ---
--- Begin Message ---
On Jan 9, 2008 11:25 AM, Lukáš Moravec <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have one question about forms and php (which I use for Mysql too).
>
> Do I need for variables from any form in html and method POST (then in php
> script) to set these variables with:
>
> $variable=$_POST['variable'];
[snip!]
That's a question that should be asked on the PHP-General list,
actually. I'm forwarding the response to that list with this message.
Are you receiving any errors? Are any messages displayed when you
have the following at the beginning of the script?
<?php
error_reporting("E_ALL");
?>
$_GET and $_POST are predefined superglobal variables, which have
been available in PHP since dinosaurs roamed the Earth.
--
</Dan>
Daniel P. Brown
Senior Unix Geek and #1 Rated "Year's Coolest Guy" By Self Since 1979.
--- End Message ---
--- Begin Message ---
Hi all,
ok, I am a little bit new to the SOAP game, but I understand it, and am
using it to talk to an outside API.
The problem that I have is that the server that I am talking to (that is
not in my control), will accept the following SOAP call
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<AuthenticateTest xmlns="https://api.authorize.net/soap/v1/">
<merchantAuthentication>
<name>name</name>
<transactionKey>string</transactionKey>
</merchantAuthentication>
</AuthenticateTest>
</soap:Body>
</soap:Envelope>
But it refuses a call that I have made using the SOAPClient PHP classes
that look like this :
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="https://api.authorize.net/soap/v1/">
<SOAP-ENV:Body>
<ns1:AuthenticateTest>
<merchantAuthentication>
<name>name</name>
<transactionKey>string</transactionKey>
</merchantAuthentication>
</ns1:AuthenticateTest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
It appears that the one that PHP creates is all in line with all of the
latest standards, and I know that the server is a Microsoft IIS server.
Does anyone know any parameters that I can use with the PHP SOAP client
that could help me contruct the request like the top one???
I don't want to have to build the text myself, and open a socket and
send the text manually like I did to verify that the top one works, and
the bottom one doesn't.
Thanks,
Tim.
--- End Message ---
--- Begin Message ---
XML is case sensitive. I notice the case of the xml is different. Try making
the PHP created xml the same case.
Bastien> Date: Wed, 9 Jan 2008 13:54:36 -0800> From: [EMAIL PROTECTED]> To:
[EMAIL PROTECTED]> Subject: [PHP] PHP SOAP Client formats> > Hi all,> > ok, I
am a little bit new to the SOAP game, but I understand it, and am > using it to
talk to an outside API.> > The problem that I have is that the server that I am
talking to (that is > not in my control), will accept the following SOAP call>
> <?xml version="1.0" encoding="utf-8"?>> <soap:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">> <soap:Body>>
<AuthenticateTest xmlns="https://api.authorize.net/soap/v1/">>
<merchantAuthentication>> <name>name</name>>
<transactionKey>string</transactionKey>> </merchantAuthentication>>
</AuthenticateTest>> </soap:Body>> </soap:Envelope>> > > But it refuses a call
that I have made using the SOAPClient PHP classes > that look like this :> >
<?xml version="1.0" encoding="UTF-8"?>> <SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="https://api.authorize.net/soap/v1/">> <SOAP-ENV:Body>>
<ns1:AuthenticateTest>> <merchantAuthentication>> <name>name</name>>
<transactionKey>string</transactionKey>> </merchantAuthentication>>
</ns1:AuthenticateTest>> </SOAP-ENV:Body>> </SOAP-ENV:Envelope>> > It appears
that the one that PHP creates is all in line with all of the > latest
standards, and I know that the server is a Microsoft IIS server.> > Does anyone
know any parameters that I can use with the PHP SOAP client > that could help
me contruct the request like the top one???> > I don't want to have to build
the text myself, and open a socket and > send the text manually like I did to
verify that the top one works, and > the bottom one doesn't.> > Thanks,> >
Tim.>
_________________________________________________________________
Use fowl language with Chicktionary. Click here to start playing!
http://puzzles.sympatico.msn.ca/chicktionary/index.html?icid=htmlsig
--- End Message ---
--- Begin Message ---
Hello,
I'm currently trying to create a system where a custom 404 ErrorDocument in
PHP is able to 301 Redirect the browser in certain cases. This works fine on
some servers, however, on some other servers the PHP script seems to be
unable to replace the 404 header.
Correctly overrides with '200' status:
http://fidelfilms.ca/redirectTest/
Unable to override default '404' status:
http://fraticelli.info/redirectTest/
Those two pages will look the same in a browser window, but one returns 404
and one returns 200 (as it should, because of the header() call) -- check
with whatever browser plugin you prefer for reading HTTP headers, such as
Live HTTP Headers for Firefox.
Returning the correct status code is important because we're migrating a
site from one domain to another, and we don't want to lose ranking in search
engines. (In the examples above, I return 200 as a test, but in practice
this will be used to 301 all visitors -- and search engines -- to the new
domain.)
My question is this: What causes PHP to be able to override the
ErrorDocument status on some servers and not others? Is it caused by PHP's
behavior or Apache? Is this a configurable option, or was the behavior
permanently changed in a given version of either?
--
View this message in context:
http://www.nabble.com/Unable-to-override-status-code-in-certain-installations..--tp14723283p14723283.html
Sent from the PHP - General mailing list archive at Nabble.com.
--- End Message ---
--- Begin Message ---
Hi Everyone,
I'm trying to compare a value to the first field in a csv fILE (example
of the data below). Using while takes too long and I can't figure out
how to compare just one row at a time. I've tried some variations of the
following.
//Common for all trials
$demoID = fopen("newDemoID.csv", "r");;
$ID = "43";
$data = fgetcsv($demoID);
First try with while:
/*
while ($data) {
if ($data[0] == $wolfID) {
print $data[1] . "," . $data[2] . "," . $data[3] .
".\n";
}
}
*/
Takes for every.
I can't use just the below because it only compares the first row.
/*
if ($data[0] == $wolfID) {
print $data[1] . "," . $data[2] . "," . $data[3] . ".\n";
}
*/
I know this is simple, but I've hit codes block due to lack of sleep.
Thanks,
Dan
Sample Data:
> 5,1,"Smith","Myrtle"
> 6,2,"Smith","Carita"
> 7,3,"Smith","Paul"
> 8,4,"Smith","Donald"
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
--- End Message ---
--- Begin Message ---
Danny Brow wrote:
Hi Everyone,
I'm trying to compare a value to the first field in a csv fILE (example
of the data below). Using while takes too long and I can't figure out
how to compare just one row at a time. I've tried some variations of the
following.
//Common for all trials
$demoID = fopen("newDemoID.csv", "r");;
$ID = "43";
$data = fgetcsv($demoID);
First try with while:
/*
while ($data) {
if ($data[0] == $wolfID) {
print $data[1] . "," . $data[2] . "," . $data[3] .
".\n";
}
}
*/
Takes for every.
I can't use just the below because it only compares the first row.
/*
if ($data[0] == $wolfID) {
print $data[1] . "," . $data[2] . "," . $data[3] . ".\n";
}
*/
I know this is simple, but I've hit codes block due to lack of sleep.
Thanks,
Dan
Sample Data:
5,1,"Smith","Myrtle"
6,2,"Smith","Carita"
7,3,"Smith","Paul"
8,4,"Smith","Donald"
Maybe try something like this.
<?php
//Common for all trials
$fh = fopen("newDemoID.csv", "r");;
# What we are looking for
$ID = "43";
# check for valid handle
if ( is_resource($fh) ) {
# Loop through file handler
# if we get data, we check it
# if/when we get false, we break out of the while loop
while ( ($data = fgetcsv($fh) ) !== false ) {
# Check for the value you are looking for.
if ( $data[0] == $ID ) {
# Obvious...
echo "{$data[1]},{$data[2]},{$data[3]}\n";
}
}
fclose($fh);
}
?>
--
Jim Lucas
"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."
Twelfth Night, Act II, Scene V
by William Shakespeare
--- End Message ---
--- Begin Message ---
On Jan 9, 2008 5:35 PM, Danny Brow <[EMAIL PROTECTED]> wrote:
> Hi Everyone,
>
> I'm trying to compare a value to the first field in a csv fILE (example
> of the data below). Using while takes too long and I can't figure out
> how to compare just one row at a time. I've tried some variations of the
> following.
>
>
> //Common for all trials
> $demoID = fopen("newDemoID.csv", "r");;
> $ID = "43";
>
> $data = fgetcsv($demoID);
>
>
>
> First try with while:
>
> /*
> while ($data) {
> if ($data[0] == $wolfID) {
> print $data[1] . "," . $data[2] . "," . $data[3] .
> ".\n";
> }
> }
> */
As an alternative, you could try this:
<?
$wolfID = "43";
$data = file_get_contents($filename);
$line = explode("\n",$data);
for($i=0;$i<count($line);$i++) {
$field = explode(",",$line[$i]); // Replace the comma with your separator.
$match = str_replace("'",'',str_replace('"','',$field[0])); //
Strip quotes, if they exist.
if($match == $wolfID) {
echo $line[$i]."\n";
}
}
?>
--
</Dan>
Daniel P. Brown
Senior Unix Geek and #1 Rated "Year's Coolest Guy" By Self Since 1979.
--- End Message ---
--- Begin Message ---
Danny Brow wrote:
Hi Everyone,
I'm trying to compare a value to the first field in a csv fILE (example
of the data below). Using while takes too long and I can't figure out
how to compare just one row at a time. I've tried some variations of the
following.
So are you trying to compare the first column or the first row? You've
said you want to compare both.
To compare the first row:
<?php
$handle = fopen('file.csv', 'r') or die("unable to open file");
$my_row = array('1','2','John Smith');
$data = fgetcsv($handle, 1000, ",");
if ($data === false) {
echo "Unable to get anything from the file.";
}
if (is_array($data)) {
if ($data == $my_row) {
echo "The first row matched\n";
} else {
echo "The first row didnt match\n";
}
}
fclose($handle);
If you really do want to compare the first column, then the time to do
it will be based on how big the csv file is. If you have a big file,
it's going to take a long time to go through each row and then look at
the first field.
<?php
$handle = fopen('file.csv', 'r') or die("unable to open file");
$my_value = '1';
$row_count = 0;
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$row_count++;
if ($data[0] == $my_value) {
echo "Found my_value on row ", $row_count, "\n";
} else {
echo "Did not find my_value on row ", $row_count, "\n";
}
}
fclose($handle);
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
I need to compare the first field of each row. But this idea is shot to
hell, i've been running one of the examples on the file and it's been
about an hour+ already... 6500 records have to be checked... I think
MySQL is calling my name right now.
Thanks,
Dan
On Thu, 2008-01-10 at 09:59 +1100, Chris wrote:
> Danny Brow wrote:
> > Hi Everyone,
> >
> > I'm trying to compare a value to the first field in a csv fILE (example
> > of the data below). Using while takes too long and I can't figure out
> > how to compare just one row at a time. I've tried some variations of the
> > following.
>
> So are you trying to compare the first column or the first row? You've
> said you want to compare both.
>
> To compare the first row:
>
> <?php
>
> $handle = fopen('file.csv', 'r') or die("unable to open file");
>
> $my_row = array('1','2','John Smith');
>
> $data = fgetcsv($handle, 1000, ",");
>
> if ($data === false) {
> echo "Unable to get anything from the file.";
> }
>
> if (is_array($data)) {
> if ($data == $my_row) {
> echo "The first row matched\n";
> } else {
> echo "The first row didnt match\n";
> }
> }
>
> fclose($handle);
>
>
> If you really do want to compare the first column, then the time to do
> it will be based on how big the csv file is. If you have a big file,
> it's going to take a long time to go through each row and then look at
> the first field.
>
> <?php
>
> $handle = fopen('file.csv', 'r') or die("unable to open file");
>
> $my_value = '1';
>
> $row_count = 0;
> while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
> $row_count++;
> if ($data[0] == $my_value) {
> echo "Found my_value on row ", $row_count, "\n";
> } else {
> echo "Did not find my_value on row ", $row_count, "\n";
> }
> }
>
> fclose($handle);
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
--- End Message ---
--- Begin Message ---
Danny Brow wrote:
I need to compare the first field of each row. But this idea is shot to
hell, i've been running one of the examples on the file and it's been
about an hour+ already... 6500 records have to be checked... I think
MySQL is calling my name right now.
Thanks,
Dan
On Thu, 2008-01-10 at 09:59 +1100, Chris wrote:
Danny Brow wrote:
Hi Everyone,
I'm trying to compare a value to the first field in a csv fILE (example
of the data below). Using while takes too long and I can't figure out
how to compare just one row at a time. I've tried some variations of the
following.
So are you trying to compare the first column or the first row? You've
said you want to compare both.
To compare the first row:
<?php
$handle = fopen('file.csv', 'r') or die("unable to open file");
$my_row = array('1','2','John Smith');
$data = fgetcsv($handle, 1000, ",");
if ($data === false) {
echo "Unable to get anything from the file.";
}
if (is_array($data)) {
if ($data == $my_row) {
echo "The first row matched\n";
} else {
echo "The first row didnt match\n";
}
}
fclose($handle);
If you really do want to compare the first column, then the time to do
it will be based on how big the csv file is. If you have a big file,
it's going to take a long time to go through each row and then look at
the first field.
<?php
$handle = fopen('file.csv', 'r') or die("unable to open file");
$my_value = '1';
$row_count = 0;
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$row_count++;
if ($data[0] == $my_value) {
echo "Found my_value on row ", $row_count, "\n";
} else {
echo "Did not find my_value on row ", $row_count, "\n";
}
}
fclose($handle);
--
Postgresql & php tutorials
http://www.designmagick.com/
even on a slow machine 6500 records should be very fast.
Are you doing this through a web interface or command line?
If browser, are you sure that your script is still running? Could the PHP
timeout be exceeded?
Try the other example that I gave you.
<pre><?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$st = microtime(true);
$file = '/tmp/testing.csv';
$fh = fopen($file, "w+") or die('Could not open new file for writing');
for ( $i=0; $i<10000; $i++ ) {
fputcsv($fh, array($i,1,"Smith{$i}","Myrtle{$i}"));
}
fclose($fh);
//Common for all trials
$fh = fopen($file, "r") or die('Could not open file ({$file}) for reading');
# What we are looking for
$ID = "9999";
# Loop through file handler
# if we get data, we check it
# if/when we get false, we break out of the while loop
while ( ($data = fgetcsv($fh) ) !== false ) {
# Check for the value you are looking for.
if ( $data[0] == $ID ) {
# Obvious...
echo "{$data[0]},{$data[1]},{$data[2]},{$data[3]}\n";
}
}
fclose($fh);
echo "Run time was ".round(microtime(true) - $st, 6)." seconds.";
?>
I looked for the last result, time for me was
9999,1,Smith9999,Myrtle9999
Run time was 0.333304 seconds.
--
Jim Lucas
"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."
Twelfth Night, Act II, Scene V
by William Shakespeare
--- End Message ---
--- Begin Message ---
http://ca.php.net/manual/en/function.fgetcsv.php
_________________________________________________________________
Discover new ways to stay in touch with Windows Live! Visit the City @ Live
today!
http://getyourliveid.ca/?icid=LIVEIDENCA006
--- End Message ---
--- Begin Message ---
Greetings folks,
I'm having a few issues with PHP this evening. I'm uploading various jpg
images, doing a resize via GD, and then storing the image in a database.
Usually this works fine, but for some unknown reason I'm getting
corrupted uploads. The corruption happens before any processing is done
on the image, and I can't seem to work out why. Form is as follows:
<form enctype="multipart/form-data" action="/account/photo" method="post">
<input name="photo" type="file" />
<input type="submit" name="submit" value="Submit" />
</form>
You can view the corrupting image here:
http://nixbox.org/page_image.php?type=full
Any help would be appreciated greatly, I just can't seem to figure this
one out.
Scott.
--- End Message ---
--- Begin Message ---
Scott Wilcox wrote:
Greetings folks,
I'm having a few issues with PHP this evening. I'm uploading various jpg
images, doing a resize via GD, and then storing the image in a database.
Usually this works fine, but for some unknown reason I'm getting
corrupted uploads. The corruption happens before any processing is done
on the image, and I can't seem to work out why. Form is as follows:
<form enctype="multipart/form-data" action="/account/photo" method="post">
<input name="photo" type="file" />
<input type="submit" name="submit" value="Submit" />
</form>
You can view the corrupting image here:
http://nixbox.org/page_image.php?type=full
Any help would be appreciated greatly, I just can't seem to figure this
one out.
Scott.
First, start your own thread next time. Don't hijack someone else's.
Now a question. Are you doing an error redirect for /account/photo ??
if so, the post data is not carried through the error redirect.
--
Jim Lucas
"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."
Twelfth Night, Act II, Scene V
by William Shakespeare
--- End Message ---
--- Begin Message ---
Jim Lucas wrote:
Scott Wilcox wrote:
Greetings folks,
I'm having a few issues with PHP this evening. I'm uploading various
jpg images, doing a resize via GD, and then storing the image in a
database.
Usually this works fine, but for some unknown reason I'm getting
corrupted uploads. The corruption happens before any processing is
done on the image, and I can't seem to work out why. Form is as follows:
<form enctype="multipart/form-data" action="/account/photo"
method="post">
<input name="photo" type="file" />
<input type="submit" name="submit" value="Submit" />
</form>
You can view the corrupting image here:
http://nixbox.org/page_image.php?type=full
Any help would be appreciated greatly, I just can't seem to figure
this one out.
Scott.
First, start your own thread next time. Don't hijack someone else's.
Now a question. Are you doing an error redirect for /account/photo ??
if so, the post data is not carried through the error redirect.
Ah my bad, I'd just edited as new :)
/account/photo is a standard apache rewrite, which usually passes the
data through no problem. Other forms within the page post fine, although
none of them are receiving data. It seems that the data is getting
there, just not as it should be.
Any ideas on how to debug/where to go from here?
Thanks.
Scott.
--- End Message ---
--- Begin Message ---
Ah, ignore. Problem seems to be solved. Some piping seems to have caused
corrupting. All working now. Thanks anyway folks! :)
Scott Wilcox wrote:
Jim Lucas wrote:
Scott Wilcox wrote:
Greetings folks,
I'm having a few issues with PHP this evening. I'm uploading various
jpg images, doing a resize via GD, and then storing the image in a
database.
Usually this works fine, but for some unknown reason I'm getting
corrupted uploads. The corruption happens before any processing is
done on the image, and I can't seem to work out why. Form is as
follows:
<form enctype="multipart/form-data" action="/account/photo"
method="post">
<input name="photo" type="file" />
<input type="submit" name="submit" value="Submit" />
</form>
You can view the corrupting image here:
http://nixbox.org/page_image.php?type=full
Any help would be appreciated greatly, I just can't seem to figure
this one out.
Scott.
First, start your own thread next time. Don't hijack someone else's.
Now a question. Are you doing an error redirect for /account/photo ??
if so, the post data is not carried through the error redirect.
Ah my bad, I'd just edited as new :)
/account/photo is a standard apache rewrite, which usually passes the
data through no problem. Other forms within the page post fine,
although none of them are receiving data. It seems that the data is
getting there, just not as it should be.
Any ideas on how to debug/where to go from here?
Thanks.
Scott.
--- End Message ---
--- Begin Message ---
How do I use a get parameter in a include?
e.g.
<?php include('x.cgi?want=ssilinks') ?>
I can't modify the cgi file though, and HTML includes don't work on my
server.
Thanks in advance.
--- End Message ---