Re: [PHP] What does mean?
On Monday 30 April 2007, Greg Donald wrote: Sounds like you got MVC-itis. PHP can't really help with that since it's a templating language. Try Rubyonrails, it's the best cure for the MVC itch. Except that it's a PAC framework, not MVC, like the vast majority of web apps frameworks out there in any language. The web just doesn't lend itself to MVC. Sun just likes to get their terminology wrong and confuse everyone for the next decade. http://www.garfieldtech.com/blog/mvc-vs-pac -- Larry Garfield AIM: LOLG42 [EMAIL PROTECTED] ICQ: 6817012 If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it. -- Thomas Jefferson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sloppy use of constants as strings. WAS: What does mean?
On 01/05/07, Daevid Vincent [EMAIL PROTECTED] wrote: echo EOF BROWSER: $_SERVER[HTTP_USER_AGENT] EOF; Isn't that form (sans quote marks) deprecated and frowned upon? ?php error_reporting( E_ALL ); echo EOF BROWSER: $_SERVER[HTTP_USER_AGENT] EOF; Why would cleaner, perfectly error free code be frowned upon? http://us2.php.net/manual/en/language.types.array.php A key may be either an integer or a string. If a key is the standard representation of an integer, it will be interpreted as such (i.e. 8 will be interpreted as 8, while 08 will be interpreted as 08). I was always under the impression that using: $_SERVER[HTTP_USER_AGENT] or $foo[myindex] Was bad compared to the proper way of: $_SERVER['HTTP_USER_AGENT'] or $foo['myindex'] True, but notice he's using it inside a heredoc string and the rules are slightly different for string parsing. http://www.php.net/manual/en/language.types.string.php#language.types.string.parsing Whereas outside a string, $foo[myindex] will give you a notice and $foo['myindex'] is OK; Inside a string, $foo[myindex] will give you no notice and $foo['myindex'] will give you a parse error. The manual suggests that $foo[myindex] is treated the same inside a string as outside - if 'myindex' is defined as a constant then that is what's used as the index. This doesn't seem to be born out by reality. ?php error_reporting(E_ALL); $test = array( 'FOO' = 'Bareword', 'BAR' = 'Constant' ); define( 'FOO', 'BAR'); print \$test[FOO]: FOO is interpreted as a $test[FOO]\n; print {\$test[FOO]}: FOO is interpreted as a {$test[FOO]}\n; print {\$test['FOO']}: FOO is interpreted as a {$test['FOO']}\n; ? $ php5 test.php $test[FOO]: FOO is interpreted as a Bareword {$test[FOO]}: FOO is interpreted as a Constant {$test['FOO']}: FOO is interpreted as a Bareword -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] resize image and store it to DB
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
Re: [PHP] resize image and store it to DB
On 5/1/07, Alain Roger [EMAIL PROTECTED] 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] resize image and store it to DB
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. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: What does mean?
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] magic.mime
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 brMime (PNG) : .mime_content_type('image.png'); echo brMime (JPG) : .mime_content_type('kader.jpg'); echo brMime (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
Re: [PHP] Re: What does mean?
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. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] newbie needs help
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* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 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) { ? trtd align=center bgcolor=#ffa href=http://pancan.com/Patient/pancreatic.html; target=_blankimg 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) { ? trtd align=center bgcolor=#ffa href=../images/passportad/mothersdayBanner.jpg target=_blankimg 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: What does mean?
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: What does mean?
END some code END Bash redirection... :) Syntax error ;) Key stuck on keyboardd :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What does mean?
On 4/30/07, Micky Hulse [EMAIL PROTECTED] 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/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: What does mean?
On Tue, 2007-05-01 at 15:01 +0100, Edward Kay wrote: END some code END Bash redirection... :) Syntax error ;) Key stuck on keyboardd :) *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. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] resize image and store it to DB
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: What does mean?
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] resize image and store it to DB
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. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] exec() and redirect output of program
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 21 '); ? On 5/1/07, Brad Fuller [EMAIL PROTECTED] 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
[PHP] mime_magic support empty ?
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
Re: [PHP] Re: What does mean?
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. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] exec() and redirect output of program
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 21 '); ? On 5/1/07, Brad Fuller [EMAIL PROTECTED] 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What does mean?
Greg Donald wrote: On 4/30/07, Richard Davey [EMAIL PROTECTED] 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] exec() and redirect output of program
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 21 '); ? On 5/1/07, Brad Fuller [EMAIL PROTECTED] 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] exec() and redirect output of program
On 5/1/07, Brad Fuller [EMAIL PROTECTED] 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 21 '); ? On 5/1/07, Brad Fuller [EMAIL PROTECTED] 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: What does mean?
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: What does mean?
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. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: What does mean?
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] exec() and redirect output of program [SOLVED]
Tijnema ! wrote: On 5/1/07, Brad Fuller [EMAIL PROTECTED] 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 21 '); ? On 5/1/07, Brad Fuller [EMAIL PROTECTED] 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
Re: [PHP] exec() and redirect output of program [SOLVED]
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 [EMAIL PROTECTED] wrote: Tijnema ! wrote: On 5/1/07, Brad Fuller [EMAIL PROTECTED] 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 21 '); ? On 5/1/07, Brad Fuller [EMAIL PROTECTED] 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
[PHP] PHP Command line script
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Command line script
First and foremost, it's a VERY BAD idea to use root for MySQL. If your code isn't perfect (and even sometimes if it is), arbitrary commands and SQL injection attacks could lead to migraines that no Tylenol will ever be able to alleviate. Secondly, what error is the CLI kicking out when you run it from the command line? On 5/1/07, Nathaniel Hall [EMAIL PROTECTED] wrote: 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 -- 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
[PHP] Deviation? Distribution? OT?
My boss and the web designer have decided to do something that requires statistical formulae well beyond my statistically-challenged capabilities, so I'm turning to y'all... Basically, the current query looks something like this: select * from (select whatever, count(*) as popular from the_table group by whatever order by popular desc limit 100 ) as pop order by rand() So basically it's the Top 100 popular, ordered at random They then want to have the MOST popular stuff with a CSS class=t5 and the least popular with class=t1 The t5 are BIG AND BOLD and the t1 are tiny and plain basically, with t2, t3, and t4 sort of in between in bigness and boldness. The CSS guy has that bit worked out, in terms of style. I just have to label the dang things t1 to t5, no more, no less. Now I have NO IDEA what the range is going to be for the popuplar score as time goes on and the site gets super-popular... So I guess I want some kind of standard deviation thingie among those Top 100? I know for sure I don't want just 20 of each t1 through t5. There are way more t1 than there are t5. So maybe it's more logarithmic than standard deviation? Or is there some kind of weighted deviation? Or maybe it's some other statistical thingie like standard deviation only not? All I now for sure is, my current hack of taking log($popular, 3) in PHP is only going to sort of work with our sample data and make them THINK that it's working, when it's actually quite borked as soon as the number of data points increases. (I.e., next week or so) Little help here? I suspect it's going to turn out to be some magical MySQL statistics function, but not knowing what standard deviation actually *means* any more, I'm at a loss to guess which one... I guess I *could* take the results in order without the wrapping rand() query, do min/max and log games in PHP on the highest/lowest, and then do a shuffle... But there's got to be a better way. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Deviation? Distribution? OT?
I don't think I'm quite following why you wouldn't just want to break it up into groups of 20 On 5/1/07, Richard Lynch [EMAIL PROTECTED] wrote: My boss and the web designer have decided to do something that requires statistical formulae well beyond my statistically-challenged capabilities, so I'm turning to y'all... Basically, the current query looks something like this: select * from (select whatever, count(*) as popular from the_table group by whatever order by popular desc limit 100 ) as pop order by rand() So basically it's the Top 100 popular, ordered at random They then want to have the MOST popular stuff with a CSS class=t5 and the least popular with class=t1 The t5 are BIG AND BOLD and the t1 are tiny and plain basically, with t2, t3, and t4 sort of in between in bigness and boldness. The CSS guy has that bit worked out, in terms of style. I just have to label the dang things t1 to t5, no more, no less. Now I have NO IDEA what the range is going to be for the popuplar score as time goes on and the site gets super-popular... So I guess I want some kind of standard deviation thingie among those Top 100? I know for sure I don't want just 20 of each t1 through t5. There are way more t1 than there are t5. So maybe it's more logarithmic than standard deviation? Or is there some kind of weighted deviation? Or maybe it's some other statistical thingie like standard deviation only not? All I now for sure is, my current hack of taking log($popular, 3) in PHP is only going to sort of work with our sample data and make them THINK that it's working, when it's actually quite borked as soon as the number of data points increases. (I.e., next week or so) Little help here? I suspect it's going to turn out to be some magical MySQL statistics function, but not knowing what standard deviation actually *means* any more, I'm at a loss to guess which one... I guess I *could* take the results in order without the wrapping rand() query, do min/max and log games in PHP on the highest/lowest, and then do a shuffle... But there's got to be a better way. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- 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
Re: [PHP] PHP Command line script
Daniel Brown wrote: First and foremost, it's a VERY BAD idea to use root for MySQL. If your code isn't perfect (and even sometimes if it is), arbitrary commands and SQL injection attacks could lead to migraines that no Tylenol will ever be able to alleviate. I changed the user I was connecting as in order to post. I don't use root in the real code. Secondly, what error is the CLI kicking out when you run it from the command line? It doesn't give an error. The only thing it does is continue on through the IF statement, which goes nowhere. I have added an ELSE to the script and run it. It ends up running the code in the 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(); } -- Nathaniel Hall, GSEC GCFW GCIA GCIH GCFA Spider Security -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Command line script
On 5/1/07, Nathaniel Hall [EMAIL PROTECTED] wrote: 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(); ? Add full error reporting, then make sure you can see the errors, then test to see if you have the mysqli extension: error_reporting( E_ALL ); ini_set( 'display_errors', 1 ); ini_set( 'log_errors', 1 ); if( !in_array( 'mysqli', get_loaded_extensions() ) ) { die( 'no mysqli found' ); } Also, why do you need to escape the dashes in the date() calls? php -r 'echo date(Y-m-d);' 2007-05-01 -- Greg Donald http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php