php-general Digest 4 Oct 2010 21:08:56 -0000 Issue 6973
Topics (messages 308417 through 308449):
Re: Syntax Error
308417 by: [email protected]
New to PHP and struggling with the basics
308418 by: Col Day
308419 by: Peter Lind
308422 by: kranthi
308423 by: Abah Joseph
308428 by: Col Day
308429 by: kranthi
308431 by: Alejandro Michelin Salomon
308433 by: Col Day
308436 by: Steve Staples
308438 by: Col Day
308439 by: Col Day
Re: file_get_contents() failing on CentOS.
308420 by: Richard Quadling
308421 by: kranthi
308424 by: Richard Quadling
308427 by: Richard Quadling
308430 by: kranthi
Re: Little Parsing help...
308425 by: Richard Quadling
308426 by: Richard Quadling
308437 by: Adam Richardson
308440 by: Richard Quadling
open .zip from memory...
308432 by: Steve Staples
308442 by: Jim Lucas
308443 by: Steve Staples
Re: cant find uploaded file in /tmp.
308434 by: tedd
Is it possible to create a global namespace alias?
308435 by: Matt Palermo
Join me on Multiply
308441 by: Farianto Kurniawan (via Multiply)
PHPExcel with large files (27,000+ rows)
308444 by: chris h
308445 by: Per Jessen
308446 by: Marc Guay
308447 by: shiplu
308448 by: chris h
Connecting to MySql with PHP
308449 by: sueandant
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 ---
Switching to pdo won't necessarily remove sql errors any more than using a php
framework will remove php errors.
Thanks,
Ash
http://www.ashleysheridan.co.uk
----- Reply message -----
From: "kranthi" <[email protected]>
Date: Mon, Oct 4, 2010 09:04
Subject: [PHP] Syntax Error
To: <[email protected]>
Cc: "chris h" <[email protected]>, "Gary" <[email protected]>,
<[email protected]>
As pointed out echo $insertSQl should help you locate many trivial
problems. But using PDO will avoid these kind of problems
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Hi all,
Working with the PHP5 for Dummies book (yup real noob, feel free to ridicule
(after telling me what I've done wrong)) and have installed Apache 2.2 and
PHP 5.3.3 onto a laptop running Vista. (yes I know!!!).
I've had Apache running fine with my basic web site created using Serif's
Webplus10 but wanted to experiment with PHP as I want an uploadable area on
my website for my friends and family to submit video/photos.
I've checked the install of PHP using php -v and I get the output that
PHP 5.3.3 (cli) (built: Jul 21 2010 20:10:20)
but when I try and go to the test.php file (below) I get an http 403 webiste
requires you to log in. Error message.
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<p>This is an HTML line
<?php
echo "<p>This is a PHP line</p>";
phpinfo();
?>
</body>
</html>
This is the text of the test.php file which I have plonked down in
/apache/htdocs
What have I missed?
the Dummies book is quoting PHP 5.0.0 as the latest release so not too far
away really.
Thanks for your help.
Cheers.
Col Day
--- End Message ---
--- Begin Message ---
On 4 October 2010 11:30, Col Day <[email protected]> wrote:
> Hi all,
>
> Working with the PHP5 for Dummies book (yup real noob, feel free to ridicule
> (after telling me what I've done wrong)) and have installed Apache 2.2 and
> PHP 5.3.3 onto a laptop running Vista. (yes I know!!!).
>
> I've had Apache running fine with my basic web site created using Serif's
> Webplus10 but wanted to experiment with PHP as I want an uploadable area on
> my website for my friends and family to submit video/photos.
>
> I've checked the install of PHP using php -v and I get the output that
>
> PHP 5.3.3 (cli) (built: Jul 21 2010 20:10:20)
>
> but when I try and go to the test.php file (below) I get an http 403 webiste
> requires you to log in. Error message.
>
> <html>
> <head>
> <title>PHP Test</title>
> </head>
> <body>
> <p>This is an HTML line
> <?php
> echo "<p>This is a PHP line</p>";
> phpinfo();
> ?>
> </body>
> </html>
>
> This is the text of the test.php file which I have plonked down in
> /apache/htdocs
>
> What have I missed?
>
> the Dummies book is quoting PHP 5.0.0 as the latest release so not too far
> away really.
>
A) v5.0.0 is years old. B) your issue is with apache, not php - 403 is
a "you have no permission to see this".
Check permissions for the file you're trying to test, as well as for
the folder. Also, seeing as you're naming the file test.php, make sure
you're browsing for that file and not just / or index.php.
Regards
Peter
--
<hype>
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15
</hype>
--- End Message ---
--- Begin Message ---
apache error logs will be helpful in this case. Their location varies
depending upon your installation. But in any case they'll be insde
your server directory (IIRC it is c:/Program Files/Apache Software
Foundation/Apache by default)
--- End Message ---
--- Begin Message ---
Your directory configuration should look like this
<Directory "C:\path_to_www_root">
Order Deny,Allow
Allow from all
Options Indexes FollowSymLinks Includes ExecCGI
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All
</Directory>
On Mon, Oct 4, 2010 at 10:53 AM, kranthi <[email protected]> wrote:
> apache error logs will be helpful in this case. Their location varies
> depending upon your installation. But in any case they'll be insde
> your server directory (IIRC it is c:/Program Files/Apache Software
> Foundation/Apache by default)
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Share with free mind!
Join the world largest open forum for hackers and programmers.
http://www.tuwana.com
--- End Message ---
--- Begin Message ---
Kranthi
Many thanks, any idea on the name of the error logs?
Peter,
Yes, browsing to the correct location but still getting the 403. this
website requires you to log in.
Abah,
I've gone to the httpd-userdir.conf file and replaced it with your text (not
including the directory tree), restarted apache (after each change) but am
still getting the same error.
However I have found that if I paste the html into my web page created by
Serif WebPlus 10 I get the "html" line but not the "php" line.
Any further thoughts?
It has to be something simple that I'vw not done!
Cheers all.
"kranthi" <[email protected]> wrote in message
news:[email protected]...
apache error logs will be helpful in this case. Their location varies
depending upon your installation. But in any case they'll be insde
your server directory (IIRC it is c:/Program Files/Apache Software
Foundation/Apache by default)
--- End Message ---
--- Begin Message ---
they should be something like error_log-[date] not sure about windows though
>>However I have found that if I paste the html into my web page created by
>>Serif WebPlus 10 I get the "html" line but not the "php" line.
are you saying that you are getting the php code in your browser ?
<?php
echo "<p>This is a PHP line</p>";
phpinfo();
?>
--- End Message ---
--- Begin Message ---
Col Day :
Go to : "C:\Arquivos de programas\Apache Software Foundation\Apache2.2\conf"
or the folder in your machine.
Search for this file => httpd.conf
Search for DocumentRoot "D:/webroot" put your work folder in my case
D:/webroot.
Search for this line and apply the same changes make in DocumentRoot
#
# This should be changed to whatever you set DocumentRoot to
#
<Directory "D:/webroot">
Search for DirectoryIndex, and add index.php to the list
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
Add on the end of the file this lines :
My php installation folder is D:/PHP/, change D:/PHP/ to your installation
folder.
#BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
PHPIniDir "D:/PHP/"
# Php as Apache module
LoadModule php5_module "D:/PHP/php5apache2_2.dll"
Restart apache.
Browse to localhost
Alejandro M.S.
-----Mensagem original-----
De: Col Day [mailto:[email protected]]
Enviada em: segunda-feira, 4 de outubro de 2010 06:31
Para: [email protected]
Assunto: [PHP] New to PHP and struggling with the basics
Hi all,
Working with the PHP5 for Dummies book (yup real noob, feel free to ridicule
(after telling me what I've done wrong)) and have installed Apache 2.2 and
PHP 5.3.3 onto a laptop running Vista. (yes I know!!!).
I've had Apache running fine with my basic web site created using Serif's
Webplus10 but wanted to experiment with PHP as I want an uploadable area on
my website for my friends and family to submit video/photos.
I've checked the install of PHP using php -v and I get the output that
PHP 5.3.3 (cli) (built: Jul 21 2010 20:10:20)
but when I try and go to the test.php file (below) I get an http 403 webiste
requires you to log in. Error message.
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<p>This is an HTML line
<?php
echo "<p>This is a PHP line</p>";
phpinfo();
?>
</body>
</html>
This is the text of the test.php file which I have plonked down in
/apache/htdocs
What have I missed?
the Dummies book is quoting PHP 5.0.0 as the latest release so not too far
away really.
Thanks for your help.
Cheers.
Col Day
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Hi Kranthi,
No, I just literally get the "HTML" line shown but absolutely nothing
beneath it.
"kranthi" <[email protected]> wrote in message
news:[email protected]...
they should be something like error_log-[date] not sure about windows
though
However I have found that if I paste the html into my web page created by
Serif WebPlus 10 I get the "html" line but not the "php" line.
are you saying that you are getting the php code in your browser ?
<?php
echo "<p>This is a PHP line</p>";
phpinfo();
?>
--- End Message ---
--- Begin Message ---
Col.
Since you're new to php, then an easy way to install apache, is using
XAMPP ( http://www.apachefriends.org/en/xampp.html )
I would suggest you remove the apache you have installed, and the php
you installed, and install the XAMPP package as it comes prebuilt with
mysql, ftp, apache and php, and it is simple to use/work with.
And if you install to defaults there, you will put your web files into
C:\xampp\htdocs\ and everythign should just work.
The way i read your initial post, is that you installed just apache, and
just php... if you did this, then you may not have integrated php into
apache properly, so then your php pages will not work.
just my $0.02 here, cuz if it doesn't work after you install XAMPP, then
there is something else wrong.
And the other thing, is that you're running on vista, and vista doesn't
like things running on localhost (or at least it didn't used to)
Steve
On Mon, 2010-10-04 at 13:51 +0100, Col Day wrote:
> Hi Kranthi,
>
> No, I just literally get the "HTML" line shown but absolutely nothing
> beneath it.
>
> "kranthi" <[email protected]> wrote in message
> news:[email protected]...
> > they should be something like error_log-[date] not sure about windows
> > though
> >
> >>>However I have found that if I paste the html into my web page created by
> >>>Serif WebPlus 10 I get the "html" line but not the "php" line.
> >
> > are you saying that you are getting the php code in your browser ?
> > <?php
> > echo "<p>This is a PHP line</p>";
> > phpinfo();
> > ?>
>
>
--- End Message ---
--- Begin Message ---
Steve,
That's superb, many thanks for the link! I shall give it a go!
Yes I did install apache then php, however I tried to follow the
instructions in the Dummies book (what does it make me if I can't follow the
dummies book?) but to no avail.
I have just printed off the first 40 pages so that i can read it whilst
looking at the screen ratrher than switching about, however I will give
Xammp a go first and foremost seeing as I only want to test my own web page
before I start to buy hosting elsewhere.
Seeing as you are so great :-) Any ideas of the best way to script an upload
page that will deliver files to the server?
Family photo's and video clips mainly.
Thoughts?
Also, many thanks to everyone who has tried to help a muppet. But I guess we
all gotta start somewhere!
Cheers again!
"Steve Staples" <[email protected]> wrote in message
news:1286202653.4703.48.ca...@webdev01...
Col.
Since you're new to php, then an easy way to install apache, is using
XAMPP ( http://www.apachefriends.org/en/xampp.html )
I would suggest you remove the apache you have installed, and the php
you installed, and install the XAMPP package as it comes prebuilt with
mysql, ftp, apache and php, and it is simple to use/work with.
And if you install to defaults there, you will put your web files into
C:\xampp\htdocs\ and everythign should just work.
The way i read your initial post, is that you installed just apache, and
just php... if you did this, then you may not have integrated php into
apache properly, so then your php pages will not work.
just my $0.02 here, cuz if it doesn't work after you install XAMPP, then
there is something else wrong.
And the other thing, is that you're running on vista, and vista doesn't
like things running on localhost (or at least it didn't used to)
Steve
On Mon, 2010-10-04 at 13:51 +0100, Col Day wrote:
Hi Kranthi,
No, I just literally get the "HTML" line shown but absolutely nothing
beneath it.
"kranthi" <[email protected]> wrote in message
news:[email protected]...
> they should be something like error_log-[date] not sure about windows
> though
>
>>>However I have found that if I paste the html into my web page created
>>>by
>>>Serif WebPlus 10 I get the "html" line but not the "php" line.
>
> are you saying that you are getting the php code in your browser ?
> <?php
> echo "<p>This is a PHP line</p>";
> phpinfo();
> ?>
--- End Message ---
--- Begin Message ---
In addition, I think I may have got to the bottom of what I was doing wrong
in the first place.
I recently swapped out my laptop for my wifes one (she upgraded, well I
upgraded hers, and I got the old one) and I forgot that this one didn't
automatically boot up into the Administrator profile.
Doh!
Cheers again all!
""Col Day"" <[email protected]> wrote in message
news:[email protected]...
Steve,
That's superb, many thanks for the link! I shall give it a go!
Yes I did install apache then php, however I tried to follow the
instructions in the Dummies book (what does it make me if I can't follow
the dummies book?) but to no avail.
I have just printed off the first 40 pages so that i can read it whilst
looking at the screen ratrher than switching about, however I will give
Xammp a go first and foremost seeing as I only want to test my own web
page before I start to buy hosting elsewhere.
Seeing as you are so great :-) Any ideas of the best way to script an
upload page that will deliver files to the server?
Family photo's and video clips mainly.
Thoughts?
Also, many thanks to everyone who has tried to help a muppet. But I guess
we all gotta start somewhere!
Cheers again!
"Steve Staples" <[email protected]> wrote in message
news:1286202653.4703.48.ca...@webdev01...
Col.
Since you're new to php, then an easy way to install apache, is using
XAMPP ( http://www.apachefriends.org/en/xampp.html )
I would suggest you remove the apache you have installed, and the php
you installed, and install the XAMPP package as it comes prebuilt with
mysql, ftp, apache and php, and it is simple to use/work with.
And if you install to defaults there, you will put your web files into
C:\xampp\htdocs\ and everythign should just work.
The way i read your initial post, is that you installed just apache, and
just php... if you did this, then you may not have integrated php into
apache properly, so then your php pages will not work.
just my $0.02 here, cuz if it doesn't work after you install XAMPP, then
there is something else wrong.
And the other thing, is that you're running on vista, and vista doesn't
like things running on localhost (or at least it didn't used to)
Steve
On Mon, 2010-10-04 at 13:51 +0100, Col Day wrote:
Hi Kranthi,
No, I just literally get the "HTML" line shown but absolutely nothing
beneath it.
"kranthi" <[email protected]> wrote in message
news:[email protected]...
> they should be something like error_log-[date] not sure about windows
> though
>
>>>However I have found that if I paste the html into my web page
>>>created by
>>>Serif WebPlus 10 I get the "html" line but not the "php" line.
>
> are you saying that you are getting the php code in your browser ?
> <?php
> echo "<p>This is a PHP line</p>";
> phpinfo();
> ?>
--- End Message ---
--- Begin Message ---
On 1 October 2010 16:19, kranthi <[email protected]> wrote:
> probably not the issue, but is the php engine behind a proxy server ?
> wget uses the environment variable, but PHP does not
>
> Kranthi.
> http://goo.gl/e6t3
>
Hopefully getting a reply today on this.
What env_var is used by wget?
--
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY
--- End Message ---
--- Begin Message ---
http_proxy or HTTP_PROXY i m not sure
--- End Message ---
--- Begin Message ---
On 4 October 2010 10:48, kranthi <[email protected]> wrote:
> http_proxy or HTTP_PROXY i m not sure
>
Thanks. Passing it on (and learning a bit).
--
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY
--- End Message ---
--- Begin Message ---
On 4 October 2010 11:24, Richard Quadling <[email protected]> wrote:
> On 4 October 2010 10:48, kranthi <[email protected]> wrote:
>> http_proxy or HTTP_PROXY i m not sure
>>
>
> Thanks. Passing it on (and learning a bit).
http://docs.php.net/manual/en/function.stream-context-get-default.php#72086
Could help to some degree. Not sure if SOAPClient will go through the
context, though there is a 'stream_context' parameter that can be set
...
All passed on.
--
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY
--- End Message ---
--- Begin Message ---
and if proxxy is the issue http://proxychains.sf.net/ will help
--- End Message ---
--- Begin Message ---
On 1 October 2010 16:20, Don Wieland <[email protected]> wrote:
> The logic I need is pretty straight forward, but I am having a hard time
> replicating it using PHP functions. I will try to break it down to it's
> simplest form:
>
> I have a field that has several lines of text. Chords and Song Lyrics.
>
> The "Chord" lines begin with an asterisk "*" and end with the line break.
> This is the string I want to parse. Lines with no asterisk at the beginning
> are ignored.
>
> Based on 3 arrays of NOTES, I want SUBSTITUTE the text (based on exact text
> character patterns - just NOTES not the chord type) of the lines in my field
> that start with an asterisk "*".
>
> original_chord_array = A, A#, B, C, C#, D, D#, E, F, F#, G, G#
> transpose_up_array = A#, B, C, C#, D, D#, E, F, F#, G, G#, A
> transpose_down_array = G#, A, A#, B, C, C#, D, D#, E, F, F#, G
>
> It is important that it only effects EXACT strings. Notes will always be
> capitalized and chord types will be lower case. Maybe we can use that
> characteristic to better identify what to change. Here are some examples of
> chords:
>
> A
> Asus7
> Csus add9
> Dmaj7
> F#m7
> G#
> C#dim no3
>
> When I transpose UP these chords, just the NOTE should change:
>
> A#
> A#sus7
> C#sus add9
> D#maj7
> Gm7
> A
> Ddim no3
>
> When I transpose DOWN these chords, just the NOTE should change:
>
> G#
> G#sus7
> Bsus add9
> C#maj7
> Fm7
> G
> Cdim no3
>
> I am working on a function, but still not producing the proper results.
> Hopefully this break down is more clear and someone will bail me out ;-)
>
> Thanks again for the feedback.
>
> Don
>
> On Oct 1, 2010, at 7:02 AM, Richard Quadling wrote:
>
>> Changing the NormalKeyID and using that ID with NoteSequenceNumber
>> should give you the new note to play.
>>
>> I think.
>
>
/**
* Transpose a chord sequence.
*
* @param $s_Sequence The chord sequence to transpose.
* @param $b_TransposeUp Transpose up or down.
*
* @return The transposed sequence.
*/
function transposeChord($s_Sequence, $b_TransposeUp = True) {
$a_Chords = array('A', 'A#', 'B', 'C', 'C#', 'D', 'D#', 'E', 'F',
'F#', 'G', 'G#');
return preg_replace_callback (
'`([A-G]#?)`',
function($a_Matches) use($a_Chords, $b_TransposeUp) {
// Find the position in the chords array of the found
chord.
$a_ChordPositions = array_keys($a_Chords,
$a_Matches[1], True);
// Get the new chord position.
$i_NewChordPosition = (count($a_Chords) +
$a_ChordPositions[0] +
($b_TransposeUp ? 1 : -1)) % count($a_Chords);
// Return the new chord position.
return $a_Chords[$i_NewChordPosition];
},
$s_Sequence
);
}
--
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY
--- End Message ---
--- Begin Message ---
On 4 October 2010 11:26, Richard Quadling <[email protected]> wrote:
> On 1 October 2010 16:20, Don Wieland <[email protected]> wrote:
>> The logic I need is pretty straight forward, but I am having a hard time
>> replicating it using PHP functions. I will try to break it down to it's
>> simplest form:
>>
>> I have a field that has several lines of text. Chords and Song Lyrics.
>>
>> The "Chord" lines begin with an asterisk "*" and end with the line break.
>> This is the string I want to parse. Lines with no asterisk at the beginning
>> are ignored.
>>
>> Based on 3 arrays of NOTES, I want SUBSTITUTE the text (based on exact text
>> character patterns - just NOTES not the chord type) of the lines in my field
>> that start with an asterisk "*".
>>
>> original_chord_array = A, A#, B, C, C#, D, D#, E, F, F#, G, G#
>> transpose_up_array = A#, B, C, C#, D, D#, E, F, F#, G, G#, A
>> transpose_down_array = G#, A, A#, B, C, C#, D, D#, E, F, F#, G
>>
>> It is important that it only effects EXACT strings. Notes will always be
>> capitalized and chord types will be lower case. Maybe we can use that
>> characteristic to better identify what to change. Here are some examples of
>> chords:
>>
>> A
>> Asus7
>> Csus add9
>> Dmaj7
>> F#m7
>> G#
>> C#dim no3
>>
>> When I transpose UP these chords, just the NOTE should change:
>>
>> A#
>> A#sus7
>> C#sus add9
>> D#maj7
>> Gm7
>> A
>> Ddim no3
>>
>> When I transpose DOWN these chords, just the NOTE should change:
>>
>> G#
>> G#sus7
>> Bsus add9
>> C#maj7
>> Fm7
>> G
>> Cdim no3
>>
>> I am working on a function, but still not producing the proper results.
>> Hopefully this break down is more clear and someone will bail me out ;-)
>>
>> Thanks again for the feedback.
>>
>> Don
>>
>> On Oct 1, 2010, at 7:02 AM, Richard Quadling wrote:
>>
>>> Changing the NormalKeyID and using that ID with NoteSequenceNumber
>>> should give you the new note to play.
>>>
>>> I think.
http://pastebin.com/rsV35czb
Code with tests and output.
--
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY
--- End Message ---
--- Begin Message ---
On Mon, Oct 4, 2010 at 6:29 AM, Richard Quadling <[email protected]>wrote:
>
> http://pastebin.com/rsV35czb
>
> Code with tests and output.
>
>
Nice code, Richard.
Adam
--
Nephtali: PHP web framework that functions beautifully
http://nephtaliproject.com
--- End Message ---
--- Begin Message ---
On 4 October 2010 16:10, Adam Richardson <[email protected]> wrote:
> On Mon, Oct 4, 2010 at 6:29 AM, Richard Quadling <[email protected]>wrote:
>
>>
>> http://pastebin.com/rsV35czb
>>
>> Code with tests and output.
>>
>>
> Nice code, Richard.
>
> Adam
Thank you.
--
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY
--- End Message ---
--- Begin Message ---
Not sure if my subject is misleading or not, but anyway, here it goes...
I am trying to download a file using file_get_contents($url) which
happens to be a .zip file.
I have no issues downloading the file, saving it to the harddrive,
opening it, and getting what i need from it... but what I am trying to
do, is not save it to disk, but to just grab the .zip file, and open it
in memory, grab the file i need from it, and then discard the .zip file,
and parse out the file i grabbed (this would prevent having a folder
with R/W access that could possibly be set wrong, or using the /tmp
folder)
Again, I dont have any issues doing it where i save it first, but when I
try to use the file from memory, i get errors saying that it can't open
the zip file becuase it has no valid resource id#.
The zip commands i am using, are the php ones zip_open, zip_read,
zip_entry_read, zip_entry_name, zip_entry_filesize and obviously
zip_close.
Can this be done, or should I just forget it, and use the /tmp dir?
Steve.
--- End Message ---
--- Begin Message ---
Steve Staples wrote:
> Not sure if my subject is misleading or not, but anyway, here it goes...
>
> I am trying to download a file using file_get_contents($url) which
> happens to be a .zip file.
>
> I have no issues downloading the file, saving it to the harddrive,
> opening it, and getting what i need from it... but what I am trying to
> do, is not save it to disk, but to just grab the .zip file, and open it
> in memory, grab the file i need from it, and then discard the .zip file,
> and parse out the file i grabbed (this would prevent having a folder
> with R/W access that could possibly be set wrong, or using the /tmp
> folder)
>
> Again, I dont have any issues doing it where i save it first, but when I
> try to use the file from memory, i get errors saying that it can't open
> the zip file becuase it has no valid resource id#.
>
> The zip commands i am using, are the php ones zip_open, zip_read,
> zip_entry_read, zip_entry_name, zip_entry_filesize and obviously
> zip_close.
>
> Can this be done, or should I just forget it, and use the /tmp dir?
>
> Steve.
>
>
>
>
Might see if this page will glean you any information
http://us3.php.net/manual/en/wrappers.php.php
I think the php://temp or php://memory will work for you instead of a file on
the file system.
Jim
--- End Message ---
--- Begin Message ---
On Mon, 2010-10-04 at 10:12 -0700, Jim Lucas wrote:
> Steve Staples wrote:
> > Not sure if my subject is misleading or not, but anyway, here it goes...
> >
> > I am trying to download a file using file_get_contents($url) which
> > happens to be a .zip file.
> >
> > I have no issues downloading the file, saving it to the harddrive,
> > opening it, and getting what i need from it... but what I am trying to
> > do, is not save it to disk, but to just grab the .zip file, and open it
> > in memory, grab the file i need from it, and then discard the .zip file,
> > and parse out the file i grabbed (this would prevent having a folder
> > with R/W access that could possibly be set wrong, or using the /tmp
> > folder)
> >
> > Again, I dont have any issues doing it where i save it first, but when I
> > try to use the file from memory, i get errors saying that it can't open
> > the zip file becuase it has no valid resource id#.
> >
> > The zip commands i am using, are the php ones zip_open, zip_read,
> > zip_entry_read, zip_entry_name, zip_entry_filesize and obviously
> > zip_close.
> >
> > Can this be done, or should I just forget it, and use the /tmp dir?
> >
> > Steve.
> >
> >
> >
> >
>
> Might see if this page will glean you any information
>
> http://us3.php.net/manual/en/wrappers.php.php
>
> I think the php://temp or php://memory will work for you instead of a file on
> the file system.
>
> Jim
>
Jim:
That is exactly what I was looking for... man, I feel dumb... I was
looking at the tmpfile() and tmpname() but it wasn't quite what i was
looking for. I've use the php://xxx before, but it slipped my mind.
thanks again :) I will implement this tonight :)
Steve
--- End Message ---
--- Begin Message ---
At 7:16 PM +0100 10/3/10, Ashley Sheridan wrote:
On Sun, 2010-10-03 at 20:53 +0300, Prekates Alexandros wrote:
Hi to the list.
Trying to test php upload i used a very simple scrip.
I managed to upload files but i dont understand why the dont
stay in the /tmp dir where the initialy are put even if i dont move them
to another dir.
alex.
Files are put into the /tmp directory by Apache, before PHP is even
aware of them. Unless you create a copy of the file, then Apache will
clean it up after your script has run (or at least it's supposed to, but
sometimes /tmp becomes a little cluttered with crud)
The best thing to do is to use move_uploaded_file to move the file to
someplace, and give the file a new name (or keep the same one and add an
extension if you want to ensure the file is given a unique name in the
directory you're putting it into)
There are lots of different scripts on the manual page for
move_uploaded_file if you're feeling a little stuck. As a safety
precaution, it's considered good practice to copy the file to a location
outside of your document root. So if your document root
is /var/www/html/ then maybe put the file in /var/www/user_files/ . This
means that people can't use your website to upload their own scripts and
gain access to your server, although it does mean you need to find an
alternative way to serve up that file if you need, but that is quite
easy, and there are lots of example scripts about for that if you need;
many people on the list have written their own, and Tedd most likely has
an example somewhere too!
Thanks,
Ash
Ash:
Thanks for the plug. The code is pretty simple.
If the "simple script" the OP used did indeed move the file to the
tmp directory, then it should be there for him to see.
I suspect that: 1) the upload script is not working properly; 2) or
the OP needs to refresh his IDE to reflect changes made to the server.
Cheers,
tedd
--
-------
http://sperling.com/
--- End Message ---
--- Begin Message ---
Is it possible to create a global namespace alias in PHP or does the alias
have to be defined in EVERY file that I use? Here is an example:
file: main.php
<?php
use \this\is\my\custom\namespace\Item as nsItem;
?>
file: index.php
<?php
require_once “main.php”;
// Attempt to use namespace alias defined in main.php file
nsItem::test();
?>
The above code doesn’t work for me. The namespace alias defined in the
main.php file isn’t accessible in the index.php file. Is there a way to make
the “nsItem” alias a “global” one, so that I don’t have to define it in EVERY
file that I want to use?
-Matt
--- End Message ---
--- Begin Message ---
Check out my Multiply site
I set up a Multiply site with my pictures, videos and blog and I want
to add you as my friend so you can see it. First, you need to join
Multiply! Once you join, you can also create your own site and share
anything you want, with anyone you want.
Here's the link:
http://multiply.com/si/aCD2q,fg,4cQ+pf+4etZKQ
Thanks,
Farianto
Stop e-mails, view our privacy policy, or report abuse:
http://multiply.com/bl/aCD2q,fg,4cQ+pf+4etZKQ
We haven't added your email address to any lists, nor will we share it
with anyone at any time.
Copyright 2010 Multiply
6001 Park of Commerce Blvd, Boca Raton, FL
--- End Message ---
--- Begin Message ---
I'm currently working on a project that requires the parsing of excel files.
Basically the user uploads an excel file, and then a script needs to save a
row in a Postgres database for each row in the excel file. The issue we are
having is that when we task PHPExcel with parsing an excel file with, say
27k rows, it explodes with a memory error. I've read up on the PHPExcel
forums and we've tried cell caching as well as ReadDataOnly, they do not
seem to be sufficient.
Does anyone here know of a way to do this? Surely there is a way to parse a
large excel file with PHP. This is also NOT an on-demand service. That is,
when someone uploads a file they get a task_id which allows them to check
the status of their excel file. So the solution does not need to be a fast
one!
Thanks,
Chris.
--- End Message ---
--- Begin Message ---
chris h wrote:
> I'm currently working on a project that requires the parsing of excel
> files. Basically the user uploads an excel file, and then a script
> needs to save a row in a Postgres database for each row in the excel
> file. The issue we are having is that when we task PHPExcel with
> parsing an excel file with, say 27k rows, it explodes with a memory
> error. I've read up on the PHPExcel forums and we've tried cell
> caching as well as ReadDataOnly, they do not seem to be sufficient.
>
> Does anyone here know of a way to do this? Surely there is a way to
> parse a large excel file with PHP.
If your excel file is or can be transformed to XML, I would just use
XSLT. No PHP needed.
--
Per Jessen, Zürich (19.1°C)
--- End Message ---
--- Begin Message ---
I use this: http://code.google.com/p/php-csv-parser/
No idea if it's any better than your current solution. I presume
you've tried extending PHP's memory limit?
--- End Message ---
--- Begin Message ---
On Tue, Oct 5, 2010 at 12:39 AM, chris h <[email protected]> wrote:
> I'm currently working on a project that requires the parsing of excel files.
> Basically the user uploads an excel file, and then a script needs to save a
> row in a Postgres database for each row in the excel file. The issue we are
> having is that when we task PHPExcel with parsing an excel file with, say
> 27k rows, it explodes with a memory error. I've read up on the PHPExcel
> forums and we've tried cell caching as well as ReadDataOnly, they do not
> seem to be sufficient.
>
> Does anyone here know of a way to do this? Surely there is a way to parse a
> large excel file with PHP. This is also NOT an on-demand service. That is,
> when someone uploads a file they get a task_id which allows them to check
> the status of their excel file. So the solution does not need to be a fast
> one!
>
>
> Thanks,
> Chris.
>
1. Remove any variable that contains big object if its not necessary.
2. Use unset when applicable
3. Read chunk by chunk.
4. Profile it to find the exact place where you are wasting memory.
Optimizing that little portion of code can improve memory performance.
--
Shiplu Mokadd.im
My talks, http://talk.cmyweb.net
Follow me, http://twitter.com/shiplu
SUST Programmers, http://groups.google.com/group/p2psust
Innovation distinguishes bet ... ... (ask Steve Jobs the rest)
--- End Message ---
--- Begin Message ---
Thanks Jessen/Marc, though the user provided format can be in xls, xlsx, or
csv. So i need a solution to support all formats.
Thanks for the ideas shiplu I'll get with the team and see if there's
anything there we aren't trying.
Chris.
On Mon, Oct 4, 2010 at 3:01 PM, shiplu <[email protected]> wrote:
> On Tue, Oct 5, 2010 at 12:39 AM, chris h <[email protected]> wrote:
> > I'm currently working on a project that requires the parsing of excel
> files.
> > Basically the user uploads an excel file, and then a script needs to
> save a
> > row in a Postgres database for each row in the excel file. The issue we
> are
> > having is that when we task PHPExcel with parsing an excel file with, say
> > 27k rows, it explodes with a memory error. I've read up on the PHPExcel
> > forums and we've tried cell caching as well as ReadDataOnly, they do not
> > seem to be sufficient.
> >
> > Does anyone here know of a way to do this? Surely there is a way to parse
> a
> > large excel file with PHP. This is also NOT an on-demand service. That
> is,
> > when someone uploads a file they get a task_id which allows them to check
> > the status of their excel file. So the solution does not need to be a
> fast
> > one!
> >
> >
> > Thanks,
> > Chris.
> >
>
> 1. Remove any variable that contains big object if its not necessary.
> 2. Use unset when applicable
> 3. Read chunk by chunk.
> 4. Profile it to find the exact place where you are wasting memory.
> Optimizing that little portion of code can improve memory performance.
>
> --
> Shiplu Mokadd.im
> My talks, http://talk.cmyweb.net
> Follow me, http://twitter.com/shiplu
> SUST Programmers, http://groups.google.com/group/p2psust
> Innovation distinguishes bet ... ... (ask Steve Jobs the rest)
>
--- End Message ---
--- Begin Message ---
I am running PHP 5.3.3, with Apache 2.0 Handler and MySql Server 5.1. My OS
is Vista Home Premium 32 bit with SP2.
MySql works fine from the command prompt, Apache is running and PHP works.
But I cannot access the mysqli classes. This simple program:
<?php
$mysqli = new mysqli("localhost", "root", "######", "testDB"); #I've
deliberately obliterated the password
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
} else {
printf("Host information: %s\n", mysqli_get_host_info($mysqli));
}
?>
produces this error message:
Warning: mysqli::mysqli() [mysqli.mysqli]: [2002] A connection attempt failed
because the connected party did not (trying to connect via
tcp://localhost:3306) in C:\Apache\htdocs\mysqlconnect.php on line 3
Warning: mysqli::mysqli() [mysqli.mysqli]: (HY000/2002): A connection attempt
failed because the connected party did not properly respond after a period of
time, or established connection failed because connected host has failed to
respond. in C:\Apache\htdocs\mysqlconnect.php on line 3
Fatal error: Maximum execution time of 30 seconds exceeded in
C:\Apache\htdocs\mysqlconnect.php on line 3
I guess PHP cannot find the mysqli classes. I've checked the phpinfo() output
and discovered :
Configuration File (php.ini) Path C:\Windows
Loaded Configuration File C:\PHP\php.ini
I don't know if this ok. I've tried changing the location of the loaded file
to C:\Windows\php.ini, but to no avail, and I don't know how to change the
location of the config file.
I am obviously doing something wrong, but I don't know what. Can anyone help?
Ironically, everything worked perfectly before I upgraded to PHP 5.3.3!
--- End Message ---