Re: [PHP] Fwd: ezmlm warning
Hi, I'm in Germany and I got it, too. I get those about once in 6 month ... nothing to worry about, is it?? Regards Original-Nachricht Datum: Wed, 20 Jul 2011 07:12:58 -0400 Von: Tim Thorburn immor...@nwconx.net An: php-general@lists.php.net Betreff: Re: [PHP] Fwd: ezmlm warning On 7/20/2011 6:19 AM, Ashley Sheridan wrote: Louis Huppenbauerlouis.huppenba...@gmail.com wrote: got the same problem today mayhabs gmail had a small problem... who knows ;) 2011/7/20 Lester Caineles...@lsces.co.uk Tamara Temple wrote: Um... what's going on here? Why would google mail be bouncing?? Happens quite often ... just means that an email server has hickupped somewhere so an email addressed to you has not got through '76.75.200.58' which I think is the same machine address on the message a deleted this morning for my email address -- Lester Caine - G8HFL - Contact - http://lsces.co.uk/wiki/?page=**contacthttp://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk// Firebird - http://www.firebirdsql.org/**index.phphttp://www.firebirdsql.org/index.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I got it too, so its not just limited to gmail. Maybe a server in between not working correctly. I'm in the UK, are the rest of you who had problems this way too? Thanks, Ash http://www.ashleysheridan.co.uk I got the same email as well. Not using gmail, and I'm located in Canada. Guessing the mail server just had an oops. Now, on to the next crisis. -- NEU: FreePhone - 0ct/min Handyspartarif mit Geld-zurück-Garantie! Jetzt informieren: http://www.gmx.net/de/go/freephone -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SQL Syntax [improved SQL]
Hi, this is the solution I came up with, that is over 10 times faster than my first attemps. Tested @31,871 entries in table 'picture' and 222,712 entries in table 'picture_attrib_rel'. Old Version: SELECT * FROM picture as p INNER JOIN picture_attrib_rel as pr1 ON (p.pid = pr1.pid) INNER JOIN picture_attrib_rel as pr2 ON (p.pid = pr2.pid and pr2.val_int 1500) WHERE pr1.aid = 2 AND pr1.val_int = 1500 AND pr2.aid = 5 AND pr2.val_int 1000 Takes about 1.9 Seconds on average to return. The version with temporary tables: DROP temporary table if exists tmp_size; DROP temporary table if exists tmp_qi; CREATE temporary table tmp_size SELECT pid FROM picture_attrib_rel WHERE aid = 2 AND val_int = 1500; CREATE temporary table tmp_qi SELECT pid FROM picture_attrib_rel WHERE aid = 5 AND val_int 1000; SELECT pid,uid FROM tmp_size JOIN tmp_qi USING(pid) JOIN pictures USING(pid); DROP temporary table if exists tmp_size; DROP temporary table if exists tmp_qi; This takes 0.12 seconds to return, which is quite bearable for now. Thanks again for all your input! Regards, Jan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] SQL Syntax
Thanks. That was my first attempt, too. Only this will throw out rows, that meet only one of the conditions, too. For example, I would get all pictures that are bigger than 100, regardless of type, and all pictures that are of type jpg, no matter the size. Doing it with a view would be an option, but that would immensely decrease flexibility. I guess I have to keep on cooking my brain on this ;-) I think I did it before, a few years ago when MySQL didn't support views yet, but I can't find that stuff ... @Dan: Thanks for forwarding my mail to the MySQL List! Regards, Jan From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] Sent: Wednesday, June 16, 2010 3:09 AM To: Jan Reiter Cc: php-general@lists.php.net Subject: Re: [PHP] SQL Syntax On Wed, 2010-06-16 at 02:58 +0200, Jan Reiter wrote: Hi folks! I'm kind of ashamed to ask a question, as I haven't followed this list very much lately. This isn't exactly a PHP question, but since mysql is the most popular database engine used with php, I figured someone here might have an idea. I have 2 tables. Table A containing 2 fields. A user ID and a picture ID = A(uid,pid) and another table B, containing 3 fields. The picture ID, an attribute ID and a value for that attribute = B(pid,aid,value). Table B contains several rows for a single PID with various AIDs and values. Each AID is unique to a PID. (e.g. AID = 1 always holding the value for the image size and AID = 3 always holding a value for the image type) The goal is now to join table A on table B using pid, and selecting the rows based on MULTIPLE attributes. So the result should only contain rows for images, that relate to an attribute ID = 1 (size) that is bigger than 100 AND!!! an attribute ID = 5 that equals 'jpg'. I know that there is an easy solution to this, doing it in one query and I have the feeling, that I can almost touch it with my fingertips in my mind, but I can't go that final step, if you know what I mean. AND THAT DRIVES ME CRAZY!! I appreciate your thoughts on this. Regards, Jan You'll be looking for something like this (untested): SELECT * FROM a LEFT JOIN b ON (a.pid = b.pid) WHERE (b.aid = 1 AND b.value 100) OR (b.aid = 3 AND b.value = 'jpg') Obviously instead of the * you may have to change to a list of field names to avoid fieldname collision on the two tables. Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] SQL Syntax
Hi folks! I'm kind of ashamed to ask a question, as I haven't followed this list very much lately. This isn't exactly a PHP question, but since mysql is the most popular database engine used with php, I figured someone here might have an idea. I have 2 tables. Table A containing 2 fields. A user ID and a picture ID = A(uid,pid) and another table B, containing 3 fields. The picture ID, an attribute ID and a value for that attribute = B(pid,aid,value). Table B contains several rows for a single PID with various AIDs and values. Each AID is unique to a PID. (e.g. AID = 1 always holding the value for the image size and AID = 3 always holding a value for the image type) The goal is now to join table A on table B using pid, and selecting the rows based on MULTIPLE attributes. So the result should only contain rows for images, that relate to an attribute ID = 1 (size) that is bigger than 100 AND!!! an attribute ID = 5 that equals 'jpg'. I know that there is an easy solution to this, doing it in one query and I have the feeling, that I can almost touch it with my fingertips in my mind, but I can't go that final step, if you know what I mean. AND THAT DRIVES ME CRAZY!! I appreciate your thoughts on this. Regards, Jan
RE: [PHP] get an object property
I have to agree, your example works fine for me. For testing I used the latest stable Release of server2go with PHP 5.2.10. Or do you want to use something like that: class o { protected $arr = array('a'=0); function o($n){$this-arr['a'] = $n;} function getA(){return $this-arr['a'];} } $o = array( new o(1), new o(2) ); if ( end($o)-getA() 1 ) { echo yeah; } Which works fine as well ... Regards, jan -Original Message- From: Tom Worster [mailto:f...@thefsb.org] Sent: Saturday, September 12, 2009 1:31 AM To: PHP General List Subject: [PHP] get an object property if i have an expression that evaluates to an object, the return value from a function, say, and i only want the value of one of the objects properties, is there a tidy way to get it without setting another variable? to illustrate, here's something that doesn't work, but it would be convenient if it did: $o = array( (object) array('a'=1), (object) array('a'=2) ); if ( end($o)-a 1 ) { // can't use - like this! ... } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Eingehende eMail ist virenfrei. Von AVG überprüft - www.avg.de Version: 8.5.409 / Virendatenbank: 270.13.71/2336 - Ausgabedatum: 09/11/09 09:15:00 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] preg_match()
Good Afternoon. This shouldn't be too complicated, but I can't come up with a solution for the problem right now. It's about RegEx in PHP (5.2) Is there a way to capture ALL sub elements of an expression like preg_match('@a(?[0-9])*b@' ,a2345678b , $matches); ?? This would produce (below) whereas I'd like to get all the elements (2-8) as an array entry each . ([1]=2, [2]=3 .) Result: array(2) { [0]= array(1) { [0]= string(9) a2345678b } [1]= array(1) { [0]= string(1) 8 } } preg_match_all doesn't do the trick. The Expression I want to use is @prim_states[\s]*\((?num[0-9\s]*)(prim_state[\s]*\((?flag[a-fA-F0-9\s]*) tex_idxs[\s]*\(([0-9\s]*)\)([0-9\s]*)\)[\s]*)*\)@ as I'm trying to parse a 3d Model File, that contains data in the form of prim_states ( 51 prim_state ( 2 tex_idxs ( 1 2 ) 0 3 0 0 1 ) prim_state ( 3 tex_idxs ( 1 2 ) 0 0 1 0 1 ) prim_state ( 3 tex_idxs ( 1 2 ) 0 4 1 0 1 ) [.] ) Thank You! Regards, Jan
RE: [PHP] preg_match()
Not quite, I'm sorry. As the outer expression prim_states( [...] ) captures, the repetitive elements inside prim_state( [...] ) overwrite each other in the matches array. Of course I could get the first entry in matches, and search it again with preg_match_all(), but that is what I'm trying to avoid. But maybe that's what I have to after all if there is no other way. Thanks Regards, Jan -Original Message- From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] Sent: Wednesday, September 09, 2009 6:21 PM To: Jan Reiter Cc: php-general@lists.php.net Subject: Re: [PHP] preg_match() On Wed, 2009-09-09 at 18:18 +0200, Jan Reiter wrote: Good Afternoon. This shouldn't be too complicated, but I can't come up with a solution for the problem right now. It's about RegEx in PHP (5.2) Is there a way to capture ALL sub elements of an expression like preg_match('@a(?[0-9])*b@' ,a2345678b , $matches); ?? This would produce (below) whereas I'd like to get all the elements (2-8) as an array entry each . ([1]=2, [2]=3 .) Result: array(2) { [0]= array(1) { [0]= string(9) a2345678b } [1]= array(1) { [0]= string(1) 8 } } preg_match_all doesn't do the trick. The Expression I want to use is @prim_states[\s]*\((?num[0-9\s]*)(prim_state[\s]*\((?flag[a-fA-F0-9\s]*) tex_idxs[\s]*\(([0-9\s]*)\)([0-9\s]*)\)[\s]*)*\)@ as I'm trying to parse a 3d Model File, that contains data in the form of prim_states ( 51 prim_state ( 2 tex_idxs ( 1 2 ) 0 3 0 0 1 ) prim_state ( 3 tex_idxs ( 1 2 ) 0 0 1 0 1 ) prim_state ( 3 tex_idxs ( 1 2 ) 0 4 1 0 1 ) [.] ) Thank You! Regards, Jan If your example is indicative of what you need, then couldn't you just loop through all the elements inside of the match as it will be a contiguous string of numbers. Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Eingehende eMail ist virenfrei. Von AVG überprüft - www.avg.de Version: 8.5.409 / Virendatenbank: 270.13.71/2336 - Ausgabedatum: 09/08/09 20:45:00 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] preg_match()
Thanks! Thats about what I'm doing right now. function parse_prim_states($in) { preg_match('@prim_states[\s]*\((?number[0-9\s]*)@' ,$in , $matches); $this-num_prim_states = (int)$matches['number']; preg_match_all('@prim_state[\s]*\((?flag1[a-fA-F0-9\s]*)tex_idxs[\s]*\((? texidx[0-9\s]*)\)(?flag2[0-9\s]*)\)@' ,$in , $matches); for($i=0;$i$this-num_prim_states;$i++) { $this-add_prim_state($matches['flag1'][$i],$matches['flag2'][$i],$matches[' texid'][$i]); } unset($matches); return true; } Regards -Original Message- From: Shawn McKenzie [mailto:nos...@mckenzies.net] Sent: Wednesday, September 09, 2009 7:57 PM To: Jan Reiter Cc: php-general@lists.php.net Subject: [PHP] Re: preg_match() Jan Reiter wrote: Good Afternoon. This shouldn't be too complicated, but I can't come up with a solution for the problem right now. It's about RegEx in PHP (5.2) Is there a way to capture ALL sub elements of an expression like preg_match('@a(?[0-9])*b@' ,a2345678b , $matches); ?? This would produce (below) whereas I'd like to get all the elements (2-8) as an array entry each . ([1]=2, [2]=3 .) AFAIK, you would need to know how many digits are there and use that many capture groups (), because you only have one capture group which will be overwritten each iteration. An alternative for your simple example above would be to do: preg_match('@a([0-9]+)b@' ,a2345678b , $matches); --then-- print_r(str_split($matches[1])); To do this multiple times in a large string you would need: preg_match_all('@a([0-9]+)b@' ,a2345678b , $matches); foreach($matches[1] as $match) { print_r(str_split($match)); } -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Eingehende eMail ist virenfrei. Von AVG überprüft - www.avg.de Version: 8.5.409 / Virendatenbank: 270.13.71/2336 - Ausgabedatum: 09/09/09 06:53:00 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] crypt salt question
Hi! How did you do the comparison with the PG_SQL database?? I believe there is a UNIX function, able to retrieve the salt from a crypt string, or one that can do the comparison, without a slat given. But I'm not quite sure. I'm gonna investigate that. But how did you compare passwords before, when using a time based random salt? I understand you use the CRYPT_STD_DES method ... Greets, Jan -Original Message- From: Andras Kende [mailto:[EMAIL PROTECTED] Sent: Thursday, August 30, 2007 11:42 PM To: php-general@lists.php.net Subject: [PHP] crypt salt question Hello, I'm trying to move some app from postgresql to mysql but unable to find out how to authenticate against the current crypted passwords with php.. insert to database: $cset = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./; $salt = substr($cset, time() 63, 1) . substr($cset, time()/64 63, 1); $password = crypt($password, $salt); //pass crypted version of password for further processing $result = pg_query (INSERT INTO users (username, password) VALUES ('$username', '$password')); I read the crypt is one way encryption but how to compare the password entered with the encrypted version if don't know the salt ?? Thanks, Andras -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] crypt salt question
No, I'm sorry, I spoke out that thought to early!! At the university we used a PG_SQL database to store the passwords, and used the LDAP tree with all the user information and stuff to store the salt as well! How do your scripts operate on that with the PG_SQL database before migrating to mysql ... Greets, Jan -Original Message- From: Jan Reiter [mailto:[EMAIL PROTECTED] Sent: Friday, August 31, 2007 12:07 AM To: 'Andras Kende'; PHP Mailing List Subject: RE: [PHP] crypt salt question Hi! How did you do the comparison with the PG_SQL database?? I believe there is a UNIX function, able to retrieve the salt from a crypt string, or one that can do the comparison, without a slat given. But I'm not quite sure. I'm gonna investigate that. But how did you compare passwords before, when using a time based random salt? I understand you use the CRYPT_STD_DES method ... Greets, Jan -Original Message- From: Andras Kende [mailto:[EMAIL PROTECTED] Sent: Thursday, August 30, 2007 11:42 PM To: php-general@lists.php.net Subject: [PHP] crypt salt question Hello, I'm trying to move some app from postgresql to mysql but unable to find out how to authenticate against the current crypted passwords with php.. insert to database: $cset = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./; $salt = substr($cset, time() 63, 1) . substr($cset, time()/64 63, 1); $password = crypt($password, $salt); //pass crypted version of password for further processing $result = pg_query (INSERT INTO users (username, password) VALUES ('$username', '$password')); I read the crypt is one way encryption but how to compare the password entered with the encrypted version if don't know the salt ?? Thanks, Andras -- 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] export data of html table
Hi! I'm not quite sure if I got you right, but if you want a simple button to print the current web-page use the browsers built-in printing function. Just link to javascript:window.print(); to bring up the printing dialogue. Is this a simple html-table, or is it something special? Or render it into a PDF File ... Hope that helps! Greets, Jan -Original Message- From: Vanessa Vega [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 22, 2007 8:09 AM To: php-general@lists.php.net Subject: [PHP] export data of html table helloo.. i have a table generated using PHP javascript...the data on that table came from a form where several data was inputted... I want to let them see a preview of the data they entered, so i put a link or button that when clicked, will display all the data in the table and they will also have an option to print them. Is there a way to easily do this? does it really need exporting data to another application like excel in order to print it? please give me some advice...thanks -- 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] ptting the variable inside the input
Hi! You don't have to end your string when placing an array value. {} will tell the parser to interpret the text between as a variable. Try: echo trtdinput name=\title\ type=\text\ value=\{$row['title']}\ //td; Jan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Programmer in the US?
Hi there! I spent the last 4 Years ('03-'07) as an Officer with the German Air Force collecting massive experience with large university networks (programming, maintenance) and on electronic warfare live training exercises (management, IT Officer), but I studied Space and Aeronautics and did not finish. I have programming experience in C/C++ since '99 and PHP/html/jscript since '01. I do not have a diploma or degree or anything. Only a military record that tells what I did, and that I did it good! ;-) Sine I see from some of your signatures that some of you are working at US based companies, do you have any tips or experiences how to start off as a programmer or technical manager with such a bad starting position? Getting a greencard once I got a job shouldn't be a problem since I'm cleared up to NATO-Secret. (if that helps) Thank you very much for any help, tips, experiences ... Best Regards, Jan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] I know this is not easy and I'm not stupid but...
Hi! Phil: Still I am curious what var_dump($userValues['afterDark']); at line 102.5 would return. I managed to recreate that fault with $var['test'] = blah; echo ($var['test']); if( $var['test'] == 0) { echo ok; } //this returns blahok -- not expected. In my case Var_dump() returns string(4) blah as expected. Using if( $var['test'] === 0) behaves as expected!! Jim: TypeCasting would only be effective if you used the type sensitive comparison operator === , because with == 0 equals NULL equals false equals and so on ... or do I miss something here?? Hope that solves it for you! I'm still investigating why my first examples fails. I've got the strong feeling that I'm missing something there. I don't believe in a php bug or a memory leak in this case! Must be something pretty obvious! Anyone a clue?? Thanks, Jan -Original Message- From: Jim Lucas [mailto:[EMAIL PROTECTED] Sent: Thursday, August 09, 2007 8:08 PM To: Stut Cc: Phil Curry; php-general Subject: Re: [PHP] I know this is not easy and I'm not stupid but... Stut wrote: Please include the list when replying. Phil Curry wrote: Phil Curry wrote: how can this be? This is not the first time I've run into a situation like this. What am I missing? line 102echo ($userValues['afterDark']); // outputs 1 line 103if ( $userValues['afterDark'] == 0 ) {// passes Add a line at 102.5... var_dump($userValues['afterDark']); What type is that variable? Don't have to do a dump, I know its a tinyint(1), not null, default 0 PHP does not have a type of tinyint knowing now that this comes from a database, if it is mysql, then it is of type string PHP converts all fields when pulled from the database into strings. It does not take into account what type the field is actually set to in mysql. Try puting a (int) in front of the condition like this if ( (int)$userValues['afterDark'] == 0 ) { ... } Maybe this will help That would be the type in the database, not the type of that variable at that time. -Stut -- 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 General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] I know this is not easy and I'm not stupid but...
Hi! Thank you for your response! The only intention of my code was to investigate the (back then) unexpected behavior of the if statement. With $var['test'] set to blah this expression should be false ($var['test'] == 0) for what I know ... $var['test'] = blah; var_dump($var['test'] == 0); //returns bool(true) Now I know why this happens! According to Table 6.5 of the Operators page in the PHP Manual in this comparison all of the values are converted to integer. And atoi(blah) for sure will fail!;-) So you have to use === to keep the types of the values! Jan -Original Message- From: Jim Lucas [mailto:[EMAIL PROTECTED] Sent: Friday, August 10, 2007 1:47 AM To: Jan Reiter Cc: [EMAIL PROTECTED]; php-general@lists.php.net Subject: Re: [PHP] I know this is not easy and I'm not stupid but... Jan Reiter wrote: Hi! Phil: Still I am curious what var_dump($userValues['afterDark']); at line 102.5 would return. I managed to recreate that fault with $var['test'] = blah; echo ($var['test']); if( $var['test'] == 0) { echo ok; } //this returns blahok -- not expected. In my case Var_dump() returns string(4) blah as expected. Using if( $var['test'] === 0) behaves as expected!! Are you wanting to only test for a empty/non-empty string? if so, use this. if ( empty($var['test']) ) { echo var['test'] is empty; } Jim: TypeCasting would only be effective if you used the type sensitive comparison operator === , because with == 0 equals NULL equals false equals and so on ... or do I miss something here?? Hope that solves it for you! I'm still investigating why my first examples fails. I've got the strong feeling that I'm missing something there. I don't believe in a php bug or a memory leak in this case! Must be something pretty obvious! Anyone a clue?? Thanks, Jan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] I know this is not easy and I'm not stupid but...
Ummh, no! (int) and (integer) perform a C style atoi() conversion. (int)blah = integer 0 (int) = integer 0 (int)1= integer 1 (int)12 = integer 12 (1 == 0) = false (blah == 0) = true ( (int)$userValues['afterDark'] === 0 ) only is true, if $userValues['afterDark'] is a string not containing an integer. This is what happens: $userValues['afterDark'] gets converted to integer by atoi(), and after that is compared by type and value to integer 0. So the type part of the test will pass for sure. But perhaps you should try to adapt the comparison to the DB value. So try ($userValues['afterDark'] == (string)0) This expression is only true if $userValues['afterDark'] equals 0, not when $userValues['afterDark'] equals or blah or 1 Hope that helps! Jan -Original Message- From: Phil Curry [mailto:[EMAIL PROTECTED] Sent: Friday, August 10, 2007 2:49 AM To: Stut Cc: php-general Subject: Re: [PHP] I know this is not easy and I'm not stupid but... Please include the list when replying. Phil Curry wrote: Phil Curry wrote: how can this be? This is not the first time I've run into a situation like this. What am I missing? line 102echo ($userValues['afterDark']); // outputs 1 line 103if ( $userValues['afterDark'] == 0 ) {// passes Add a line at 102.5... var_dump($userValues['afterDark']); What type is that variable? Don't have to do a dump, I know its a tinyint(1), not null, default 0 That would be the type in the database, not the type of that variable at that time. -Stut -- http://stut.net/ Absolutely right. didn't think of that. var_dump($userValues['afterDark']); == string(1) 1 but then I'm comparing a string to an int and the result always seems to pass. So does that mean any string compared to any int will be true? By casting (int)$userValues['afterDark'] the test still passes and var_dump shows the (int)$userValues['afterDark'] as an int(1) but does give a value like the previous example. ie. string(1)1 but only int(1) Not sure if the expression has a value of 1 now that its been cast. Then finally if ( (int)$userValues['afterDark'] === 0 ) {// passes So: if ( $userValues['afterDark'] == 0 ) { // passes if ( (int)$userValues['afterDark'] == 0 ) { // passes if ( (int)$userValues['afterDark'] === 0 ) { // passes And the value of afterdark in the mysql table is tinyint(1) 1. And echo( 1+(int)$userValues['afterDark']);// outputs 2 Now I'm confused! -Phil -- 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] preg_match_all to match img tags
Maybe this is what you are searching for: $images = array(); $data = blah img src=img.png width=\400\ height='600' src=blah.png img src=gg.tiff; preg_match_all(/\ *[img][^\]*[.]*\/i, $data, $matches); foreach($matches[0] as $match) { preg_match_all(/(src|height|width)*= *[\\']{0,1}([^\\'\ \]*)/i, $match, $m); $images[] = array_combine($m[1],$m[2]); } print_r($image); It will produce: Array ( [0] = Array ( [src] = img.png [width] = 400 [height] = 600 ) [1] = Array ( [src] = gg.tiff ) ) I wrote it just as an example. So you may modify it for your needs! Does anyone know if there is a way to put this into ONE regex?? Jan -Original Message- From: brian [mailto:[EMAIL PROTECTED] Sent: Friday, August 10, 2007 3:18 AM To: php-general@lists.php.net Subject: Re: [PHP] preg_match_all to match img tags Ólafur Waage wrote: I know this isn't exactly a php related question but due to the quality of answers ive seen lately ill give this a shot. (yes yes im smoothing up the crowd before the question) I have a weblog system that i am creating, the trouble is that if a user links to an external image larger than 500pixels in width, it messes with the whole layout. I had found some regex code im using atm but its not good at matching the entire image tag. It seems to ignore properties after the src declaration and not match tags that have properties before the src declaration . preg_match_all(/\ *[img][^\]*[src] *= *[\\']{0,1}([^\\'\ ]*)/i, $data, $matches); print_r($matches); This currently makes two arrays for me, the source location from all img tags and a large part of the tag itself. But not the entire tag. What i do is i match the img tag, find the src, get the image properties, and if the width is more than 500, i shrink it down and add width=X and height=Y properties to the image tag. How can i match an image tag correctly so it does not cause any issues with how the user adds the image. style #your_content_div img { max-width: 500px !important; } /style OK, so it won't work with IE6. Screw them. But if the height is set in the img tag it'll keep that, so the image could become distorted. So, you could also do something like: #your_content_div img { visibility: none; } Then run some Javascript routine onload to properly figure the dimensions of each image. Adjust the width down to 500px, if necessary, then the height by whatever percent difference between original width over new width: var new_height = (original_width / 500) * original_height; Then, whether you change the dimensions of the image or not, change the visibility of each to 'visible'. So, um ... no PHP involved. brian -- 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] Problems with file_get_contents() and local PHP file
D'oh! The solution is so simple and clean that it almost hurts. I didn't see it in the first approach! There is a way to go all this, without using file() or file_get_contents()! Cuz this would require to use a URL wrapper to retrieve compiled code, which would cost overhead on the local webserver and the internet deamon. Just use and modify this code. You may also put it into a function; // I strongly recommend to use this INSIDE a function to get a clear namespace function get_img_script($parameters) { // backup $_GET variable $getbuffer = $_GET; unset($_GET); $_GET = $parameters; ob_start(); include 'yourscript.php'; $buffer = ob_get_contents(); Ob_end_clean(); // restore $_GET variable unset($_GET); $_GET = $getbuffer; return $buffer; } And call it like this: // define variables here. If you'd passed it with ?var=val // use $param = array('var'='val'); $img = get_img_script($param); Hope that solves the problem in a clean way! Jan -Original Message- From: Richard Lynch [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 08, 2007 3:51 AM To: Mike Cc: php-general@lists.php.net Subject: Re: [PHP] Problems with file_get_contents() and local PHP file On Sun, August 5, 2007 1:37 am, Mike wrote: Hey. My server is running PHP 4(Not actually my server so I don't know the exact version) and I'm having trouble with getting an image from a PHP file. Use ?php phpinfo();? to find out exactly what you've got. The problem is that originally this system was developed to be used with PHP 5, and used fopen() and stream_get_contents() to retrieve the image file from flash_frames.php. I thought I could just replace both of those with file_get_contents(), but it appears to fail when doing so. A quick test confirmed that file_get_contents(), when used locally, returns the PHP source as opposed to the output of the file. If it's old enough, even file_get_contents may not be defined... It first appeared in PHP 4.3.0, so if you're running something earlier than that, upgrade. Or I guess you could use: implode('', file($filename)); I didn't originally code this (I am but an inheritor who is learning PHP as he goes :P), so I'm at a loss for what should be done to fix this. I considered just converting the file into a function that returns the image, but I cannot find out how to return an image (Or convert the image to a string of bytes as the original code expected it to be). Any help is greatly appreciated. :) -Mike Original code for retrieving image: //Replaces res_viewer to flash_frames since they both take the same arguments $img=rawurldecode($img); $fl_imgsrc=str_replace('/res_viewer.php?','/flash_frames.php?scale='. $scale.'',rawurldecode($img)); This is doing rawurldecode() on $img twice, which is almost for sure not right. It probably works for all the actual inputs you are using, but it would fail if somebody passed in a filename that happened to have %xx in the actual filename, almost for sure. //Grabs the generated image set up for the flash preview $handle = fopen($fl_imgsrc, rb); $contents = stream_get_contents($handle); $fl_map = new SWFBitmap($contents); This is using the Ming extension. There is a Ming mailing list that may be helpful if it turns out that $contents is fine, but the new SWFBitmap is not working The number of Ming users is very tiny compared to PHP in general, and I suspect not many hard-core Ming users are on this list. fclose($handle); -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Problems with file_get_contents() and local PHP file
Hi! If you want file_get_contents() to open the compiled data, force the server to compile it first. ;-) Do not open the file from filesystem, use the ULR (http://server/flash_frames.php?...). For this fopen() wrappers have to be enabled. http://www.php.net/manual/en/function.file-get-contents.php The tip in the blue box. If you get uncompiled code with the url stated, you got a big security hole in the server config!! Hope this is, what you are searching for ... Jan -Original Message- From: Mike [mailto:[EMAIL PROTECTED] Sent: Sunday, August 05, 2007 8:38 AM To: php-general@lists.php.net Subject: [PHP] Problems with file_get_contents() and local PHP file Hey. My server is running PHP 4(Not actually my server so I don't know the exact version) and I'm having trouble with getting an image from a PHP file. I have a file, flash_frames.php, which outputs an image composed of the combination of a bunch of other images. Another file, flash.php, takes this image and chops it up into frames and then animates it in a flash file. The problem is that originally this system was developed to be used with PHP 5, and used fopen() and stream_get_contents() to retrieve the image file from flash_frames.php. I thought I could just replace both of those with file_get_contents(), but it appears to fail when doing so. A quick test confirmed that file_get_contents(), when used locally, returns the PHP source as opposed to the output of the file. I didn't originally code this (I am but an inheritor who is learning PHP as he goes :P), so I'm at a loss for what should be done to fix this. I considered just converting the file into a function that returns the image, but I cannot find out how to return an image (Or convert the image to a string of bytes as the original code expected it to be). Any help is greatly appreciated. :) -Mike Original code for retrieving image: //Replaces res_viewer to flash_frames since they both take the same arguments $img=rawurldecode($img); $fl_imgsrc=str_replace('/res_viewer.php?','/flash_frames.php?scale='. $scale.'',rawurldecode($img)); //Grabs the generated image set up for the flash preview $handle = fopen($fl_imgsrc, rb); $contents = stream_get_contents($handle); $fl_map = new SWFBitmap($contents); fclose($handle); -- 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] Problems with file_get_contents() and local PHP file
Nice to hear that! If you expect heavy traffic on the site using that script you might want try to save some DNS and http connection overhead by stating the url with http://localhost/ and so on. Given that the server's OS is unix based, it may also work to execute the php-script like a shell script if the php environment is set accordingly. In case of a image processing script, this may take a huge load of work away from your apache or wahterver server, and restrict it to the php processor only. (the data stream won't be routed over the internet deamon and the webserver on port 80) In order to do so, try $buffer = `php /var/www/thescript.php`; // or whatever location your script is in ... Instead of $buffer = file_get_contents(http://localblah...;); But if it's a rented server, apache overhead isn't your concern, so go on and let your provider worry about it! :-D Jan -Original Message- From: Mike [mailto:[EMAIL PROTECTED] Sent: Monday, August 06, 2007 12:45 AM To: php-general@lists.php.net Subject: Re: [PHP] Problems with file_get_contents() and local PHP file Hah, it works! I had to fiddle around a few other errors but that did the trick! Thank you so much. :) -Mike -- 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] Problems with file_get_contents() and local PHP file
You've got a point about that. Try ?php echo file_get_contents(http://localhost/path/to/webdir;); ? First ... If you see your own webpage it's okay, else don't mess with it. -Original Message- From: Chris [mailto:[EMAIL PROTECTED] Sent: Monday, August 06, 2007 2:51 AM To: Jan Reiter Cc: 'Mike'; php-general@lists.php.net Subject: Re: [PHP] Problems with file_get_contents() and local PHP file Jan Reiter wrote: Nice to hear that! If you expect heavy traffic on the site using that script you might want try to save some DNS and http connection overhead by stating the url with http://localhost/ and so on. Which will most likely point to a different virtual host and cause you even more problems trying to track it down. -- Postgresql php tutorials http://www.designmagick.com/ -- 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] Problem with getting time in EST
Hi! Try setting the timezone to one of the cities inside it from this list: http://www.php.net/manual/en/timezones.america.php DST will be taken into account automatically. Hope that helps. Jan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Problem with getting time in EST
Tedd: you can set your default php timezone in the php.ini with the date.timezone value. What Server do you use? What OS? I'm using apache2.x on win32, debian and fedora core. The time of Detroit looks ok to compared to times stated on world time pages on the internet. After upgrading to PHP5, did you check for the latest version of PECL's timezonedb. I don't know if its included with the PHP package! May be a bad question, but are the time and timezone settings of your HW clock correct?? Just as the very last option to check, if everything else fails ... ;-) Jan -Original Message- From: tedd [mailto:[EMAIL PROTECTED] Sent: Saturday, August 04, 2007 5:02 PM To: Jan Reiter; 'Crab Hunt'; php-general@lists.php.net Subject: RE: [PHP] Problem with getting time in EST Jan: That's the problem, it doesn't work. I have mine set for Detroit and it's an hour off Detroit time. It kind of bugged me that when I upgraded to php5 that I had to define the default time zone in my code, but then to find out that it's off by an hour really ticks me off. What's the point of defining a time zone if php5 isn't going to get it right? All this time I thought that I was doing something wrong, but it appears that this is a problem for others as well -- are we doing something wrong? Cheers, tedd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Creating watermarks
Hi! Try using imagealphablending() to blend your logo onto the original image. This function should not require the user browser to be capable of blending functions as would using the alpha channel of a png inmage or such ... Jan -Original Message- From: Tom Ray [Lists] [mailto:[EMAIL PROTECTED] Sent: Saturday, August 04, 2007 5:32 PM To: php-general@lists.php.net Subject: [PHP] Creating watermarks I've been learning how to use PHP with the GD Library and I've managed to learn quite a bit. I can upload, resize, create thumbnails and I'm even able to create security code images for forms. My question is how do I create a Watermark on the image? I want something transparent but still visible enough to see the copyright and the website. I want to put it in the center of the image. I would use a non-water marked image and when it's called on (depending on viewing size) I want the water mark to be added. How would one go about doing that? -- 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] Output Buffering and zlib Compression Issue
Hi! I'm not quite sure what you are trying to do ... Why do you use output buffering in your code, when you turn it off in the htaccess directive?? php_flag output_buffering Off The code worked for me. But I tested it without your htaccess settings ... Jan -Ursprüngliche Nachricht- Von: Chris [mailto:[EMAIL PROTECTED] Gesendet: Samstag, 4. August 2007 01:18 An: php-general@lists.php.net Betreff: [PHP] Output Buffering and zlib Compression Issue When I run the following code (PHP 5.2.2, 5.2.3) via Apache (with an htaccess file), I get this error: Notice: ob_end_clean() [ref.outcontrol]: failed to delete buffer zlib output compression. in ... Can anyone explain what's going on? I'm assuming it isn't a bug and I've read the documentation. Did I miss something? htaccess file code: php_flag output_buffering Off php_flag zlib.output_compression On php_value zlib.output_compression_level -1 PHP Code: ?php error_reporting(E_ALL | E_NOTICE); ini_set('display_errors', '1'); ob_start(); echo You shouldn't see this.; while (ob_get_level() 0) { ob_end_clean(); } ob_start(); echo You SHOULD see this.; ob_end_flush(); ? Chris -- 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] Output Buffering and zlib Compression Issue
Right! With zlib compression ob_start() or similar seems to get called before the user script execution. I'm not quite sure why. Anyhow ob_get_level() returns 2 after the ob_start() is called for the first time in the script. You can avoid the error with while (ob_get_level() 1) { ob_end_clean(); } but it won't kill the buffer containing output before ob_start() is called. ob_end_clean(); ob_end_clean(); will reproduce your error, too. This leads to the assumption, that it is an issue of advancing the functions internal process pointer. Same reason why $data1 = mysql_fetch_assoc($resultid); $data2 = mysql_fetch_assoc($resultid); won't lead to the desired effect either, but While($data = mysql_fetch_assoc($resultid)){...} does, as does while (@ob_end_clean()); It seems only this way of accessing the buffers allows deleting the lowermost buffer created before Script execution. Jan -Original Message- From: Chris [mailto:[EMAIL PROTECTED] Sent: Saturday, August 04, 2007 3:25 AM To: php-general@lists.php.net Subject: [PHP] Re: Output Buffering and zlib Compression Issue -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php