|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
php-general-digest-help
lists.php.net
Date: Tue May 01 2007 - 15:30:23 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 1 May 2007 20:30:23 -0000 Issue 4767
Topics (messages 254180 through 254208):
resize image and store it to DB
254180 by: Alain Roger
254181 by: Tijnema !
254182 by: Robert Cummings
254191 by: tedd
254193 by: Robert Cummings
Re: What does "<<<" mean?
254183 by: Man-wai Chang
254185 by: Robert Cummings
254187 by: Man-wai Chang
254188 by: Edward Kay
254189 by: Greg Donald
254190 by: Robert Cummings
254192 by: Mattias Thorslund
254198 by: Robert Cummings
254200 by: Richard Davey
254203 by: Mattias Thorslund
254204 by: Robert Cummings
254205 by: Tijnema !
magic.mime
254184 by: Alain Roger
Re: newbie needs help
254186 by: Ben Clapp
exec() and redirect output of program
254194 by: Brad Fuller
254195 by: Daniel Brown
254199 by: Brad Fuller
254201 by: Brad Fuller
254202 by: Tijnema !
session id nightmare
254196 by: Brad Sumrall
mime_magic support empty ?
254197 by: Alain Roger
Re: exec() and redirect output of program [SOLVED]
254206 by: Brad Fuller
254207 by: Daniel Brown
PHP Command line script
254208 by: Nathaniel Hall
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscribe
lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscribe
lists.php.net
To post to the list, e-mail:
php-general
lists.php.net
----------------------------------------------------------------------
attached mail follows:
Hi,
I allow web application users to insert their own picture into database.
but i defined a max size limit 130 px width by 160px height.
so for that i determine the max ratio in case of picture does not have this
size.
after that i resize it and would like to store it to DB, however i have some
problem once it is resized.
here is my code :
> data = file_get_contents($_FILES['uploadedfile']['tmp_name']);
>
> $img = imagecreatefromstring($data);
> $width = imagesx($img);
> $height = imagesy($img);
>
> $maxwidth = 130; //130px
> $maxheight = 160; //160px
>
> $ratio =0.00;
> if($width >$maxwidth || $height>$maxheight) // image is somehow
> bigger than 160px * 130px
> {
> if($width >$maxwidth)
> {
> $ratio = $maxwidth/$width;
> }
> if($height>$maxheight)
> {
> // always take the smallest ratio
> $ratio = ($maxheight/$height) > $ratio ? $ratio : ($maxheight/$height);
> }
> }
> else // both $width and $height are smaller than max, so we need to zoom
> {
> $i=0.00;
> $i=($maxwidth/$width);
> $i = ($maxheight/$height) > $i ? $i : ($maxheight/$height);
> $ratio = $i;
> }
>
> $newwidth = $width*$ratio;
> $newheight = $height*$ratio;
> $thumb = imagecreatetruecolor($newwidth, $newheight);
>
> imagecopyresized($thumb, $img, 0, 0, 0, 0, $newwidth, $newheight, $width,
> $height);
>
> $escaped = pg_escape_bytea($thumb); // does not work and it's normal
>
$thumb is an image, so ho can i make it useful for pg_escape_bytea function
?
i do not want to create a tmp file on server and after load it.
I would like to do it stored image directly into DB on-fly.
thanks alot,
--
Alain
------------------------------------
Windows XP SP2
PostgreSQL 8.1.4
Apache 2.0.58
PHP 5
attached mail follows:
On 5/1/07, Alain Roger <raf.news
gmail.com> wrote:
> Hi,
>
> I allow web application users to insert their own picture into database.
> but i defined a max size limit 130 px width by 160px height.
>
> so for that i determine the max ratio in case of picture does not have this
> size.
> after that i resize it and would like to store it to DB, however i have some
> problem once it is resized.
>
> here is my code :
>
> > data = file_get_contents($_FILES['uploadedfile']['tmp_name']);
> >
> > $img = imagecreatefromstring($data);
> > $width = imagesx($img);
> > $height = imagesy($img);
> >
> > $maxwidth = 130; //130px
> > $maxheight = 160; //160px
> >
> > $ratio =0.00;
> > if($width >$maxwidth || $height>$maxheight) // image is somehow
> > bigger than 160px * 130px
> > {
> > if($width >$maxwidth)
> > {
> > $ratio = $maxwidth/$width;
> > }
> > if($height>$maxheight)
> > {
> > // always take the smallest ratio
> > $ratio = ($maxheight/$height) > $ratio ? $ratio : ($maxheight/$height);
> > }
> > }
> > else // both $width and $height are smaller than max, so we need to zoom
> > {
> > $i=0.00;
> > $i=($maxwidth/$width);
> > $i = ($maxheight/$height) > $i ? $i : ($maxheight/$height);
> > $ratio = $i;
> > }
> >
> > $newwidth = $width*$ratio;
> > $newheight = $height*$ratio;
> > $thumb = imagecreatetruecolor($newwidth, $newheight);
> >
> > imagecopyresized($thumb, $img, 0, 0, 0, 0, $newwidth, $newheight, $width,
> > $height);
> >
> > $escaped = pg_escape_bytea($thumb); // does not work and it's normal
> >
>
> $thumb is an image, so ho can i make it useful for pg_escape_bytea function
> ?
>
> i do not want to create a tmp file on server and after load it.
> I would like to do it stored image directly into DB on-fly.
>
> thanks alot,
> --
> Alain
I don't know if there's a better way, but you could try output
buffering, so that you start it, output the image with imagejpeg,
imagepng, imagegif, etc. and then get the contents of the buffer.
Tijnema
attached mail follows:
On Tue, 2007-05-01 at 12:59 +0200, Tijnema ! wrote:
>
> I don't know if there's a better way, but you could try output
> buffering, so that you start it, output the image with imagejpeg,
> imagepng, imagegif, etc. and then get the contents of the buffer.
That's what I'd suggest also... since it's what I do :)
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
attached mail follows:
At 12:54 PM +0200 5/1/07, Alain Roger wrote:
>
>i do not want to create a tmp file on server and after load it.
>I would like to do it stored image directly into DB on-fly.
Why?
My understanding is that when you upload a file, it has to go
somewhere. It might as well go into a tmp folder/file that php
handles (creates/deletes), right? Or is this something that can be
handled totally within memory? And if so, what's the difference,
speed, security, what?
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
attached mail follows:
On Tue, 2007-05-01 at 11:08 -0400, tedd wrote:
> At 12:54 PM +0200 5/1/07, Alain Roger wrote:
> >
> >i do not want to create a tmp file on server and after load it.
> >I would like to do it stored image directly into DB on-fly.
>
> Why?
>
> My understanding is that when you upload a file, it has to go
> somewhere. It might as well go into a tmp folder/file that php
> handles (creates/deletes), right? Or is this something that can be
> handled totally within memory? And if so, what's the difference,
> speed, security, what?
If you're going to put it in a database, then there's no sense incurring
the filesystem overhead of a temporary file. It can indeed be done
completely in memory by using output buffering.
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
attached mail follows:
>> <<< END
>> ....some code....
>> END
> It's heredoc syntax.
> http://us2.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc
>
Bash redirection... :)
--
.~. Might, Courage, Vision, SINCERITY. http://www.linux-sxs.org
/ v \ Simplicity is Beauty! May the Force and Farce be with you!
/( _ )\ (Ubuntu 6.10) Linux 2.6.21.1
^ ^ 20:40:01 up 3 days 5:33 0 users load average: 1.00 1.02 1.00
news://news.3home.net news://news.hkpcug.org news://news.newsgroup.com.hk
attached mail follows:
On Tue, 2007-05-01 at 20:40 +0800, Man-wai Chang wrote:
> >> <<< END
> >> ....some code....
> >> END
> > It's heredoc syntax.
> > http://us2.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc
> >
>
> Bash redirection... :)
Syntax error ;)
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
attached mail follows:
>>>> <<< END
>>>> ....some code....
>>>> END
>> Bash redirection... :)
> Syntax error ;)
Bash uses only 2. PHP uses 3. And I am using this:
$sql="
select ...
from ....
left join ...
on ....
where .....
";
--
.~. Might, Courage, Vision, SINCERITY. http://www.linux-sxs.org
/ v \ Simplicity is Beauty! May the Force and Farce be with you!
/( _ )\ (Ubuntu 6.10) Linux 2.6.21.1
^ ^ 21:53:01 up 3 days 6:46 0 users load average: 1.00 1.01 1.00
news://news.3home.net news://news.hkpcug.org news://news.newsgroup.com.hk
attached mail follows:
>>>> <<< END
>>>> ....some code....
>>>> END
>> Bash redirection... :)
> Syntax error ;)
Key stuck on keyboardddddddddddddddddddddd :)
attached mail follows:
On 4/30/07, Micky Hulse <micky
ambiguism.com> wrote:
> Greg Donald wrote:
> > Try Rubyonrails, it's the best cure for the MVC itch.
>
> Django framework is pretty nice too. :)
Django is very under-developed compared to Rails. There's not a
Javascript library in sight and the developers have a "do it yourself"
attitude towards anything in the web 2.0 realm. The database
abstraction layer doesn't work very well across "apps" and you repeat
yourself throughout your code in the model/form relationship and data
validations.
The Django project has alot going for it but in having an ear for what
modern developers need in a MVC (or MTV in the case of Django)
framework, they are lacking.
--
Greg Donald
http://destiney.com/
attached mail follows:
On Tue, 2007-05-01 at 15:01 +0100, Edward Kay wrote:
> >>>> <<< END
> >>>> ....some code....
> >>>> END
> >> Bash redirection... :)
>
> > Syntax error ;)
>
> Key stuck on keyboardddddddddddddddddddddd :)
*lol*
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
attached mail follows:
Man-wai Chang wrote:
>
> Bash uses only 2. PHP uses 3. And I am using this:
>
> $sql="
> select ...
> from ....
> left join ...
> on ....
> where .....
> ";
Exactly. I never saw the point in complicating my life with heredocs
when both single- and double-quoted strings can contain multiple lines
anyway.
One thing that does bother me a little with multi-line strings of either
variety is that if I want to avoid inserting extra spaces in the string
at the beginning of each line after the first, I have to left-align the
whole thing and cannot indent it with the rest of my code:
if($something){
if($something_else){
$myID = intval($_GET['rowID']);
$sql_pretty =
"SELECT
field1,
field2
FROM
mytable
WHERE
rowID = $myID";
$sql_ugly =
"SELECT
field1,
field2
FROM
mytable
WHERE
rowID = $myID";
}
}
Are there perhaps editors that would DISPLAY multi-line quoted strings
"indented" to the correct level without inserting extra spaces? Some
editors wrap lines to the correct level, which is also much more
readable, so what I'm thinking of is a bit similar to that.
Mattias
attached mail follows:
On Tue, 2007-05-01 at 08:36 -0700, Mattias Thorslund wrote:
> Man-wai Chang wrote:
> >
> > Bash uses only 2. PHP uses 3. And I am using this:
> >
> > $sql="
> > select ...
> > from ....
> > left join ...
> > on ....
> > where .....
> > ";
>
>
> Exactly. I never saw the point in complicating my life with heredocs
> when both single- and double-quoted strings can contain multiple lines
> anyway.
>
> One thing that does bother me a little with multi-line strings of either
> variety is that if I want to avoid inserting extra spaces in the string
> at the beginning of each line after the first, I have to left-align the
> whole thing and cannot indent it with the rest of my code:
>
> if($something){
> if($something_else){
> $myID = intval($_GET['rowID']);
> $sql_pretty =
> "SELECT
> field1,
> field2
> FROM
> mytable
> WHERE
> rowID = $myID";
> $sql_ugly =
> "SELECT
> field1,
> field2
> FROM
> mytable
> WHERE
> rowID = $myID";
> }
> }
>
> Are there perhaps editors that would DISPLAY multi-line quoted strings
> "indented" to the correct level without inserting extra spaces? Some
> editors wrap lines to the correct level, which is also much more
> readable, so what I'm thinking of is a bit similar to that.
Then you'd have an editor that presents something other than what is
actually there. Go see Microsoft, I'm sure they create rubbish like
that.
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
attached mail follows:
Greg Donald wrote:
> On 4/30/07, Richard Davey <rich
corephp.co.uk> wrote:
>> I'm not dissing heredoc syntax, it has its uses (now and again) but it's
>> far from "clean", especially when embedded deep in classes
>
> Classes? PHP is the absolute worst language to do OO programming in.
> If you like OO, move on to ruby or python, you'll be much happier. Or
> you can wait around until PHP fully (d)evolves into Java.
Do you write digg headlines as a past-time? They're quite keen on
sensationlist clap like that.
> All parts of a heredoc statement do not have to be right justified,
> only the closing line.
That'd be the fuck ugly part.
>> The frowning surely would be at the mixing of logic and presentation,
>
> Sounds like you got MVC-itis. PHP can't really help with that since
> it's a templating language.
Actually I've got clean code, common-sense itis. Separating code from
presentation has been taught in comp sci for decades, and has sod all to
do with Web 2.0 / MVC / Ruby / whatever.
> I love me some heredoc syntax:
>
> #!/usr/bin/env perl -w
>
> $x = <<END;
> hello world!
> END
>
> print $x;
It's just as fuck ugly in properly nested, properly strucutred Perl. The
problem isn't the language, it's the way heredoc works.
Cheers,
Rich
--
Zend Certified Engineer
http://www.corephp.co.uk
"Never trust a computer you can't throw out of a window"
attached mail follows:
Robert Cummings wrote:
> On Tue, 2007-05-01 at 08:36 -0700, Mattias Thorslund wrote:
>
>> Man-wai Chang wrote:
>>
>>> Bash uses only 2. PHP uses 3. And I am using this:
>>>
>>> $sql="
>>> select ...
>>> from ....
>>> left join ...
>>> on ....
>>> where .....
>>> ";
>>>
>> Exactly. I never saw the point in complicating my life with heredocs
>> when both single- and double-quoted strings can contain multiple lines
>> anyway.
>>
>> One thing that does bother me a little with multi-line strings of either
>> variety is that if I want to avoid inserting extra spaces in the string
>> at the beginning of each line after the first, I have to left-align the
>> whole thing and cannot indent it with the rest of my code:
>>
>> if($something){
>> if($something_else){
>> $myID = intval($_GET['rowID']);
>> $sql_pretty =
>> "SELECT
>> field1,
>> field2
>> FROM
>> mytable
>> WHERE
>> rowID = $myID";
>> $sql_ugly =
>> "SELECT
>> field1,
>> field2
>> FROM
>> mytable
>> WHERE
>> rowID = $myID";
>> }
>> }
>>
>> Are there perhaps editors that would DISPLAY multi-line quoted strings
>> "indented" to the correct level without inserting extra spaces? Some
>> editors wrap lines to the correct level, which is also much more
>> readable, so what I'm thinking of is a bit similar to that.
>>
>
> Then you'd have an editor that presents something other than what is
> actually there. Go see Microsoft, I'm sure they create rubbish like
> that.
>
> Cheers,
> Rob.
>
"something other than what is actually there"
Not at all, Rob! Have you seen how many editors dynamically wrap lines
(Quanta on KDE for instance)? Instead of placing the wrapped line right
smach along the left edge, it indents the following lines under the
first line. It is visually clear that there is no extra white space
because the extra indent has a different background color.
Like this (I used +'s to indicate a different background color, telling
you this isn't whitespace in your code):
if($something){
$variable = "This text message goes on and on and ever on and and
+++would run right off the edge of my screen but thankfully my editor
+++is smart enough to wrap the lines in a way that also does not
+++ruin the indentation.\n";
}
Now, I would wish for my editor to also indent multi-line strings in the
same fashion. Essentially, the lines of $sql_ugly in my example above
should be displayed in alignment with the indentation:
if($something){
if($something_else){
$myID = intval($_GET['rowID']);
$sql =
++++++"SELECT
++++++ field1,
++++++ field2
++++++FROM
++++++ mytable
++++++WHERE
++++++ rowID = $myID";
}
}
I doubt Microsoft develops an editor that I could use on my Linux system
for this...
Cheers,
Mattias
attached mail follows:
On Tue, 2007-05-01 at 12:28 -0700, Mattias Thorslund wrote:
> Robert Cummings wrote:
>
> Now, I would wish for my editor to also indent multi-line strings in the
> same fashion. Essentially, the lines of $sql_ugly in my example above
> should be displayed in alignment with the indentation:
>
> if($something){
> if($something_else){
> $myID = intval($_GET['rowID']);
> $sql =
> ++++++"SELECT
> ++++++ field1,
> ++++++ field2
> ++++++FROM
> ++++++ mytable
> ++++++WHERE
> ++++++ rowID = $myID";
> }
> }
Aaaah, I see... still looks terrible >:)
> I doubt Microsoft develops an editor that I could use on my Linux system
> for this...
Probably not.
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
attached mail follows:
> I doubt Microsoft develops an editor that I could use on my Linux system
> for this...
>
> Cheers,
>
> Mattias
You could use a silly editor from Microsoft, and then run it using Wine.
Tijnema
attached mail follows:
Hi,
I know that magic.mime is depreciated but i would like to test a simple
thing. However, i have some issues with it.... it does not work :-(
basically, my php.ini file points as following :
mime_magic.magicfile = "x:\PHP511\extras\magic.mime"
>
I also enabled the dll via :
extension=php_mime_magic.dll
>
when i check the settings via phpinfo() i have everything ok (i mean the
mime_magic module is loaded).
However, if i write a simple PHP test page as following :
error_reporting(E_ALL );
> echo "<br>Mime (PNG) : ".mime_content_type('image.png');
> echo "<br>Mime (JPG) : ".mime_content_type('kader.jpg');
> echo "<br>Mime (PHP) : ".mime_content_type('test_mime.php');
> echo "<br>";
>
i get nothing from function mime_content_type().
Where could be the problem ?
thanks a lot,
--
Alain
------------------------------------
Windows XP SP2
PostgreSQL 8.1.4
Apache 2.0.58
PHP 5
attached mail follows:
I do apologize for the non-list reply, I will make sure and keep that in
there on the next emails. I checked this morning and there was only one
image, so the second mymonth code did not execute, but I replaced the
code with what Richard gave me and it works also. And about the {}
brackets, I am having to teach myself PHP code while trying to update
and maintain a preprogrammed website so most of the code I see and I am
using is chopped up code from the old programmer (which he did not keep
a very tidy code). I figure out what a line of code does and then try to
manipulate the existing code into what I need, so my syntax comes from
the old programmer and what he had.
On another note I want to say THANK YOU again, your response to my
question blew my mind on how quickly you guys responded, I have posted
questions and sent emails on some other programming sites and either
takes a few days to hear back or I never get the answer I need. I will
only be asking questions about PHP here from now on. You have a loyal
user forever.
Ben
Daniel Brown wrote:
>
> Good catch on the non-list reply, Richard. I didn't even notice that.
>
>
> On 4/30/07, *Richard Davey* < rich
corephp.co.uk
> <mailto:rich
corephp.co.uk>> wrote:
>
> Ben Clapp wrote:
>
> > Thank you again for the help, it does work now but with an
> issue, here
> > is the code that i have for it right now:
>
> You should always reply to the php mailing list, so other people can
> benefit from the answers we give.
>
> > With this it works, but i am sure that when mymonth == 5 (may 1st,
> > tomorrow) I will have two of the same pictures.
>
> You are right, you will. Because you're running the mothers day check
> twice, once with the 'new' code I gave you, and once with your old
> code.
>
> > If I take out this bit of code from the above code:
> > then NOTHING shows up. Am I not getting something right or is there
> > something elese that is getting in the way or is something not being
> > completed?
>
> You've got missing { } around your if blocks. You also could make the
> code a lot more tidy / easy to read. Try the following (it replaces
> entirely the code you emailed me, swap all of it for this)
>
> <?php
> $mymonth = date('m');
>
> // novenmber is pancreatic cancer month
> if ($mymonth == 11)
> {
> ?>
> <tr><td align="center" bgcolor="#ffffff"><a
> href="http://pancan.com/Patient/pancreatic.html" target="_blank"><img
> src="../images/ads/pancanNov_banner.jpg" width="777" height="182"
> border="0"></a></td>
> </tr>
> <?php
> }
>
> $start_date = strtotime('13 April '.date("Y"));
> $end_date = strtotime('13 May '.date("Y"));
> $current = time();
>
> if ($current >= $start_date && $current <= $end_date)
> {
> ?>
> <tr><td align="center" bgcolor="#ffffff"><a
> href="../images/passportad/mothersdayBanner.jpg" target="_blank"><img
> src="../images/passportad/mothersdayBanner.jpg" width="771"
> height="112"
> border="0" /></a></td>
> </tr>
> <?php
> }
> ?>
>
> Cheers,
>
> Rich
> --
> Zend Certified Engineer
> http://www.corephp.co.uk
>
> "Never trust a computer you can't throw out of a window"
>
>
>
>
> --
> Daniel P. Brown
> [office] (570-) 587-7080 Ext. 272
> [mobile] (570-) 766-8107
attached mail follows:
I found this on PHP.net:
http://us.php.net/manual/en/function.exec.php
Note: If you start a program using this function and want to leave it
running in the background, you have to make sure that the output of that
program is redirected to a file or some other output stream or else PHP will
hang until the execution of the program
ends.
This is what I want... I want to execute another PHP script from the CLI,
pass it a parameter and let it go to town after the HTTP request closes.
Can someone please illustrate how I can make this work?
Thx,
Brad
attached mail follows:
This way just lets it do it's own thing, with no output, and PHP won't
hang. It'll continue from the CLI after the HTTP session is over.
<?
exec('php test.php > /dev/null 2>&1 &');
?>
On 5/1/07, Brad Fuller <bfuller
cpacampaigns.com> wrote:
>
>
> I found this on PHP.net:
>
> http://us.php.net/manual/en/function.exec.php
>
> Note: If you start a program using this function and want to leave it
> running in the background, you have to make sure that the output of that
> program is redirected to a file or some other output stream or else PHP
> will
> hang until the execution of the program
> ends.
>
>
> This is what I want... I want to execute another PHP script from the CLI,
> pass it a parameter and let it go to town after the HTTP request closes.
>
> Can someone please illustrate how I can make this work?
>
> Thx,
>
> Brad
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107
attached mail follows:
Daniel Brown wrote:
> This way just lets it do it's own thing, with no output,
> and PHP won't hang. It'll continue from the CLI after the HTTP
> session is over.
>
> <?
> exec('php test.php > /dev/null 2>&1 &'); ?>
>
>
> On 5/1/07, Brad Fuller <bfuller
cpacampaigns.com> wrote:
>>
>>
>> I found this on PHP.net:
>>
>> http://us.php.net/manual/en/function.exec.php
>>
>> Note: If you start a program using this function and want to leave it
>> running in the background, you have to make sure that the output of
>> that program is redirected to a file or some other output stream or
>> else PHP will hang until the execution of the program ends.
>>
>>
>> This is what I want... I want to execute another PHP script from the
>> CLI, pass it a parameter and let it go to town after the HTTP
>> request closes.
>>
>> Can someone please illustrate how I can make this work?
>>
>> Thx,
>>
>> Brad
>>
>> --
>> PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
>> http://www.php.net/unsub.php
It seems the script is calling itself even though I'm specifying a different
script to run...
test2.php
<?php echo "Hello, World!"; ?>
test1.php
<?php
if( !isset($_POST['account_id']) || $_POST['account_id'] == "" ) {
echo "account_id is required.";
exit;
}
// more stuff here...
exec("/usr/bin/php -q /path/to/test2.php", $output); // should run
test2.php
echo "<pre>";
print_r($output);
echo "</pre>";
?>
http://www.example.com/test1.php
Expected Result:
Array
(
[0] => Hello, World!
)
Actual Result:
Array
(
[0] => X-Powered-By: PHP/5.2.1
[1] => Content-type: text/html
[2] =>
[3] => account_id is required.
)
Can anyone explain this and possibly help me find a solution?
Thx,
Brad
attached mail follows:
Brad Fuller wrote:
> Daniel Brown wrote:
>> This way just lets it do it's own thing, with no output, and PHP
>> won't hang. It'll continue from the CLI after the HTTP session is
>> over.
>>
>> <?
>> exec('php test.php > /dev/null 2>&1 &'); ?>
>>
>>
>> On 5/1/07, Brad Fuller <bfuller
cpacampaigns.com> wrote:
>>>
>>>
>>> I found this on PHP.net:
>>>
>>> http://us.php.net/manual/en/function.exec.php
>>>
>>> Note: If you start a program using this function and want to leave
>>> it running in the background, you have to make sure that the output
>>> of that program is redirected to a file or some other output stream
>>> or else PHP will hang until the execution of the program ends.
>>>
>>>
>>> This is what I want... I want to execute another PHP script from the
>>> CLI, pass it a parameter and let it go to town after the HTTP
>>> request closes.
>>>
>>> Can someone please illustrate how I can make this work?
>>>
>>> Thx,
>>>
>>> Brad
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/) To unsubscribe,
>>> visit: http://www.php.net/unsub.php
>
>
> It seems the script is calling itself even though I'm
> specifying a different script to run...
>
> test2.php
>
> <?php echo "Hello, World!"; ?>
>
>
> test1.php
>
> <?php
> if( !isset($_POST['account_id']) ||
> $_POST['account_id'] == "" ) {
> echo "account_id is required.";
> exit;
> }
>
> // more stuff here...
>
> exec("/usr/bin/php -q /path/to/test2.php", $output); // should run
> test2.php
>
> echo "<pre>";
> print_r($output);
> echo "</pre>";
>
>>
>
>
> http://www.example.com/test1.php
>
> Expected Result:
>
> Array
> (
> [0] => Hello, World!
> )
>
>
> Actual Result:
>
> Array
> (
> [0] => X-Powered-By: PHP/5.2.1
> [1] => Content-type: text/html
> [2] =>
> [3] => account_id is required.
> )
>
> Can anyone explain this and possibly help me find a solution?
>
> Thx,
>
> Brad
P.S. I am posting a form to the test1.php page with a valid account_id etc.;
after re-reading the message I thought someone might think it's printing
that result because nothing is posted.
Update:
I also found a file called "error_log" in the folder where test2.php
resides, full of several of these lines:
[01-May-2007 14:12:52] PHP Warning: Zend Optimizer does not support this
version of PHP - please upgrade to the latest version of Zend Optimizer in
Unknown on line 0
Could that have something to do with why the script is calling on itself
instead of running the specified php script?
I recently had the hosting company rebuild PHP, first they did
--enable-suexec (to run PHP as CGI) and then later rebuilt again to
--enable-pcntl and --enable-sigchild, as I thought I would be needing that
functionality. Did that break the CLI?
Please help, Thx.
Brad
attached mail follows:
On 5/1/07, Brad Fuller <bfuller
cpacampaigns.com> wrote:
> Brad Fuller wrote:
> > Daniel Brown wrote:
> >> This way just lets it do it's own thing, with no output, and PHP
> >> won't hang. It'll continue from the CLI after the HTTP session is
> >> over.
> >>
> >> <?
> >> exec('php test.php > /dev/null 2>&1 &'); ?>
> >>
> >>
> >> On 5/1/07, Brad Fuller <bfuller
cpacampaigns.com> wrote:
> >>>
> >>>
> >>> I found this on PHP.net:
> >>>
> >>> http://us.php.net/manual/en/function.exec.php
> >>>
> >>> Note: If you start a program using this function and want to leave
> >>> it running in the background, you have to make sure that the output
> >>> of that program is redirected to a file or some other output stream
> >>> or else PHP will hang until the execution of the program ends.
> >>>
> >>>
> >>> This is what I want... I want to execute another PHP script from the
> >>> CLI, pass it a parameter and let it go to town after the HTTP
> >>> request closes.
> >>>
> >>> Can someone please illustrate how I can make this work?
> >>>
> >>> Thx,
> >>>
> >>> Brad
> >>>
> >>> --
> >>> PHP General Mailing List (http://www.php.net/) To unsubscribe,
> >>> visit: http://www.php.net/unsub.php
> >
> >
> > It seems the script is calling itself even though I'm
> > specifying a different script to run...
> >
> > test2.php
> >
> > <?php echo "Hello, World!"; ?>
> >
> >
> > test1.php
> >
> > <?php
> > if( !isset($_POST['account_id']) ||
> > $_POST['account_id'] == "" ) {
> > echo "account_id is required.";
> > exit;
> > }
> >
> > // more stuff here...
> >
> > exec("/usr/bin/php -q /path/to/test2.php", $output); // should run
> > test2.php
> >
> > echo "<pre>";
> > print_r($output);
> > echo "</pre>";
> >
> >>
> >
> >
> > http://www.example.com/test1.php
> >
> > Expected Result:
> >
> > Array
> > (
> > [0] => Hello, World!
> > )
> >
> >
> > Actual Result:
> >
> > Array
> > (
> > [0] => X-Powered-By: PHP/5.2.1
> > [1] => Content-type: text/html
> > [2] =>
> > [3] => account_id is required.
> > )
> >
> > Can anyone explain this and possibly help me find a solution?
> >
> > Thx,
> >
> > Brad
>
> P.S. I am posting a form to the test1.php page with a valid account_id etc.;
> after re-reading the message I thought someone might think it's printing
> that result because nothing is posted.
>
> Update:
>
> I also found a file called "error_log" in the folder where test2.php
> resides, full of several of these lines:
>
> [01-May-2007 14:12:52] PHP Warning: Zend Optimizer does not support this
> version of PHP - please upgrade to the latest version of Zend Optimizer in
> Unknown on line 0
>
> Could that have something to do with why the script is calling on itself
> instead of running the specified php script?
>
> I recently had the hosting company rebuild PHP, first they did
> --enable-suexec (to run PHP as CGI) and then later rebuilt again to
> --enable-pcntl and --enable-sigchild, as I thought I would be needing that
> functionality. Did that break the CLI?
>
> Please help, Thx.
>
> Brad
It seems that the php binary isn't the same version as the php library
used in the webserver and so that there's a problem loading Zend. Are
you sure that the PHP binary is also replaced when they reinstalled
PHP?
Tijnema
attached mail follows:
As this one continues!
Looking for a program that will help me monitor sessions/user/page access to
upload to my server to help me debug what is going wrong.
I must have some conflict going on somewhere in the background and maybe
some monitoring program will help me get to the root of the issue.
Brad
attached mail follows:
Hi,
I previously wrote a post about mime_magic issue.
i would like to add some details about result from phpinfo() function.
when i check it i can see that "mime_magic support" is empty. not set to
enabled or disabled... only empty cell.
I also tried the standard magic.mime file delivered with PHP 5.1.2 but
nothing.
i tried On/Off for debug => nothing.
i tried another magic.mine file from GnuWin32 or from another version of PHP
=> nothing.
I'm lost :-(
My web host provider will not accept to use the PCEL dll file. I've seen
that on his server magic_mime works perfectly.
So as i would like to develop it on my computer, i need to have it also
working there.
Any suggestion ?
thanks a lot,
--
Alain
------------------------------------
Windows XP SP2
PostgreSQL 8.1.4
Apache 2.0.58
PHP 5
attached mail follows:
Tijnema ! wrote:
> On 5/1/07, Brad Fuller <bfuller
cpacampaigns.com> wrote:
>> Brad Fuller wrote:
>>> Daniel Brown wrote:
>>>> This way just lets it do it's own thing, with no output, and
>>>> PHP won't hang. It'll continue from the CLI after the HTTP
>>>> session is over.
>>>>
>>>> <?
>>>> exec('php test.php > /dev/null 2>&1 &'); ?>
>>>>
>>>>
>>>> On 5/1/07, Brad Fuller <bfuller
cpacampaigns.com> wrote:
>>>>>
>>>>>
>>>>> I found this on PHP.net:
>>>>>
>>>>> http://us.php.net/manual/en/function.exec.php
>>>>>
>>>>> Note: If you start a program using this function and want to leave
>>>>> it running in the background, you have to make sure that the
>>>>> output of that program is redirected to a file or some other
>>>>> output stream or else PHP will hang until the execution of the
>>>>> program ends.
>>>>>
>>>>>
>>>>> This is what I want... I want to execute another PHP script from
>>>>> the CLI, pass it a parameter and let it go to town after the HTTP
>>>>> request closes.
>>>>>
>>>>> Can someone please illustrate how I can make this work?
>>>>>
>>>>> Thx,
>>>>>
>>>>> Brad
>>>>>
>>>>> --
>>>>> PHP General Mailing List (http://www.php.net/) To unsubscribe,
>>>>> visit: http://www.php.net/unsub.php
>>>
>>>
>>> It seems the script is calling itself even though I'm specifying a
>>> different script to run...
>>>
>>> test2.php
>>>
>>> <?php echo "Hello, World!"; ?>
>>>
>>>
>>> test1.php
>>>
>>> <?php
>>> if( !isset($_POST['account_id']) || $_POST['account_id'] ==
>>> "" ) { echo "account_id is required.";
>>> exit;
>>> }
>>>
>>> // more stuff here...
>>>
>>> exec("/usr/bin/php -q /path/to/test2.php", $output); //
>>> should run test2.php
>>>
>>> echo "<pre>";
>>> print_r($output);
>>> echo "</pre>";
>>>
>>>>
>>>
>>>
>>> http://www.example.com/test1.php
>>>
>>> Expected Result:
>>>
>>> Array
>>> (
>>> [0] => Hello, World!
>>> )
>>>
>>>
>>> Actual Result:
>>>
>>> Array
>>> (
>>> [0] => X-Powered-By: PHP/5.2.1
>>> [1] => Content-type: text/html
>>> [2] =>
>>> [3] => account_id is required.
>>> )
>>>
>>> Can anyone explain this and possibly help me find a solution?
>>>
>>> Thx,
>>>
>>> Brad
>>
>> P.S. I am posting a form to the test1.php page with a valid
>> account_id etc.; after re-reading the message I thought someone
>> might think it's printing that result because nothing is posted.
>>
>> Update:
>>
>> I also found a file called "error_log" in the folder where test2.php
>> resides, full of several of these lines:
>>
>> [01-May-2007 14:12:52] PHP Warning: Zend Optimizer does not support
>> this version of PHP - please upgrade to the latest version of Zend
>> Optimizer in Unknown on line 0
>>
>> Could that have something to do with why the script is calling on
>> itself instead of running the specified php script?
>>
>> I recently had the hosting company rebuild PHP, first they did
>> --enable-suexec (to run PHP as CGI) and then later rebuilt again to
>> --enable-pcntl and --enable-sigchild, as I thought I would be needing
>> that functionality. Did that break the CLI?
>>
>> Please help, Thx.
>>
>> Brad
>
>
> It seems that the php binary isn't the same version as the
> php library used in the webserver and so that there's a
> problem loading Zend. Are you sure that the PHP binary is
> also replaced when they reinstalled PHP?
>
> Tijnema
Well, I finally got it working... I simply call "php" instead of using the
full path "/usr/bin/php". When I type "which php" from the shell I get
"/usr/local/bin/php" so I'm not sure if the CLI binary maybe got moved when
we switched to CGI mode or what, anyway I still get the Zend Optimizer
Warning message when I run the script from the command line but for some
reason it doesn't write to error_log when the script is called from the
exec() function.. Maybe that's simply because the errors are being
redirected to /dev/null... But anyway it works now :) I will call up our
hosting company and see if we can do something about that Zend Optimizer
warning.
Thanks Daniel and Tijnema for the help.
Cheers,
Brad
attached mail follows:
Brad,
The error_log file is written by httpd (Apache). It actually just
sounds like they need to upgrade their Zend Optimizer, which is a cinch to
do.
On 5/1/07, Brad Fuller <bfuller
cpacampaigns.com> wrote:
>
> Tijnema ! wrote:
> > On 5/1/07, Brad Fuller <bfuller
cpacampaigns.com> wrote:
> >> Brad Fuller wrote:
> >>> Daniel Brown wrote:
> >>>> This way just lets it do it's own thing, with no output, and
> >>>> PHP won't hang. It'll continue from the CLI after the HTTP
> >>>> session is over.
> >>>>
> >>>> <?
> >>>> exec('php test.php > /dev/null 2>&1 &'); ?>
> >>>>
> >>>>
> >>>> On 5/1/07, Brad Fuller <bfuller
cpacampaigns.com> wrote:
> >>>>>
> >>>>>
> >>>>> I found this on PHP.net:
> >>>>>
> >>>>> http://us.php.net/manual/en/function.exec.php
> >>>>>
> >>>>> Note: If you start a program using this function and want to leave
> >>>>> it running in the background, you have to make sure that the
> >>>>> output of that program is redirected to a file or some other
> >>>>> output stream or else PHP will hang until the execution of the
> >>>>> program ends.
> >>>>>
> >>>>>
> >>>>> This is what I want... I want to execute another PHP script from
> >>>>> the CLI, pass it a parameter and let it go to town after the HTTP
> >>>>> request closes.
> >>>>>
> >>>>> Can someone please illustrate how I can make this work?
> >>>>>
> >>>>> Thx,
> >>>>>
> >>>>> Brad
> >>>>>
> >>>>> --
> >>>>> PHP General Mailing List (http://www.php.net/) To unsubscribe,
> >>>>> visit: http://www.php.net/unsub.php
> >>>
> >>>
> >>> It seems the script is calling itself even though I'm specifying a
> >>> different script to run...
> >>>
> >>> test2.php
> >>>
> >>> <?php echo "Hello, World!"; ?>
> >>>
> >>>
> >>> test1.php
> >>>
> >>> <?php
> >>> if( !isset($_POST['account_id']) || $_POST['account_id'] ==
> >>> "" ) { echo "account_id is required.";
> >>> exit;
> >>> }
> >>>
> >>> // more stuff here...
> >>>
> >>> exec("/usr/bin/php -q /path/to/test2.php", $output); //
> >>> should run test2.php
> >>>
> >>> echo "<pre>";
> >>> print_r($output);
> >>> echo "</pre>";
> >>>
> >>>>
> >>>
> >>>
> >>> http://www.example.com/test1.php
> >>>
> >>> Expected Result:
> >>>
> >>> Array
> >>> (
> >>> [0] => Hello, World!
> >>> )
> >>>
> >>>
> >>> Actual Result:
> >>>
> >>> Array
> >>> (
> >>> [0] => X-Powered-By: PHP/5.2.1
> >>> [1] => Content-type: text/html
> >>> [2] =>
> >>> [3] => account_id is required.
> >>> )
> >>>
> >>> Can anyone explain this and possibly help me find a solution?
> >>>
> >>> Thx,
> >>>
> >>> Brad
> >>
> >> P.S. I am posting a form to the test1.php page with a valid
> >> account_id etc.; after re-reading the message I thought someone
> >> might think it's printing that result because nothing is posted.
> >>
> >> Update:
> >>
> >> I also found a file called "error_log" in the folder where test2.php
> >> resides, full of several of these lines:
> >>
> >> [01-May-2007 14:12:52] PHP Warning: Zend Optimizer does not support
> >> this version of PHP - please upgrade to the latest version of Zend
> >> Optimizer in Unknown on line 0
> >>
> >> Could that have something to do with why the script is calling on
> >> itself instead of running the specified php script?
> >>
> >> I recently had the hosting company rebuild PHP, first they did
> >> --enable-suexec (to run PHP as CGI) and then later rebuilt again to
> >> --enable-pcntl and --enable-sigchild, as I thought I would be needing
> >> that functionality. Did that break the CLI?
> >>
> >> Please help, Thx.
> >>
> >> Brad
> >
> >
> > It seems that the php binary isn't the same version as the
> > php library used in the webserver and so that there's a
> > problem loading Zend. Are you sure that the PHP binary is
> > also replaced when they reinstalled PHP?
> >
> > Tijnema
>
>
> Well, I finally got it working... I simply call "php" instead of using the
> full path "/usr/bin/php". When I type "which php" from the shell I get
> "/usr/local/bin/php" so I'm not sure if the CLI binary maybe got moved
> when
> we switched to CGI mode or what, anyway I still get the Zend Optimizer
> Warning message when I run the script from the command line but for some
> reason it doesn't write to error_log when the script is called from the
> exec() function.. Maybe that's simply because the errors are being
> redirected to /dev/null... But anyway it works now :) I will call up our
> hosting company and see if we can do something about that Zend Optimizer
> warning.
>
> Thanks Daniel and Tijnema for the help.
>
> Cheers,
>
> Brad
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107
attached mail follows:
I am attempting to run a script that will run from the command line
nightly to update a field in a database. I already created a script
that would access the database and insert most of the information when a
webpage is visited and I had no problems with it. The command line
script appears to fail on the prepare. I have echo'ed the SQL statement
to the screen, copied it, and run it on the MySQL server with no
problems. Any ideas?
<?php
$mysqli = new mysqli('localhost', 'root', 'abc123', 'mydb');
if (mysqli_connect_errno()) {
echo "Unable to connect to database.\n";
exit;
} else {
$login = date('m\-d\-Y');
if ($logout = $mysqli->prepare("UPDATE `mydb`.`authlog`
SET `logout` = ? WHERE `login` LIKE '$login%'")) { // <--- Will not go
any further than here, even when hard coding the information.
$logout->bind_param("s", date('m\-d\-Y\TH\:i\:s'));
$logout->execute();
$logout->close();
}
}
$mysqli->close();
?>
--
Nathaniel Hall, GSEC GCFW GCIA GCIH GCFA
Spider Security
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]