[PHP] Re: Problem with variables
On 6/25/2013 5:46 PM, Fernando A wrote: Hello, I am working with php and codeigniter, but I have not yet experienced. I need create a variable that is available throughout system. This variable contains the number of company and can change. as I can handle this? Thank you, very much! Ferd One way would be to create a file like this: ? // company_info.php $_SESSION['company_name'] = My Company; $_SESSION['company_addr1'] = 1 Main St.; etc. etc. etc. Then - in your startup script (or in every script), use an include statement: ?php session_start(); include($path_to_includes./company_info.php); Now you will have those SESSION vars available for the entire session, basically until you close your browser. You can also use the php.ini auto-prepend setting, which automatically does this for you, altho the vars would not be session vars, since the prepend-ed file happens before your script issues the session_start (I think). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: problem with my login script
On 02 Oct 2012 at 12:07, Maciek Sokolewicz maciek.sokolew...@gmail.com wrote: On 02-10-2012 11:59, Bálint Horváth wrote: The problem was already solved. I forgot to send a copy to the list... Rodrigo, break!? Ohh man, it's a crazy idea... A developer DOES NOT use break at all (in a loop)... (switch is an exception) I personally find this statement to be utter bullshit. There is nothing wrong with using break. There is a very good reason why it's available in the language. In very many cases, it costs a lot less code to add a break than to add additional clauses to your while-conditional. Agree 100%. -- Cheers -- Tim
RES: [PHP] Re: problem with my login script
I follow this rule of thumb: small blocks of highly understandable code. If this demands ternary conditionals or breaks, so be it! -Mensagem original- De: Tim Streater [mailto:t...@clothears.org.uk] Enviada em: terça-feira, 2 de outubro de 2012 08:37 Para: PHP General List Assunto: [PHP] Re: problem with my login script On 02 Oct 2012 at 12:07, Maciek Sokolewicz maciek.sokolew...@gmail.com wrote: On 02-10-2012 11:59, Bálint Horváth wrote: The problem was already solved. I forgot to send a copy to the list... Rodrigo, break!? Ohh man, it's a crazy idea... A developer DOES NOT use break at all (in a loop)... (switch is an exception) I personally find this statement to be utter bullshit. There is nothing wrong with using break. There is a very good reason why it's available in the language. In very many cases, it costs a lot less code to add a break than to add additional clauses to your while-conditional. Agree 100%. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: RES: [PHP] Re: problem with my login script
Just for the record, I'll sign that one. There is a reason for continue, break and return to exist. Just make sure, that your code is understandable and there is no problem using these exits. If your code is that complicated, that you don't understand a break in it, the problem is another. Samuel Lopes Grigolato samuel.grigol...@gmail.com hat am 2. Oktober 2012 um 13:40 geschrieben: I follow this rule of thumb: small blocks of highly understandable code. If this demands ternary conditionals or breaks, so be it! -Mensagem original- De: Tim Streater [mailto:t...@clothears.org.uk] Enviada em: terça-feira, 2 de outubro de 2012 08:37 Para: PHP General List Assunto: [PHP] Re: problem with my login script On 02 Oct 2012 at 12:07, Maciek Sokolewicz maciek.sokolew...@gmail.com wrote: On 02-10-2012 11:59, Bálint Horváth wrote: The problem was already solved. I forgot to send a copy to the list... Rodrigo, break!? Ohh man, it's a crazy idea... A developer DOES NOT use break at all (in a loop)... (switch is an exception) I personally find this statement to be utter bullshit. There is nothing wrong with using break. There is a very good reason why it's available in the language. In very many cases, it costs a lot less code to add a break than to add additional clauses to your while-conditional. Agree 100%. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Marco Behnke Dipl. Informatiker (FH), SAE Audio Engineer Diploma Zend Certified Engineer PHP 5.3 Tel.: 0174 / 9722336 e-Mail: ma...@behnke.biz Softwaretechnik Behnke Heinrich-Heine-Str. 7D 21218 Seevetal http://www.behnke.biz -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: RES: [PHP] Re: problem with my login script
My problem was solved no need to argue. I don't see why use a while loop with a count variable when it produces the same result as a foreach loop. As for using a break in the loop, I could add it but the loop is gonna stop anyway as soon as it hits the end of the array. I also didn't see the point in using the explode() function as long as I remove the (in my opinion) useless index numbers from the text file containing the username. The following code works as I expect it to: ?php session_start(); $users = file(../inc/users.inc.php); if(!empty($_POST['username']) !empty($_POST['password'])){ if(filter_var($_POST['username'], FILTER_VALIDATE_EMAIL)){ foreach($users as $row){ $row = trim($row); if($_POST['username'] == $row){ $_SESSION['logged_in'] = 1; $_SESSION['username'] = $row; } } if($_SESSION['logged_in'] != 1){ $error = 2; } }else{ $error = 4; } }else{ $error = 3; } if($error){ header(Location:); }else{ header(Location:); } ? users.inc.php: m...@email1.com m...@email2.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: problem with my login script
To break or not to break? that's the question... All that fight makes me (and, I think that Thomas too) learn a bit more about all of this. And for finish with all of it. I think that if something is not deprecated, is because it's is a good idea to use it somewhere. If the Language developers think that way, i will not discord. Regards. Em 02-10-2012 10:35, Thomas Conrad escreveu: My problem was solved no need to argue. I don't see why use a while loop with a count variable when it produces the same result as a foreach loop. As for using a break in the loop, I could add it but the loop is gonna stop anyway as soon as it hits the end of the array. I also didn't see the point in using the explode() function as long as I remove the (in my opinion) useless index numbers from the text file containing the username. The following code works as I expect it to: ?php session_start(); $users = file(../inc/users.inc.php); if(!empty($_POST['username']) !empty($_POST['password'])){ if(filter_var($_POST['username'], FILTER_VALIDATE_EMAIL)){ foreach($users as $row){ $row = trim($row); if($_POST['username'] == $row){ $_SESSION['logged_in'] = 1; $_SESSION['username'] = $row; } } if($_SESSION['logged_in'] != 1){ $error = 2; } }else{ $error = 4; } }else{ $error = 3; } if($error){ header(Location:); }else{ header(Location:); } ? users.inc.php: m...@email1.com m...@email2.com
[PHP] Re: Problem of load balance among php-cgi process
It's cause by eaccelerator module, when I remove this module, the php-cgi works well. Is there some compatible issue between eaccelerator and php? Regards Sean 2011/10/19 Sean Chen s...@coovan.com Hi, ** ** I’ve got a problem when running PHP with nginx, there are several php-cgi processes and only one is busy at one time, like this: ** ** 500 23868 0.0 0.0 209164 10948 ?S21:23 0:01 /usr/local/websrv/php/bin/php-cgi --fpm --fpm-config /usr/local/websrv/php/etc/php-fpm.conf 500 23871 0.0 0.0 209136 10684 ?S21:23 0:01 /usr/local/websrv/php/bin/php-cgi --fpm --fpm-config /usr/local/websrv/php/etc/php-fpm.conf 500 23872 0.0 0.0 209136 10732 ?S21:23 0:01 /usr/local/websrv/php/bin/php-cgi --fpm --fpm-config /usr/local/websrv/php/etc/php-fpm.conf 500 23873 0.0 0.0 209136 10712 ?S21:23 0:01 /usr/local/websrv/php/bin/php-cgi --fpm --fpm-config /usr/local/websrv/php/etc/php-fpm.conf 500 23874 0.0 0.0 209076 10576 ?S21:23 0:01 /usr/local/websrv/php/bin/php-cgi --fpm --fpm-config /usr/local/websrv/php/etc/php-fpm.conf 500 23875 0.0 0.0 209136 10976 ?S21:23 0:01 /usr/local/websrv/php/bin/php-cgi --fpm --fpm-config /usr/local/websrv/php/etc/php-fpm.conf 500 23876 0.0 0.0 209136 10796 ?S21:23 0:01 /usr/local/websrv/php/bin/php-cgi --fpm --fpm-config /usr/local/websrv/php/etc/php-fpm.conf 500 23877 0.0 0.0 209136 11068 ?S21:23 0:01 /usr/local/websrv/php/bin/php-cgi --fpm --fpm-config /usr/local/websrv/php/etc/php-fpm.conf 500 23878 0.0 0.0 209136 10708 ?S21:23 0:01 /usr/local/websrv/php/bin/php-cgi --fpm --fpm-config /usr/local/websrv/php/etc/php-fpm.conf 500 23879 0.0 0.0 209136 10960 ?S21:23 0:01 /usr/local/websrv/php/bin/php-cgi --fpm --fpm-config /usr/local/websrv/php/etc/php-fpm.conf 500 23880 0.0 0.0 209136 10832 ?S21:23 0:01 /usr/local/websrv/php/bin/php-cgi --fpm --fpm-config /usr/local/websrv/php/etc/php-fpm.conf 500 *27195 15.0* 0.1 210196 12644 ?S23:02 0:02 /usr/local/websrv/php/bin/php-cgi --fpm --fpm-config /usr/local/websrv/php/etc/php-fpm.conf ** ** The red one is busy, and other php-cgi processes is cpu free, cpu load is about 20% total, with lot of free memory, disk and network io status is fine, and mean time, response of HTTP request to this server is very slow. ** ** The cpu load of php-cgi processes return normal when I restart the php-fpm service (each process takes some cpu slice which means they are all working I think). But, after several minutes, the problem appears again and again… ** ** what’s wrong with my php-cgi? ** ** PS: how do I debug or monitor the php program running status when it goes wrong? ** ** versions: php: 5.2.17 nginx: 5.8.55 OS: CentOS 5.6 64-bit ** ** Regards Sean ** **
Re: [PHP] Re: Problem of load balance among php-cgi process
On 10/20/2011 5:20 AM, sean chen wrote: The red one is busy My email client is color blind. -- Jim Lucas http://www.cmsws.com/ http://www.cmsws.com/examples/ http://www.bendsource.com/ C - (541) 408-5189 O - (541) 323-9113 H - (541) 323-4219 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] 答复: [PHP] Re: Problem of load balance among php-cgi process
lol. The last one: 500 23880 0.0 0.0 209136 10832 ?S21:23 0:01 /usr/local/websrv/php/bin/php-cgi --fpm --fpm-config /usr/local/websrv/php/etc/php-fpm.conf 500 27195 15.0 0.1 210196 12644 ?S23:02 0:02 /usr/local/websrv/php/bin/php-cgi --fpm --fpm-config /usr/local/websrv/php/etc/php-fpm.conf - THIS ONE PS: The problem is solved, It's cause by eaccelerator module, when I remove this module, the php-cgi works well. Regards. Sean -邮件原件- On 10/20/2011 5:20 AM, sean chen wrote: The red one is busy My email client is color blind. -- Jim Lucas http://www.cmsws.com/ http://www.cmsws.com/examples/ http://www.bendsource.com/ C - (541) 408-5189 O - (541) 323-9113 H - (541) 323-4219 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: problem with session_write_close
I'm having a problem with a brand new installation of pmwiki. I've not encountered this before so I'm unsure why this is happening. The following two warnings are presented at the top of each page: Warning: session_write_close() [function.session-write-close]: open(/ var/lib/php/session/sess_sh3dvs4pgiuq04vmj1tfmkqvj1, O_RDWR) failed: Permission denied (13) in/var/www/vhosts/mouseha.us/httpdocs/ pmwiki-2.2.27/pmwiki.php on line 2012 Warning: session_write_close() [function.session-write-close]: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/var/lib/php/session) in/var/www/ vhosts/mouseha.us/httpdocs/pmwiki-2.2.27/pmwiki.php on line 2012 There are plenty of other session files in that directory with the owner/group apache:apache. I don't know why it can't deal with this. (Cross-posted between pmwiki-users and php-general.) Update: I found out what was happening -- nothing to do with php in general. My lovely server management software (Plesk) has started adding a new line to it's vhost http include file: SuexecUserGroup mouse psacln which means apache is running under the local user/group for permissions. The file in question above was left over from a previous incarnation of the site (I blew it away and recreated it to start fresh - hah!) so the session file was left over from the previous session (not at all clear why it didn't get a new one) and had the wrong permissions set. Resetting the permissions solved the problem. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: problem with passing-by-reference
changed all function-definitions to include a before their name, no change in behavior though.. On Fri, May 14, 2010 at 10:09 AM, Rene Veerman rene7...@gmail.com wrote: Hi. I'm doing the 5.3-strict thing, and am removing all my passing-by-reference muck from a script of mine. But i've run into a problem; I use the following construct to push new values fairly deeply inside an array structure; $chase = chaseToReference ($wm, $path); $arr = result($chase); $arr[$v] = $lid; $path is a flat-list array of indexes in $wm that have to be traversed to get to the right portion of $wm. a debug-dump of $wm and $arr after running this code shows $arr correctly updated, but $wm not. :(( here are the functions involved, any help is much appreciated. function chaseToReference ($array, $path) { if (!empty($path)) { if (empty($array[$path[0]])) { return badResult (E_USER_WARNING, array( 'msg' = 'Could not walk the full tree', '$path' = $path, '$array (possibly partially walked)' = $array )); } else return chaseToReference($array[$path[0]], array_slice($path, 1)); } else { return goodResult($array); } } function result($r) { return $r['result']; } function goodResult($r) { $r2 = array ( 'isMetaForFunc' = true, 'result' = $r ); return $r2; } -- - Greetings from Rene7705, My free open source webcomponents: http://code.google.com/u/rene7705/ http://mediabeez.ws/downloads (and demos) http://www.facebook.com/rene7705 - -- - Greetings from Rene7705, My free open source webcomponents: http://code.google.com/u/rene7705/ http://mediabeez.ws/downloads (and demos) http://www.facebook.com/rene7705 - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: problem with passing-by-reference
On Fri, May 14, 2010 at 10:09 AM, Rene Veerman rene7...@gmail.com wrote: Hi. I'm doing the 5.3-strict thing, and am removing all my passing-by-reference muck from a script of mine. But i've run into a problem; I use the following construct to push new values fairly deeply inside an array structure; $chase = chaseToReference ($wm, $path); $arr = result($chase); $arr[$v] = $lid; $path is a flat-list array of indexes in $wm that have to be traversed to get to the right portion of $wm. a debug-dump of $wm and $arr after running this code shows $arr correctly updated, but $wm not. :(( here are the functions involved, any help is much appreciated. function chaseToReference ($array, $path) { if (!empty($path)) { if (empty($array[$path[0]])) { return badResult (E_USER_WARNING, array( 'msg' = 'Could not walk the full tree', '$path' = $path, '$array (possibly partially walked)' = $array )); } else return chaseToReference($array[$path[0]], array_slice($path, 1)); } else { return goodResult($array); } } function result($r) { return $r['result']; } function goodResult($r) { $r2 = array ( 'isMetaForFunc' = true, 'result' = $r ); return $r2; } On Fri, May 14, 2010 at 10:39 AM, Rene Veerman rene7...@gmail.com wrote: changed all function-definitions to include a before their name, no change in behavior though.. And then, change the calling code to: $chase = chaseToReference ($wm, $path); $arr = result($chase); $arr[$v] = $lid; and it works :)) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problem: Writing into Files?
On Sun, 02 Aug 2009 13:14:42 +0300, Parham Doustdar parha...@gmail.com wrote: Now this one always sets the file to one for some reason. I'll reiterate just in case there's been a misunderstanding on my part: [code] $fp = fopen($f, r+); while (!flock($fp, LOCK_EX)) sleep(1); $count = fgets($fp,filesize($fp)); ftruncate($fp, 0); fwrite($fp, ($count+1)); flock($fp, LOCK_UN); fclose($fp); Thanks a lot again for your help. This will work: $f = 'file.txt'; $fp = fopen($f, r+); while (!flock($fp, LOCK_EX)) sleep(1); $count = intval(fread($fp,1024)); fseek($fp,0,SEEK_SET); ftruncate($fp, 0); fwrite($fp, ($count+1)); fclose($fp); echo $count; (first you should create file file.txt manually, only then it will work) -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Problem: Writing into Files?
Hi The thing with this method is that it's just like the previous one; it opens then adds something. I'm assuming if again two visitors visit at the same time, this'd reset to zero. No, the a mode (IIRC) handles file locking for you. Even if it doesn't, the file won't be truncated, so you won't lose your count. -- Richard Heyes HTML5 graphing: RGraph - www.rgraph.net (updated 25th July) Lots of PHP and Javascript code - http://www.phpguru.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Problem: Writing into Files?
Hi, ... You can write a single byte to the file to increment the counter, then to read the count just use filesize(). I believe the a fopen() mode will handle locking for you. It will result in a slowly growing file, but space isn't exactly at a premium nowadays, and when the file gets to a certain size (eg 1 gazillion k) you could use a summary file. -- Richard Heyes HTML5 graphing: RGraph - www.rgraph.net (updated 25th July) Lots of PHP and Javascript code - http://www.phpguru.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problem: Writing into Files?
On Sun, 02 Aug 2009 07:11:27 +0300, Parham Doustdar parha...@gmail.com wrote: Dear Ollisso, I tried it with FLock() but it still didn't work. This is what I did: [code] $fp = fopen($f, r); $count =fgets($fp, 1024); fclose($fp); $fw = fopen($f, w); while (!flock($fw, LOCK_EX)) sleep(1); $cnew = $count + 1; $countnew = fputs($fw, $count + 1); flock($fw, LOCK_UN); fclose($fw); [/code] Am I doing anything wrong here? Thanks! Hello, Actually you should do something like this (according to manual) $f=fopen(file, r+); while(!flock($f, LOCK_EX)) sleep(1); $count = fgets($f,1024); ftruncate($f, 0); fwrite($f, $count+1); fclose($f); Problem in your case: first time you open file for reading, but you don't flock it, so it can read non-writen file. -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problem: Writing into Files?
Now this one always sets the file to one for some reason. I'll reiterate just in case there's been a misunderstanding on my part: [code] $fp = fopen($f, r+); while (!flock($fp, LOCK_EX)) sleep(1); $count = fgets($fp,filesize($fp)); ftruncate($fp, 0); fwrite($fp, ($count+1)); flock($fp, LOCK_UN); fclose($fp); Thanks a lot again for your help. -- --- Contact info: Skype: parham-d MSN: fire_lizard16 at hotmail dot com email: parham90 at GMail dot com Ollisso olli...@fromru.com wrote in message news:op.ux03zprl48v...@ol-n.kyla.fi... On Sun, 02 Aug 2009 07:11:27 +0300, Parham Doustdar parha...@gmail.com wrote: Dear Ollisso, I tried it with FLock() but it still didn't work. This is what I did: [code] $fp = fopen($f, r); $count =fgets($fp, 1024); fclose($fp); $fw = fopen($f, w); while (!flock($fw, LOCK_EX)) sleep(1); $cnew = $count + 1; $countnew = fputs($fw, $count + 1); flock($fw, LOCK_UN); fclose($fw); [/code] Am I doing anything wrong here? Thanks! Hello, Actually you should do something like this (according to manual) $f=fopen(file, r+); while(!flock($f, LOCK_EX)) sleep(1); $count = fgets($f,1024); ftruncate($f, 0); fwrite($f, $count+1); fclose($f); Problem in your case: first time you open file for reading, but you don't flock it, so it can read non-writen file. -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Problem: Writing into Files?
Dear Richard, I don't quite know how I can write a bite into a file. I also looked into a manual and couldn't find a mention of FLock-ing in the explaination for FOpen parameters. Thanks a lot for your help. -- --- Contact info: Skype: parham-d MSN: fire_lizard16 at hotmail dot com email: parham90 at GMail dot com Richard Heyes rich...@php.net wrote in message news:af8726440908020221r22e1efb3g321ba4140bfa4...@mail.gmail.com... Hi, ... You can write a single byte to the file to increment the counter, then to read the count just use filesize(). I believe the a fopen() mode will handle locking for you. It will result in a slowly growing file, but space isn't exactly at a premium nowadays, and when the file gets to a certain size (eg 1 gazillion k) you could use a summary file. -- Richard Heyes HTML5 graphing: RGraph - www.rgraph.net (updated 25th July) Lots of PHP and Javascript code - http://www.phpguru.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Problem: Writing into Files?
I don't quite know how I can write a bite into a file. I also looked into a manual and couldn't find a mention of FLock-ing in the explaination for FOpen parameters. Ok, from memory: ?php fwrite(fopen('/tmp/counter', 'a'), '1'); ? The 1 could be any single byte character I guess. -- Richard Heyes HTML5 graphing: RGraph - www.rgraph.net (updated 25th July) Lots of PHP and Javascript code - http://www.phpguru.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problem: Writing into Files?
On Sat, 01 Aug 2009 08:20:23 +0300, Parham Doustdar parha...@gmail.com wrote: Hi there, I've written a counter for my blog, which keeps the count of visitors in a file. However, when the visitors get too many, it resets to zero. Why? Here's the piece of code: [code] $f = $dir . '/view_counter' .EXT; $fp = fopen($f, r); $count =fgets($fp, 1024); fclose($fp); $fw = fopen($f, w); $cnew = $count + 1; $countnew = fputs($fw, $count + 1); return $cnew; [/code] I'm thinking this is caused by two visitors visiting the page at the same time; but is there a way to fix it, perhaps the reading/writing parameter? Thanks! Check: http://www.php.net/flock -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problem: Writing into Files?
Dear Ollisso, I tried it with FLock() but it still didn't work. This is what I did: [code] $fp = fopen($f, r); $count =fgets($fp, 1024); fclose($fp); $fw = fopen($f, w); while (!flock($fw, LOCK_EX)) sleep(1); $cnew = $count + 1; $countnew = fputs($fw, $count + 1); flock($fw, LOCK_UN); fclose($fw); [/code] Am I doing anything wrong here? Thanks! -- --- Contact info: Skype: parham-d MSN: fire_lizard16 at hotmail dot com email: parham90 at GMail dot com Ollisso olli...@fromru.com wrote in message news:op.uxy29woc48v...@ol-n.kyla.fi... On Sat, 01 Aug 2009 08:20:23 +0300, Parham Doustdar parha...@gmail.com wrote: Hi there, I've written a counter for my blog, which keeps the count of visitors in a file. However, when the visitors get too many, it resets to zero. Why? Here's the piece of code: [code] $f = $dir . '/view_counter' .EXT; $fp = fopen($f, r); $count =fgets($fp, 1024); fclose($fp); $fw = fopen($f, w); $cnew = $count + 1; $countnew = fputs($fw, $count + 1); return $cnew; [/code] I'm thinking this is caused by two visitors visiting the page at the same time; but is there a way to fix it, perhaps the reading/writing parameter? Thanks! Check: http://www.php.net/flock -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problem with fetching values...
Am 2008-12-28 16:11:15, schrieb Nathan Nobbe: OK. i would stop right there and ask yourself why.. there are tons of stable, working solutions out there that already do this, most notably for php5, PDO, http://us.php.net/manual/en/pdo.drivers.php which btw, is written in C ;) I have tried to test it... The problem is now, that none of my 4 Hosting provider support it. :-/ Thanks, Greetings and nice Day/Evening Michelle Konzack Systemadministrator 24V Electronic Engineer Tamay Dogan Network Debian GNU/Linux Consultant -- Linux-User #280138 with the Linux Counter, http://counter.li.org/ # Debian GNU/Linux Consultant # http://www.tamay-dogan.net/ http://www.can4linux.org/ Michelle Konzack Apt. 917 ICQ #328449886 +49/177/935194750, rue de Soultz MSN LinuxMichi +33/6/61925193 67100 Strasbourg/France IRC #Debian (irc.icq.com) signature.pgp Description: Digital signature
Re: [PHP] Re: Problem with fetching values...
On Monday 29 December 2008 2:26:46 am Michelle Konzack wrote: Am 2008-12-28 16:11:15, schrieb Nathan Nobbe: OK. i would stop right there and ask yourself why.. there are tons of stable, working solutions out there that already do this, most notably for php5, PDO, http://us.php.net/manual/en/pdo.drivers.php which btw, is written in C ;) I have tried to test it... The problem is now, that none of my 4 Hosting provider support it. :-/ Then you seriously need new hosting providers. PDO is part of the standard install for PHP5, and there is simply no excuse for a web host to not support it. You can try contacting them first to ask them to enable it, and if they say no, you say go away. Really, that's simply irresponsible on their part. -- Larry Garfield la...@garfieldtech.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problem with fetching values...
Am 2008-12-29 22:09:16, schrieb chris smith: So, PostgreSQL catch the array by name pg_fetch_array($db_query, null, PGSQL_ASSOC) and MySQL use the position mysql_fetch_array($db_query, MYSQL_NUM) Why? http://www.php.net/mysql_fetch_array Use MYSQL_ASSOC as the 2nd param, or leave it out and by default it uses BOTH. Argh!!! Asshole !!! (me) -- I have not seen the tree in the wood! Thanks, Greetings and nice Day/Evening Michelle Konzack Systemadministrator 24V Electronic Engineer Tamay Dogan Network Debian GNU/Linux Consultant -- Linux-User #280138 with the Linux Counter, http://counter.li.org/ # Debian GNU/Linux Consultant # http://www.tamay-dogan.net/ http://www.can4linux.org/ Michelle Konzack Apt. 917 ICQ #328449886 +49/177/935194750, rue de Soultz MSN LinuxMichi +33/6/61925193 67100 Strasbourg/France IRC #Debian (irc.icq.com) signature.pgp Description: Digital signature
Re: [PHP] Re: Problem with fetching values...
On Mon, Dec 29, 2008 at 7:57 AM, Michelle Konzack linux4miche...@tamay-dogan.net wrote: Am 2008-12-29 22:09:16, schrieb chris smith: So, PostgreSQL catch the array by name pg_fetch_array($db_query, null, PGSQL_ASSOC) and MySQL use the position mysql_fetch_array($db_query, MYSQL_NUM) Why? http://www.php.net/mysql_fetch_array Use MYSQL_ASSOC as the 2nd param, or leave it out and by default it uses BOTH. Argh!!! Asshole !!! (me) -- I have not seen the tree in the wood! Thanks, Greetings and nice Day/Evening Michelle Konzack Systemadministrator 24V Electronic Engineer Tamay Dogan Network Debian GNU/Linux Consultant -- Linux-User #280138 with the Linux Counter, http://counter.li.org/ # Debian GNU/Linux Consultant # http://www.tamay-dogan.net/ http://www.can4linux.org/ Michelle Konzack Apt. 917 ICQ #328449886 +49/177/935194750, rue de Soultz MSN LinuxMichi +33/6/61925193 67100 Strasbourg/France IRC #Debian (irc.icq.com) FWIW you can also use mysql_fetch_assoc http://us2.php.net/mysql_fetch_assoc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Problem changing file encoding
Thodoris wrote: Hi guys, I am developing a project and I wrote an interface to import contracts in it. The problem is that when the user uploads the file I don't know what is the encoding it has. So I decided that a good idea is to make the user tell me the encoding from a drop down before I parse the file. Then I could probably change the encoding with iconv and use it to validate the data and make the inserts in mysql. Although in the unix world I have available the iconv command and I can change the file to the new encoding like this: iconv -f CP737 -t UTF-8 -o newfile.csv original_file.csv I can't find a way to do this from within php. Iconv support gives me some options but only to convert strings and there is not a way AFAIK to get all the supported encodings from the system as I can do in command line with this: iconv --list Is this the best way to do this ? Can I use mbstring as an alternative ? Please make any suggestions you might think because I am stuck. made this a while back.. might help :) http://programphp.com/iconv.phps Thanks Natham this is a nice approach and it certainly helps. -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problem changing file encoding
Thodoris wrote: Hi guys, I am developing a project and I wrote an interface to import contracts in it. The problem is that when the user uploads the file I don't know what is the encoding it has. So I decided that a good idea is to make the user tell me the encoding from a drop down before I parse the file. Then I could probably change the encoding with iconv and use it to validate the data and make the inserts in mysql. Although in the unix world I have available the iconv command and I can change the file to the new encoding like this: iconv -f CP737 -t UTF-8 -o newfile.csv original_file.csv I can't find a way to do this from within php. Iconv support gives me some options but only to convert strings and there is not a way AFAIK to get all the supported encodings from the system as I can do in command line with this: iconv --list Is this the best way to do this ? Can I use mbstring as an alternative ? Please make any suggestions you might think because I am stuck. made this a while back.. might help :) http://programphp.com/iconv.phps -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Problem with memory management
Problem with memory management I sure know that feeling... :-/ -- Richard Heyes HTML5 Graphing for FF, Chrome, Opera and Safari: http://www.rgraph.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Problem with memory management
Richard Heyes wrote: Problem with memory management I sure know that feeling... :-/ So, there is no other choice that waiting a new PHP release ? -- Alan Boudreault Mapgears http://www.mapgears.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Problem with memory management
On Sat, Oct 11, 2008 at 1:58 PM, Alan Boudreault [EMAIL PROTECTED] wrote: Richard Heyes wrote: Problem with memory management I sure know that feeling... :-/ So, there is no other choice that waiting a new PHP release ? -- Alan Boudreault Mapgears http://www.mapgears.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Are you actually having a real problem here other than just looking at the memory usage function? Or are you just trying to get an idea for how much power this app is going to need? Perhaps maybe you can do some pre-generation of the heavier parts of this app before it is used in a front-end script. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Problem with memory management
Eric Butera wrote: On Sat, Oct 11, 2008 at 1:58 PM, Alan Boudreault [EMAIL PROTECTED] wrote: Richard Heyes wrote: Problem with memory management I sure know that feeling... :-/ So, there is no other choice that waiting a new PHP release ? -- Alan Boudreault Mapgears http://www.mapgears.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Are you actually having a real problem here other than just looking at the memory usage function? Or are you just trying to get an idea for how much power this app is going to need? Perhaps maybe you can do some pre-generation of the heavier parts of this app before it is used in a front-end script. I don't have a REAL PROBLEM. We made an extension for PHP for web mapping that uses GIS data. GIS data can be large sometime and some scripts can easily use a lot of memory for big data process. (We don't control how our clients use our extension) So... i don't have a real problem at the moment... but not beeing able to free the memory when we need/want it is obviously a problem. I was just trying to understand this behavior. Thanks Alan -- Alan Boudreault Mapgears http://www.mapgears.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problem with memory management
Alan Boudreault wrote: Hi all, I'm wondering why PHP doesn't free my memory with this test code. The memory usage is always the same even if i unset my object. The Garbage collector seems to only free the memory at the end of the script. Here's the php Scripts that i use for testing: ?php //dl(php_mapscript.so); function test() { $oShapeFile = ms_newShapefileObj( /opt/www/bdga/msp/data/bdga/BDGA_HYDRO_S_POLY.shp, -1); echo before getShape : .memory_get_usage(true).\n; for ($i=0; $i$oShapeFile-numshapes;$i++) { $oShape = $oShapeFile-getShape($i); $oShape-free(); unset($oShape); $oShape = NULL; } echo after getShape : .memory_get_usage(true).\n; $oShapeFile-free(); unset($oShapeFile); $oShapeFile = null; echo after free : .memory_get_usage(true).\n; } echo start : .memory_get_usage(true).\n; test(); echo end : .memory_get_usage(true).\n; ? Output result: start : 262144 before getShape : 262144 after getShape : 11010048 after free : 11010048 end : 11010048 I've also run valgrind to be sure that is not my extension that doesn't free its memory: $ valgrind --leak-check=full php -f shapeTest.php ==18730== LEAK SUMMARY: ==18730==definitely lost: 0 bytes in 0 blocks. ==18730== possibly lost: 0 bytes in 0 blocks. ==18730==still reachable: 240 bytes in 2 blocks. ==18730== suppressed: 0 bytes in 0 blocks. Thanks, Alan interesting, I'm finding the same thing in one of my atom feed parsers; over time no matter how much I unset / truncate variables the memory usage stills grows over time - at this time I can't find any way to bring it right down; on a timer the whole script resets and restarts itself; one thing I have noticed is that I can see the emalloc memory usage report dropping and rising [memory_get_usage( false );], but still rising over time.. hope this wasn't a hijack; just here trying to figure out the same problem at the minute! Regards.. Nathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Problem with memory management
On Fri, Oct 10, 2008 at 3:32 PM, Nathan Rixham [EMAIL PROTECTED] wrote: Alan Boudreault wrote: Hi all, I'm wondering why PHP doesn't free my memory with this test code. The memory usage is always the same even if i unset my object. The Garbage collector seems to only free the memory at the end of the script. Here's the php Scripts that i use for testing: ?php //dl(php_mapscript.so); function test() { $oShapeFile = ms_newShapefileObj( /opt/www/bdga/msp/data/bdga/BDGA_HYDRO_S_POLY.shp, -1); echo before getShape : .memory_get_usage(true).\n; for ($i=0; $i$oShapeFile-numshapes;$i++) { $oShape = $oShapeFile-getShape($i); $oShape-free(); unset($oShape); $oShape = NULL; } echo after getShape : .memory_get_usage(true).\n; $oShapeFile-free(); unset($oShapeFile); $oShapeFile = null; echo after free : .memory_get_usage(true).\n; } echo start : .memory_get_usage(true).\n; test(); echo end : .memory_get_usage(true).\n; ? Output result: start : 262144 before getShape : 262144 after getShape : 11010048 after free : 11010048 end : 11010048 I've also run valgrind to be sure that is not my extension that doesn't free its memory: $ valgrind --leak-check=full php -f shapeTest.php ==18730== LEAK SUMMARY: ==18730==definitely lost: 0 bytes in 0 blocks. ==18730== possibly lost: 0 bytes in 0 blocks. ==18730==still reachable: 240 bytes in 2 blocks. ==18730== suppressed: 0 bytes in 0 blocks. Thanks, Alan interesting, I'm finding the same thing in one of my atom feed parsers; over time no matter how much I unset / truncate variables the memory usage stills grows over time - at this time I can't find any way to bring it right down; on a timer the whole script resets and restarts itself; one thing I have noticed is that I can see the emalloc memory usage report dropping and rising [memory_get_usage( false );], but still rising over time.. hope this wasn't a hijack; just here trying to figure out the same problem at the minute! Regards.. Nathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I think the engine doesn't really worry about freeing memory until it has to. Or was this only on circular references? I remember there was that whole GSOC project to implement garbage collection, but it never got implemented. Maybe someone who really knows will chime in. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Problem with memory management
Eric Butera wrote: On Fri, Oct 10, 2008 at 3:32 PM, Nathan Rixham [EMAIL PROTECTED] wrote: Alan Boudreault wrote: Hi all, I'm wondering why PHP doesn't free my memory with this test code. The memory usage is always the same even if i unset my object. The Garbage collector seems to only free the memory at the end of the script. Here's the php Scripts that i use for testing: ?php //dl(php_mapscript.so); function test() { $oShapeFile = ms_newShapefileObj( /opt/www/bdga/msp/data/bdga/BDGA_HYDRO_S_POLY.shp, -1); echo before getShape : .memory_get_usage(true).\n; for ($i=0; $i$oShapeFile-numshapes;$i++) { $oShape = $oShapeFile-getShape($i); $oShape-free(); unset($oShape); $oShape = NULL; } echo after getShape : .memory_get_usage(true).\n; $oShapeFile-free(); unset($oShapeFile); $oShapeFile = null; echo after free : .memory_get_usage(true).\n; } echo start : .memory_get_usage(true).\n; test(); echo end : .memory_get_usage(true).\n; ? Output result: start : 262144 before getShape : 262144 after getShape : 11010048 after free : 11010048 end : 11010048 I've also run valgrind to be sure that is not my extension that doesn't free its memory: $ valgrind --leak-check=full php -f shapeTest.php ==18730== LEAK SUMMARY: ==18730==definitely lost: 0 bytes in 0 blocks. ==18730== possibly lost: 0 bytes in 0 blocks. ==18730==still reachable: 240 bytes in 2 blocks. ==18730== suppressed: 0 bytes in 0 blocks. Thanks, Alan interesting, I'm finding the same thing in one of my atom feed parsers; over time no matter how much I unset / truncate variables the memory usage stills grows over time - at this time I can't find any way to bring it right down; on a timer the whole script resets and restarts itself; one thing I have noticed is that I can see the emalloc memory usage report dropping and rising [memory_get_usage( false );], but still rising over time.. hope this wasn't a hijack; just here trying to figure out the same problem at the minute! Regards.. Nathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I think the engine doesn't really worry about freeing memory until it has to. Or was this only on circular references? I remember there was that whole GSOC project to implement garbage collection, but it never got implemented. Maybe someone who really knows will chime in. you're right; I remember the discussion over on internals 3rd December last year; they made a new gc patch for 5.3; not sure if it got implemented or not.. here's what andy wrote (there followed a massive discussion) [quote] Hi all, Was hoping to send this off earlier but I was travelling for the past week and had very limited email access. As promised in the past few weeks we have spent a significant amount of time in reviewing the garbage collector work and testing it in our performance lab. Dmitry has been exchanging ideas and patches with David Wang during this time. Suffice to say that as I've mentioned in the past, memory management is an extremely sensitive piece of PHP, which is why it was important for us to review this work in great depth before committing it to the code base. The updated patch still retains the same algorithm as David's original implementation however the data structures have been changed in order to work faster and use less memory. The revised patch has the following advantages: - It fixes several crash bugs - Enhances performance by removing several unnecessary checks - The memory overhead was reduced (from 12 to 4 bytes for each heap-allocated zval) - The speed of clean PHP code (code that doesn't create cycles) was improved - Additional test cases were created The end result is a more stable and faster GC patch. That said we have yet to find real-life applications that create significant cycles which would benefit from this patch. In fact as you'll see from the results our tests show an increase in maximum memory use and slower execution (to be fair they are marginal). We have tested both PHP_5_3 without any patches, the original patch and the new patch. The following table shows execution time (seconds for N requests) and slowdown. PHP_5_3 Original GC patch Current GC patch slowdown slowdown bench 11,550 12,310 6,58% 12,170 5,37% hello 8,781 8,852 0,81% 8,813 0,36% xoops 128,500 135,100 5,14% 130,200 1,32% static 18,540 20,840 12,41% 18,920 2,05% qdig 29,320 30,270 3,24% 29,610 0,99% qdig2 13,960 14,100 1,00% 14,090 0,93% The next table shows memory usage in MB and overhead PHP_5_3 Original GC patch Current GC patch overhead overhead hello 13,750 13,945 1,42% 13,765 0,11% xoops 18,036 18,636 3,33% 18,568 2,95% static 15,300 16,000 4,58% 15,308 0,05% qdig 14,820 15,008 1,27% 14,828 0,05% qdig2 14,824 15,012 1,27% 14,838 0,09% To summarize
[PHP] Re: problem with slash / characters
Tanner Postert wrote: ignore previous. sorry. I'm trying to display values from a database, the values come from the database like this: [0] = Array ( [id] = 5 [order_id] = 10 [key] = ship_to_name [value] = John Anderson ) [1] = Array ( [id] = 6 [order_id] = 10 [key] = ship_to_address [value] = c/o Company XYZ ) etc. so i am rolling thru that array and making a new array by: foreach ( $data as $k = $v ) { $new[$v['key']] = $v['value']; } so that i have 1 array. The problem is that somewhere along the way the string c/o Company XYZ is becoming c/1 Company XYZ. I added a print_r after every iteration to see what its looking like along the way: foreach( $data as $k=$v ) { error_log( new . $v['key'] . = . $v['value'] ); $new[$v['key']] = $v['value']; error_log( print_r( $new, true ) ); } and I get: new ship_to_name = Gordon Anderson Array ( [ship_to_name] = Gordon Anderson ) new ship_to_address = c/o Company XYZ Array ( [ship_to_name] = Gordon Anderson [ship_to_address] = c/o Company XYZ ) new ship_to_address_2 = 1100 S Baldwin Array ( [ship_to_name] = Gordon Anderson [ship_to_address] = c/o Company XYZ [ship_to_address_2] = 1100 S Baldwin ) new ship_to_city = Oxford Array ( [ship_to_name] = Gordon Anderson [ship_to_address] = c/1 Company XYZ [ship_to_address_2] = 1100 S Baldwin [ship_to_city] = Oxford ) ... and it looks the same for the remaining iterations. how did the string change in the middle of that for loop? This also only happens on one machine. the production environment, which his Redhat, it doesn't happen on my development env, which is Fedora 9. Thanks in advance. What happens if you change the / to another character, e.g., #? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: problem with slash / characters
very, strange. if I change it to c / o Company XYZ ( with spaces between each character) it becomes: c 1 o Company XYZ. if I change it to c#o Company XYZ it becomes c1o Company XYZ On Wed, Oct 1, 2008 at 12:16 PM, Al [EMAIL PROTECTED] wrote: Tanner Postert wrote: ignore previous. sorry. I'm trying to display values from a database, the values come from the database like this: [0] = Array ( [id] = 5 [order_id] = 10 [key] = ship_to_name [value] = John Anderson ) [1] = Array ( [id] = 6 [order_id] = 10 [key] = ship_to_address [value] = c/o Company XYZ ) etc. so i am rolling thru that array and making a new array by: foreach ( $data as $k = $v ) { $new[$v['key']] = $v['value']; } so that i have 1 array. The problem is that somewhere along the way the string c/o Company XYZ is becoming c/1 Company XYZ. I added a print_r after every iteration to see what its looking like along the way: foreach( $data as $k=$v ) { error_log( new . $v['key'] . = . $v['value'] ); $new[$v['key']] = $v['value']; error_log( print_r( $new, true ) ); } and I get: new ship_to_name = Gordon Anderson Array ( [ship_to_name] = Gordon Anderson ) new ship_to_address = c/o Company XYZ Array ( [ship_to_name] = Gordon Anderson [ship_to_address] = c/o Company XYZ ) new ship_to_address_2 = 1100 S Baldwin Array ( [ship_to_name] = Gordon Anderson [ship_to_address] = c/o Company XYZ [ship_to_address_2] = 1100 S Baldwin ) new ship_to_city = Oxford Array ( [ship_to_name] = Gordon Anderson [ship_to_address] = c/1 Company XYZ [ship_to_address_2] = 1100 S Baldwin [ship_to_city] = Oxford ) ... and it looks the same for the remaining iterations. how did the string change in the middle of that for loop? This also only happens on one machine. the production environment, which his Redhat, it doesn't happen on my development env, which is Fedora 9. Thanks in advance. What happens if you change the / to another character, e.g., #? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: problem with slash / characters
just did some further testing, and even if I remove the special characters, the 3rd character in that string becomes a 1. I change it to Company XYZ, and it looks right when its assigned to the array the first time, and on the next iteration of the loop. but after that, it looks lke Co1pany XYZ. On Wed, Oct 1, 2008 at 12:18 PM, Tanner Postert [EMAIL PROTECTED]wrote: very, strange. if I change it to c / o Company XYZ ( with spaces between each character) it becomes: c 1 o Company XYZ. if I change it to c#o Company XYZ it becomes c1o Company XYZ On Wed, Oct 1, 2008 at 12:16 PM, Al [EMAIL PROTECTED] wrote: Tanner Postert wrote: ignore previous. sorry. I'm trying to display values from a database, the values come from the database like this: [0] = Array ( [id] = 5 [order_id] = 10 [key] = ship_to_name [value] = John Anderson ) [1] = Array ( [id] = 6 [order_id] = 10 [key] = ship_to_address [value] = c/o Company XYZ ) etc. so i am rolling thru that array and making a new array by: foreach ( $data as $k = $v ) { $new[$v['key']] = $v['value']; } so that i have 1 array. The problem is that somewhere along the way the string c/o Company XYZ is becoming c/1 Company XYZ. I added a print_r after every iteration to see what its looking like along the way: foreach( $data as $k=$v ) { error_log( new . $v['key'] . = . $v['value'] ); $new[$v['key']] = $v['value']; error_log( print_r( $new, true ) ); } and I get: new ship_to_name = Gordon Anderson Array ( [ship_to_name] = Gordon Anderson ) new ship_to_address = c/o Company XYZ Array ( [ship_to_name] = Gordon Anderson [ship_to_address] = c/o Company XYZ ) new ship_to_address_2 = 1100 S Baldwin Array ( [ship_to_name] = Gordon Anderson [ship_to_address] = c/o Company XYZ [ship_to_address_2] = 1100 S Baldwin ) new ship_to_city = Oxford Array ( [ship_to_name] = Gordon Anderson [ship_to_address] = c/1 Company XYZ [ship_to_address_2] = 1100 S Baldwin [ship_to_city] = Oxford ) ... and it looks the same for the remaining iterations. how did the string change in the middle of that for loop? This also only happens on one machine. the production environment, which his Redhat, it doesn't happen on my development env, which is Fedora 9. Thanks in advance. What happens if you change the / to another character, e.g., #? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: problem with slash / characters
figured it out. later on in the code theres some formatting for a specific values that the address_2 field was accidentally falling into. On Wed, Oct 1, 2008 at 12:24 PM, Tanner Postert [EMAIL PROTECTED]wrote: just did some further testing, and even if I remove the special characters, the 3rd character in that string becomes a 1. I change it to Company XYZ, and it looks right when its assigned to the array the first time, and on the next iteration of the loop. but after that, it looks lke Co1pany XYZ. On Wed, Oct 1, 2008 at 12:18 PM, Tanner Postert [EMAIL PROTECTED]wrote: very, strange. if I change it to c / o Company XYZ ( with spaces between each character) it becomes: c 1 o Company XYZ. if I change it to c#o Company XYZ it becomes c1o Company XYZ On Wed, Oct 1, 2008 at 12:16 PM, Al [EMAIL PROTECTED] wrote: Tanner Postert wrote: ignore previous. sorry. I'm trying to display values from a database, the values come from the database like this: [0] = Array ( [id] = 5 [order_id] = 10 [key] = ship_to_name [value] = John Anderson ) [1] = Array ( [id] = 6 [order_id] = 10 [key] = ship_to_address [value] = c/o Company XYZ ) etc. so i am rolling thru that array and making a new array by: foreach ( $data as $k = $v ) { $new[$v['key']] = $v['value']; } so that i have 1 array. The problem is that somewhere along the way the string c/o Company XYZ is becoming c/1 Company XYZ. I added a print_r after every iteration to see what its looking like along the way: foreach( $data as $k=$v ) { error_log( new . $v['key'] . = . $v['value'] ); $new[$v['key']] = $v['value']; error_log( print_r( $new, true ) ); } and I get: new ship_to_name = Gordon Anderson Array ( [ship_to_name] = Gordon Anderson ) new ship_to_address = c/o Company XYZ Array ( [ship_to_name] = Gordon Anderson [ship_to_address] = c/o Company XYZ ) new ship_to_address_2 = 1100 S Baldwin Array ( [ship_to_name] = Gordon Anderson [ship_to_address] = c/o Company XYZ [ship_to_address_2] = 1100 S Baldwin ) new ship_to_city = Oxford Array ( [ship_to_name] = Gordon Anderson [ship_to_address] = c/1 Company XYZ [ship_to_address_2] = 1100 S Baldwin [ship_to_city] = Oxford ) ... and it looks the same for the remaining iterations. how did the string change in the middle of that for loop? This also only happens on one machine. the production environment, which his Redhat, it doesn't happen on my development env, which is Fedora 9. Thanks in advance. What happens if you change the / to another character, e.g., #? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Problem with sorting
On Sep 21, 2008, at 2:24 PM, Eric Butera wrote: On Sun, Sep 21, 2008 at 3:26 PM, Ashley Sheridan [EMAIL PROTECTED] wrote: On Sun, 2008-09-21 at 15:21 -0400, Eric Butera wrote: On Sun, Sep 21, 2008 at 3:17 PM, Ashley Sheridan [EMAIL PROTECTED] wrote: On Sun, 2008-09-21 at 14:34 -0400, Eric Butera wrote: Michelle Konzack wrote: * Do not Cc: me, because I READ THIS LIST, if I write here * *Keine Cc: am mich, ich LESE DIESE LISTE wenn ich hier schreibe* Cute, get gmail and you won't have such problems. I quite like the double emails thing, it makes me feel like I'm more popular :p Ash www.ashleysheridan.co.uk I could also always bcc replies to you so you get three. How great would that be? :D Wow, I'd be like really popular if everyone did that! Does this really mean that I need to get out more and make friends outside of the Interweb?! Ash www.ashleysheridan.co.uk No, the fact we're having this exchange on a Sunday is an indicator. :( *sigh* LOL! ~Phil PS... This was read and replied to on a Monday. =P -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Problem with sorting
On Mon, Sep 22, 2008 at 10:42 AM, Philip Thompson [EMAIL PROTECTED] wrote: LOL! ~Phil PS... This was read and replied to on a Monday. =P *golf clap* -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problem with sorting
Michelle Konzack wrote: * Do not Cc: me, because I READ THIS LIST, if I write here * *Keine Cc: am mich, ich LESE DIESE LISTE wenn ich hier schreibe* Hello, I have a Database of µChips and I want to sort it case insensitive and in numerical order in the same time. Since the name of the µChips are mostly [:alpha:][:num:]* I am running into problems since the first one can have 0-5 characters. So, what I need is to get the substring (leading [:alpha:]) unify and sort it and not use a loop over it, and get all chips from the category. Now from each category cut the [:alpha:], the sort numerical and after this re-add the cuted [:alpha:]. H, first I am searching a solution the get the Categories, which mean, the leading [:alpha:] AND, if numerical categories exist, there first number. The listing should be something like 3 8 AW AT DS ICL LM MAX W Does somone has a solution for it? (I do not like to reinvent the wheel) Thanks, Greetings and nice Day/Evening Michelle Konzack Systemadministrator 24V Electronic Engineer Tamay Dogan Network Debian GNU/Linux Consultant if it's from a database could you order by substring(columnname, 2,1) or similar..? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Problem with sorting
On Sun, Sep 21, 2008 at 1:19 PM, Nathan Rixham [EMAIL PROTECTED] wrote: Michelle Konzack wrote: * Do not Cc: me, because I READ THIS LIST, if I write here * *Keine Cc: am mich, ich LESE DIESE LISTE wenn ich hier schreibe* Cute, get gmail and you won't have such problems. Thanks, Greetings and nice Day/Evening Michelle Konzack Systemadministrator 24V Electronic Engineer Tamay Dogan Network Debian GNU/Linux Consultant if it's from a database could you order by substring(columnname, 2,1) or similar..? I've done stuff like this before but it is way too slow to be used on anything other than a manager screen (that isn't used much). I'd recommend creating another column that sets your data up correctly for sorting based on your criteria. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Problem with sorting
On Sun, 2008-09-21 at 14:34 -0400, Eric Butera wrote: Michelle Konzack wrote: * Do not Cc: me, because I READ THIS LIST, if I write here * *Keine Cc: am mich, ich LESE DIESE LISTE wenn ich hier schreibe * Cute, get gmail and you won't have such problems. I quite like the double emails thing, it makes me feel like I'm more popular :p Ash www.ashleysheridan.co.uk
Re: [PHP] Re: Problem with sorting
On Sun, Sep 21, 2008 at 3:17 PM, Ashley Sheridan [EMAIL PROTECTED] wrote: On Sun, 2008-09-21 at 14:34 -0400, Eric Butera wrote: Michelle Konzack wrote: * Do not Cc: me, because I READ THIS LIST, if I write here * *Keine Cc: am mich, ich LESE DIESE LISTE wenn ich hier schreibe* Cute, get gmail and you won't have such problems. I quite like the double emails thing, it makes me feel like I'm more popular :p Ash www.ashleysheridan.co.uk I could also always bcc replies to you so you get three. How great would that be? :D -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Problem with sorting
On Sun, 2008-09-21 at 15:21 -0400, Eric Butera wrote: On Sun, Sep 21, 2008 at 3:17 PM, Ashley Sheridan [EMAIL PROTECTED] wrote: On Sun, 2008-09-21 at 14:34 -0400, Eric Butera wrote: Michelle Konzack wrote: * Do not Cc: me, because I READ THIS LIST, if I write here * *Keine Cc: am mich, ich LESE DIESE LISTE wenn ich hier schreibe* Cute, get gmail and you won't have such problems. I quite like the double emails thing, it makes me feel like I'm more popular :p Ash www.ashleysheridan.co.uk I could also always bcc replies to you so you get three. How great would that be? :D Wow, I'd be like really popular if everyone did that! Does this really mean that I need to get out more and make friends outside of the Interweb?! Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Problem with sorting
On Sun, Sep 21, 2008 at 3:26 PM, Ashley Sheridan [EMAIL PROTECTED] wrote: On Sun, 2008-09-21 at 15:21 -0400, Eric Butera wrote: On Sun, Sep 21, 2008 at 3:17 PM, Ashley Sheridan [EMAIL PROTECTED] wrote: On Sun, 2008-09-21 at 14:34 -0400, Eric Butera wrote: Michelle Konzack wrote: * Do not Cc: me, because I READ THIS LIST, if I write here * *Keine Cc: am mich, ich LESE DIESE LISTE wenn ich hier schreibe* Cute, get gmail and you won't have such problems. I quite like the double emails thing, it makes me feel like I'm more popular :p Ash www.ashleysheridan.co.uk I could also always bcc replies to you so you get three. How great would that be? :D Wow, I'd be like really popular if everyone did that! Does this really mean that I need to get out more and make friends outside of the Interweb?! Ash www.ashleysheridan.co.uk No, the fact we're having this exchange on a Sunday is an indicator. :( *sigh* -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Problem with sorting
On Sun, 2008-09-21 at 15:24 -0400, Eric Butera wrote: On Sun, Sep 21, 2008 at 3:26 PM, Ashley Sheridan [EMAIL PROTECTED] wrote: On Sun, 2008-09-21 at 15:21 -0400, Eric Butera wrote: On Sun, Sep 21, 2008 at 3:17 PM, Ashley Sheridan [EMAIL PROTECTED] wrote: On Sun, 2008-09-21 at 14:34 -0400, Eric Butera wrote: Michelle Konzack wrote: * Do not Cc: me, because I READ THIS LIST, if I write here * *Keine Cc: am mich, ich LESE DIESE LISTE wenn ich hier schreibe * Cute, get gmail and you won't have such problems. I quite like the double emails thing, it makes me feel like I'm more popular :p Ash www.ashleysheridan.co.uk I could also always bcc replies to you so you get three. How great would that be? :D Wow, I'd be like really popular if everyone did that! Does this really mean that I need to get out more and make friends outside of the Interweb?! Ash www.ashleysheridan.co.uk No, the fact we're having this exchange on a Sunday is an indicator. :( *sigh* Bugger, it's official then... :'-( Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problem with function
Jason Pruim wrote: So, I am fighting with a problem function... I have used this function on a previous project and it worked just fine, so I'm not sure what changed... The only difference is that on this site, I'm using mod_rewrite to write all non-existent folder requests into a php file to process what to do with it. here's some code: processing file: ?PHP require(php.ini.php); require(dbmysqliconnect.php); require(defaults.php); require(notify_email.php); $link = dbmysqliconnect($server, $username, $password, $database, $link); $date = time(); //Do NOT insert or update sales rep database through this method... Only included to be supplied to the notify_email function. JP $salesRepID = $_POST['txtSalesRepID']; $Record= $_POST['txtRecord']; notify_email($Record, $salesRepID); $stmt = mysqli_stmt_init($link); //Create the statement mysqli_stmt_prepare($stmt, UPDATE purl.schreur SET FName = ?, LName = ?, email = ?, phone = ?, record = ?, subscribed = ?, date = ?, IPAddress = ?, Business = ?, Address1 = ?, City = ?, State = ?, Zip = ?, Coffee = ?, Meeting = ?, time = ?) or die(prepare error . mysqli_error($link)); mysqli_stmt_bind_param($stmt, '', $_POST['txtFName'], $_POST['txtLName'], $_POST['txtEmail'], $_POST['txtPhone'], $_POST['record'], $_POST['subscribed'], $date, $_SERVER['REMOTE_ADDR'], $_POST['txtBusiness'], $_POST['txtAddress1'], $_POST['txtCity'], $_POST['txtState'], $_POST['txtZip'], $_POST['rdoCoffee'], $_POST['rdoTime'], $_POST['areaPlans']) or die( bind error . mysqli_error($link)); //Add the record mysqli_stmt_execute($stmt) or die( execute error . mysqli_error($link)); ? notify_email.php file: ?PHP function notify_email($Record, $salesRepID) { require(defaults.php); require(func.sendemail.php); require(dbmysqliconnect.php); $salesRep = array(1 = [EMAIL PROTECTED], [EMAIL PROTECTED], 2 = [EMAIL PROTECTED], [EMAIL PROTECTED], 3 =[EMAIL PROTECTED], 4=[EMAIL PROTECTED]); echo 1; $link1 = dbmysqliconnect($server, $username, $password, $database, $link); echo 2; $sql = SELECT * FROM schreur WHERE record='{$Record}'; $row[] = mysqli_query($link1, $sql) or die(Could not perform query: .mysqli_errno($link1)); echo 3; $result = $row[0]; echo 4; //$dataSet = array(); //while ($row = mysqli_fetch_assoc($result)) { //echo brwhileBR; //$dataSet[] = $row; //} $from= [EMAIL PROTECTED]; echo 5; $returnPath = [EMAIL PROTECTED]; $replyTo = [EMAIL PROTECTED]; echo $Record; echo 6; //echo brJust before while in notify_email.phpbr; //echo brdirectly above whilebr; //echo BRdataset print: ; //print_r($dataSet); //echo BR; //echo brdirectly above foreachbr; //foreach ( $dataSet AS $row ) { echo 6; while ($row = mysqli_fetch_assoc($result)) { echo inside while; //Build the e-mail headers $ID = $row['salesRep']; $to = $salesRep[$ID]; $headers = From: .$from.\n; $headers .= Return-Path: .$returnPath.\n; $headers .= Reply-To: .$replyTo.\n; $subject = {$row['FName']} wants coffee!; $message = First Name: {$row['FName']} \n; $message .= Last Name: {$row['LName']}\n; $message .= Company . $row['Business'] . \n; $message .= Email: .$row['email'] . \n; $message .= Phone: .$row['phone'] . \n; $message .= Address: . $row['Address1'] . \n; $message .= City: . $row['City'] . \n; $message .= State: .$row['State'] . \n; $message .= Zip: . $row['Zip'] . \n; $message .= Coffee of choice: .$row['Coffee'] . \n\n; $message .= When a good time would be: \n.$row['Meeting'] . \n\n; $message .= Current plans: \n\n;
Re: [PHP] Re: Problem with function
On Sep 12, 2008, at 8:53 AM, Nathan Rixham wrote: Jason Pruim wrote: nothing obvious to me.. so debug more! ?PHP function notify_email($Record, $salesRepID) { echo in notify_email . PHP_EOL; require(defaults.php); echo already loaded and required defaults loaded . PHP_EOL; require(func.sendemail.php); echo require func.sendemail.php loaded . PHP_EOL; require(dbmysqliconnect.php); echo already loaded and required dbmysqliconnect loaded . PHP_EOL; will tell you where it's breaking I'd assume.. Okay, when I had that in the notify_email.php file it looked like it all loaded just fine... the echo's were displayed. When I put that in my process.php file I got this output: already loaded and required defaults loaded Just before send_email functionjust after send_email funtion require func.sendemail.php loaded already loaded and required dbmysqliconnect loaded execute error Duplicate entry '0' for key 1 So I think Jochem might be right... Problem with mysqli? -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Problem with function
On Sep 12, 2008, at 9:21 AM, Jason Pruim wrote: On Sep 12, 2008, at 8:53 AM, Nathan Rixham wrote: Jason Pruim wrote: nothing obvious to me.. so debug more! ?PHP function notify_email($Record, $salesRepID) { echo in notify_email . PHP_EOL; require(defaults.php); echo already loaded and required defaults loaded . PHP_EOL; require(func.sendemail.php); echo require func.sendemail.php loaded . PHP_EOL; require(dbmysqliconnect.php); echo already loaded and required dbmysqliconnect loaded . PHP_EOL; will tell you where it's breaking I'd assume.. Okay, when I had that in the notify_email.php file it looked like it all loaded just fine... the echo's were displayed. When I put that in my process.php file I got this output: already loaded and required defaults loaded Just before send_email functionjust after send_email funtion require func.sendemail.php loaded already loaded and required dbmysqliconnect loaded execute error Duplicate entry '0' for key 1 So I think Jochem might be right... Problem with mysqli? Okay scratch that... I was attempting to update the auto_increment field so when I changed that, it got rid of the error but didn't fix the problem :) -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Problem with function
Jason Pruim wrote: On Sep 12, 2008, at 8:53 AM, Nathan Rixham wrote: Jason Pruim wrote: nothing obvious to me.. so debug more! ?PHP function notify_email($Record, $salesRepID) { echo in notify_email . PHP_EOL; require(defaults.php); echo already loaded and required defaults loaded . PHP_EOL; require(func.sendemail.php); echo require func.sendemail.php loaded . PHP_EOL; require(dbmysqliconnect.php); echo already loaded and required dbmysqliconnect loaded . PHP_EOL; will tell you where it's breaking I'd assume.. Okay, when I had that in the notify_email.php file it looked like it all loaded just fine... the echo's were displayed. When I put that in my process.php file I got this output: already loaded and required defaults loaded Just before send_email functionjust after send_email funtion require func.sendemail.php loaded already loaded and required dbmysqliconnect loaded execute error Duplicate entry '0' for key 1 So I think Jochem might be right... Problem with mysqli? -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com [EMAIL PROTECTED] actually on closer inspection the problem looks here.. following requires 16 params: mysqli_stmt_prepare($stmt, UPDATE purl.schreur SET FName = ?, LName = ?, email = ?, phone = ?, record = ?, subscribed = ?, date = ?, IPAddress = ?, Business = ?, Address1 = ?, City = ?, State = ?, Zip = ?, Coffee = ?, Meeting = ?, time = ?) or die(prepare error . mysqli_error($link)); 17 params bound AND rdoTime + areaPlans are in wrong order or are just wrong.. mysqli_stmt_bind_param($stmt, '', $_POST['txtFName'], $_POST['txtLName'], $_POST['txtEmail'], $_POST['txtPhone'], $_POST['record'], $_POST['subscribed'], $date, $_SERVER['REMOTE_ADDR'], $_POST['txtBusiness'], $_POST['txtAddress1'], $_POST['txtCity'], $_POST['txtState'], $_POST['txtZip'], $_POST['rdoCoffee'], $_POST['rdoTime'], $_POST['areaPlans']) or die( bind error . mysqli_error($link)); may help; probable causing the duplciate error problem; (doesn't explain first error though) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Problem with function
Nathan Rixham wrote: Jason Pruim wrote: On Sep 12, 2008, at 8:53 AM, Nathan Rixham wrote: Jason Pruim wrote: nothing obvious to me.. so debug more! [snip snip snip] have to say this: error_reporting( E_ALL ); at the top would help; + display_errors on in php.ini and problem is probably due to duplciate variable/constant definition in default.php or dbmysqliconnect.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Problem with function
On Sep 12, 2008, at 9:34 AM, Nathan Rixham wrote: Nathan Rixham wrote: Jason Pruim wrote: On Sep 12, 2008, at 8:53 AM, Nathan Rixham wrote: Jason Pruim wrote: nothing obvious to me.. so debug more! [snip snip snip] have to say this: error_reporting( E_ALL ); at the top would help; + display_errors on in php.ini and problem is probably due to duplciate variable/ constant definition in default.php or dbmysqliconnect.php I could agree more... which is why I have this: ini_set('error_reporting', E_ALL); But the log isn't showing anything... My error log for the site has this: [Fri Sep 12 09:40:54 2008] [debug] mod_rewrite.c(1643): [client 192.168.0.253] mod_rewrite's internal redirect status: 0/10. -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Problem with function
Jason Pruim schreef: On Sep 12, 2008, at 9:34 AM, Nathan Rixham wrote: Nathan Rixham wrote: Jason Pruim wrote: On Sep 12, 2008, at 8:53 AM, Nathan Rixham wrote: Jason Pruim wrote: nothing obvious to me.. so debug more! [snip snip snip] have to say this: error_reporting( E_ALL ); at the top would help; + display_errors on in php.ini and problem is probably due to duplciate variable/constant definition in default.php or dbmysqliconnect.php I could agree more... which is why I have this: ini_set('error_reporting', E_ALL); But the log isn't showing anything... php.ini is what he said. My error log for the site has this: [Fri Sep 12 09:40:54 2008] [debug] mod_rewrite.c(1643): [client 192.168.0.253] mod_rewrite's internal redirect status: 0/10. -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Problem with function
On Sep 12, 2008, at 9:46 AM, Jochem Maas wrote: Jason Pruim schreef: On Sep 12, 2008, at 9:34 AM, Nathan Rixham wrote: Nathan Rixham wrote: Jason Pruim wrote: On Sep 12, 2008, at 8:53 AM, Nathan Rixham wrote: Jason Pruim wrote: nothing obvious to me.. so debug more! [snip snip snip] have to say this: error_reporting( E_ALL ); at the top would help; + display_errors on in php.ini and problem is probably due to duplciate variable/ constant definition in default.php or dbmysqliconnect.php I could agree more... which is why I have this: ini_set('error_reporting', E_ALL); But the log isn't showing anything... php.ini is what he said. isn't it the same difference? -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Problem with function
Jochem Maas wrote: Jason Pruim schreef: On Sep 12, 2008, at 9:34 AM, Nathan Rixham wrote: Nathan Rixham wrote: Jason Pruim wrote: On Sep 12, 2008, at 8:53 AM, Nathan Rixham wrote: Jason Pruim wrote: nothing obvious to me.. so debug more! [snip snip snip] have to say this: error_reporting( E_ALL ); at the top would help; + display_errors on in php.ini and problem is probably due to duplciate variable/constant definition in default.php or dbmysqliconnect.php I could agree more... which is why I have this: ini_set('error_reporting', E_ALL); But the log isn't showing anything... php.ini is what he said. My error log for the site has this: [Fri Sep 12 09:40:54 2008] [debug] mod_rewrite.c(1643): [client 192.168.0.253] mod_rewrite's internal redirect status: 0/10. -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com [EMAIL PROTECTED] display_errors in php.ini is what you want; makes life easier while developing; and good to have E_STRICT and E_ALL set for err reporting; then you can catch every tiny potential future bug as well :) ps did you read the one about your bind variables being in the wrong order and too many? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: problem with include directive under XHTML
Robert Huff wrote: I'm working on a project that involves converting HTML to XHTML. Not strictly sure this is a PHP issue, but testing (so far) has eliminated other possibilities. Can someone offer suggestions why, on the same server (Apache 2.2.8), this works: !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01//EN html lang=en-US head link rel=stylesheet type=text/css href=proj_default.css title=ss_default titleTesting html/title /head body script language=php include 'letters/Disclaimer'; /script hr addressa href=mailto:[EMAIL PROTECTED]Robert Huff/a/address !-- Created: Wed Jan 19 10:52:50 EST 2005 -- !-- hhmts start -- Last modified: Mon Jun 2 16:56:19 EDT 2008 !-- hhmts end -- /body /html but this doesn't: ?xml version=1.0 encoding=utf-8? !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.1//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd; html xmlns=http://www.w3.org/1999/xhtml; head titleTesting xhtml/title link rel=stylesheet type=text/css href=proj_default.css title=ss_default / link rel=icon type=image/x-icon href=images/favicon.png / link rel=shortcut icon type=image/x-icon href=images/favicon.png / /head body script type=text/php include 'letters/Disclaimer'; /script hr / addressa href=mailto:[EMAIL PROTECTED]Robert Huff/a/address !-- Created: Wed Jan 19 10:52:50 EST 2005 -- !-- hhmts start -- Last modified: Mon Jun 2 17:37:52 EDT 2008 !-- hhmts end -- /body /html Rspectfully, Robert Huff According to W3Schools (http://www.w3schools.com/TAGS/tag_script.asp) text/php is not a valid type for a script tag. I was never aware of it ever being a valid type for that matter - I would expect the browser to be very confused when it saw that and attempt to parse it as something like Javascript (Which makes me wonder why it even worked at all as I can't find anything about an include function built into Javascript itself). I'd just try this instead, renaming the file to have .php as it's extension so that your server parses it as PHP. ?php include('letters/Disclaimer'); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: problem with for loop
Richard Kurth wrote: Way does my for loop not complete the task if there are 4 emails it only process 3 emails through the foreach loop if there is 3 it only process 2 # Connect up $host =domain.com; $port =110; $mailtype = pop3; $mailbox =INBOX; $username =[EMAIL PROTECTED]; $password =boat1234; $conn = @imap_open({ . $host . : . $port . / . $mailtype . /notls} . $mailbox, $username, $password); $number=imap_num_msg($conn); for($i = 1; $i = $number; $i++) { $file=C:\web\bouncehandler\eml\em$i; imap_savebody($conn,$file,$i); $file=file_get_contents(C:\web\bouncehandler\eml\em$i); $multiArray = Bouncehandler::get_the_facts($file); $EMAIL = $the['recipient']; foreach($multiArray as $the){ switch($the['action']){ case 'failed': $sql=UPDATE contacts SET emailstatus = 'Fatal-Bounced' WHERE emailaddress = '$EMAIL'; mysql_query($sql) or die(Invalid query: . mysql_error()); break; case 'transient': $sql=UPDATE contacts SET emailstatus = 'Bounced' WHERE emailaddress = '$EMAIL'; mysql_query($sql) or die(Invalid query: . mysql_error()); break; case 'autoreply': $sql=UPDATE contacts SET emailstatus = 'Bounced' WHERE emailaddress = '$EMAIL'; mysql_query($sql) or die(Invalid query: . mysql_error()); break; default: //don't do anything break; } } } I think you need to check the boundary conditions on your loop. As you write it, for($i = 1; $i = $number; $i++) if $number is 4 then $i will have the values 1,2,3,4. Perhaps message list is zero-based, and you actually need to count from zero: for($i = 0; $i $number; $i++) so you would get $i to read 0,1,2,3 The manual page doesn't explicitly say the the message number is one-based, and most real programming languages these days use zero-based arrays... -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: problem with for loop
I think Peter is probably right. In the case he is not however, can you post a print_r of $multiArray. - Craige On Fri, May 2, 2008 at 7:24 AM, Peter Ford [EMAIL PROTECTED] wrote: Richard Kurth wrote: Way does my for loop not complete the task if there are 4 emails it only process 3 emails through the foreach loop if there is 3 it only process 2 # Connect up $host =domain.com; $port =110; $mailtype = pop3; $mailbox =INBOX; $username =[EMAIL PROTECTED]; $password =boat1234; $conn = @imap_open({ . $host . : . $port . / . $mailtype . /notls} . $mailbox, $username, $password); $number=imap_num_msg($conn); for($i = 1; $i = $number; $i++) { $file=C:\web\bouncehandler\eml\em$i; imap_savebody($conn,$file,$i); $file=file_get_contents(C:\web\bouncehandler\eml\em$i); $multiArray = Bouncehandler::get_the_facts($file); $EMAIL = $the['recipient']; foreach($multiArray as $the){ switch($the['action']){ case 'failed': $sql=UPDATE contacts SET emailstatus = 'Fatal-Bounced' WHERE emailaddress = '$EMAIL'; mysql_query($sql) or die(Invalid query: . mysql_error()); break; case 'transient': $sql=UPDATE contacts SET emailstatus = 'Bounced' WHERE emailaddress = '$EMAIL'; mysql_query($sql) or die(Invalid query: . mysql_error()); break; case 'autoreply': $sql=UPDATE contacts SET emailstatus = 'Bounced' WHERE emailaddress = '$EMAIL'; mysql_query($sql) or die(Invalid query: . mysql_error()); break; default: //don't do anything break; } } } I think you need to check the boundary conditions on your loop. As you write it, for($i = 1; $i = $number; $i++) if $number is 4 then $i will have the values 1,2,3,4. Perhaps message list is zero-based, and you actually need to count from zero: for($i = 0; $i $number; $i++) so you would get $i to read 0,1,2,3 The manual page doesn't explicitly say the the message number is one-based, and most real programming languages these days use zero-based arrays... -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- 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
[PHP] Re: problem with sessions config.
N . Boatswain wrote: Hello guys; i'm having a problem with session behavior; i'm going straight to it, but first some considerations: PHP Version 5.2.5IIF 5.1Running on localhost (XP machine)I start sessions at the top of every page. A the start of a test page, just as example, i do the assignment: $_SESSION[username] = aaa; At the end of the same page i print it's value: echo $_SESSION[username]; And i get the layout: aaa, as expecteed. Then I redirect to another page. On that one, after initializating the session (session_start();) print again the $_SESSION[username] content and the result is empty. If i try the same code on a server (all this is on my local machine), the code works as expected; so i think it is a configuration problem, here is my php.ini part that correspond to session configuration, so you can tell my if i'm doing anything wrong, long comments where removed: [Session]; Handler used to store/retrieve data.session.save_handler = files;session.save_path = /tmp BC 13/12/07session.save_path=/tmp; Whether to use cookies.session.use_cookies = 1;session.cookie_secure = ; This option enables administrators to make their users invulnerable to; attacks which involve passing session ids in URLs; defaults to 0.session.use_only_cookies = 1; Name of the session (used as cookie name).session.name = PHPSESSID; Initialize session on request startup.session.auto_start = 1; Lifetime in seconds of cookie or, if 0, until browser is restarted.session.cookie_lifetime = 0; The path for which the cookie is valid.session.cookie_path = /; The domain for which the cookie is valid.session.cookie_domain =; Whether or not to add the httpOnly flag to the cookie, which makes it inaccessible to browser scripting languages such as JavaScript.session.cookie_httponly = ; Handler used to serialize data. php is the standard serializer of PHP.session.serialize_ha ndler = php; Define the probability that the 'garbage collection' process is started; on every session initialization.; The probability is calculated by using gc_probability/gc_divisor,; e.g. 1/100 means there is a 1% chance that the GC process starts; on each request.session.gc_probability = 1session.gc_divisor = 1000; After this number of seconds, stored data will be seen as 'garbage' and; cleaned up by the garbage collection process.session.gc_maxlifetime = 1440session.bug_compat_42 = 0session.bug_compat_warn = 1; Check HTTP Referer to invalidate externally stored URLs containing ids.; HTTP_REFERER has to contain this substring for the session to be; considered as valid.session.referer_check =; How many bytes to read from the file.session.entropy_length = 0; Specified here to create the session id.session.entropy_file =;session.entropy_length = 16;session.entropy_file = /dev/urandom; Set to {nocache,private,public,} to determine HTTP caching aspects; or leave this empt y to avoid sending anti-caching headers.session.cache_limiter = nocache; Document expires after n minutes.session.cache_expire = 180session.use_trans_sid = 0; Select a hash function; 0: MD5 (128 bits); 1: SHA-1 (160 bits)session.hash_function = 0; Define how many bits are stored in each character when converting; the binary hash data to something readable.;; 4 bits: 0-9, a-f; 5 bits: 0-9, a-v; 6 bits: 0-9, a-z, A-Z, -, ,session.hash_bits_per_character = 5; The URL rewriter will look for URLs in a defined set of HTML tags.; form/fieldset are special; if you include them here, the rewriter will; add a hidden input field with the info which is otherwise appended; to URLs. If you want XHTML conformity, remove the form entry.; Note that all valid entries require a =, even if no value follows.url_rewriter.tags = a=href,area=href,frame=src,input=src,form=,fieldset= Well, thanks and sorry for my english; Nicolás. _ Watch “Cause Effect,” a show about real people making a real difference. Learn more. http://im.live.com/Messenger/IM/MTV/?source=text_watchcause It works for me; I am using php-5.2.5 with lighttpd and FastCGI. I called session_start() on both the pages. and I have enabled session.use_trans_sid. You can temporarily override it from the php script by using this - ? //...other code ini_set(session.use_trans_sid,1); //...other code ? Try and report again. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: problem with sessions config.
Thanks for your answers people; but i'm still having the problem, ¿any approach to the reason?. Remember everything works fine in on-line servers, so it may not be a problem of the code, but a config. one;cheers, Nicolas. To: php-general@lists.php.net Date: Sat, 22 Mar 2008 13:58:15 +0530 From: [EMAIL PROTECTED] Subject: [PHP] Re: problem with sessions config. N . Boatswain wrote: Hello guys; i'm having a problem with session behavior; i'm going straight to it, but first some considerations: PHP Version 5.2.5IIF 5.1Running on localhost (XP machine)I start sessions at the top of every page. A the start of a test page, just as example, i do the assignment: $_SESSION[username] = aaa; At the end of the same page i print it's value: echo $_SESSION[username]; And i get the layout: aaa, as expecteed. Then I redirect to another page. On that one, after initializating the session (session_start();) print again the $_SESSION[username] content and the result is empty. If i try the same code on a server (all this is on my local machine), the code works as expected; so i think it is a configuration problem, here is my php.ini part that correspond to session configuration, so you can tell my if i'm doing anything wrong, long comments where removed: [Session]; Handler used to store/retrieve data.session.save_handler = files;session.save_path = /tmp BC 13/12/07session.save_path=/tmp; Whether to use cookies.session.use_cookies = 1;session.cookie_secure = ; This option enables administrators to make their users invulnerable to; attacks which involve passing session ids in URLs; defaults to 0.session.use_only_cookies = 1; Name of the session (used as cookie name).session.name = PHPSESSID; Initialize session on request startup.session.auto_start = 1; Lifetime in seconds of cookie or, if 0, until browser is restarted.session.cookie_lifetime = 0; The path for which the cookie is valid.session.cookie_path = /; The domain for which the cookie is valid.session.cookie_domain =; Whether or not to add the httpOnly flag to the cookie, which makes it inaccessible to browser scripting languages such as JavaScript.session.cookie_httponly = ; Handler used to serialize data. php is the standard serializer of PHP.session.serialize_ha ndler = php; Define the probability that the 'garbage collection' process is started; on every session initialization.; The probability is calculated by using gc_probability/gc_divisor,; e.g. 1/100 means there is a 1% chance that the GC process starts; on each request.session.gc_probability = 1session.gc_divisor = 1000; After this number of seconds, stored data will be seen as 'garbage' and; cleaned up by the garbage collection process.session.gc_maxlifetime = 1440session.bug_compat_42 = 0session.bug_compat_warn = 1; Check HTTP Referer to invalidate externally stored URLs containing ids.; HTTP_REFERER has to contain this substring for the session to be; considered as valid.session.referer_check =; How many bytes to read from the file.session.entropy_length = 0; Specified here to create the session id.session.entropy_file =;session.entropy_length = 16;session.entropy_file = /dev/urandom; Set to {nocache,private,public,} to determine HTTP caching aspects; or leave this empt y to avoid sending anti-caching headers.session.cache_limiter = nocache; Document expires after n minutes.session.cache_expire = 180session.use_trans_sid = 0; Select a hash function; 0: MD5 (128 bits); 1: SHA-1 (160 bits)session.hash_function = 0; Define how many bits are stored in each character when converting; the binary hash data to something readable.;; 4 bits: 0-9, a-f; 5 bits: 0-9, a-v; 6 bits: 0-9, a-z, A-Z, -, ,session.hash_bits_per_character = 5; The URL rewriter will look for URLs in a defined set of HTML tags.; form/fieldset are special; if you include them here, the rewriter will; add a hidden input field with the info which is otherwise appended; to URLs. If you want XHTML conformity, remove the form entry.; Note that all valid entries require a =, even if no value follows.url_rewriter.tags = a=href,area=href,frame=src,input=src,form=,fieldset= Well, thanks and sorry for my english; Nicolás. _ Watch “Cause Effect,” a show about real people making a real difference. Learn more. http://im.live.com/Messenger/IM/MTV/?source=text_watchcause It works for me; I am using php-5.2.5 with lighttpd and FastCGI. I called session_start() on both the pages. and I have enabled session.use_trans_sid. You can temporarily override it from the php script by using this - ? //...other code ini_set(session.use_trans_sid,1); //...other code ? Try and report again. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: problem with this regex to remove img tag...
On 3/16/08, Ryan A [EMAIL PROTECTED] wrote: Now that thats over... can anybody recommend a good starting point to learn regex in baby steps? Cheers! R Mastering Regular Expressions, by Jeffrey Friedl ISBN 0-596-00289-0 -- -David. When the power of love overcomes the love of power, the world will know peace. -Jimi Hendrix -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: problem with this regex to remove img tag...
2008/3/17 Jonathan Crawford [EMAIL PROTECTED]: http://www.regular-expressions.info/php.html I second http://www.regular-expressions.info/. -- /Daniel P. Brown Forensic Services, Senior Unix Engineer 1+ (570-) 362-0283 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: problem with this regex to remove img tag...
Ryan A wrote: Hey All, After searching I found this regex to remove img tags from a post, but running it is giving me an error, being a total noob with regex i have no idea what the heck is wrong heres the whole script as its tiny: ?php $html = hello .'img src=/articles-blog/imgs/paul-fat.jpg alt= width=272 height=289 align=left'. Paul! ; $html = preg_replace('/?img((\s+\w+(\s*=\s*(?:.*?|\'.*?\'|[^\'\s]+))?)+\s*|\s*)/?', '', $html); echo $html; ? Any help appreciated. TIA, Ryan -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs why not a simple: $html = preg_replace('#([/]?img.*)#U', '', $html); ? - Tul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: problem with this regex to remove img tag...
M. Sokolewicz wrote: Ryan A wrote: Hey All, After searching I found this regex to remove img tags from a post, but running it is giving me an error, being a total noob with regex i have no idea what the heck is wrong heres the whole script as its tiny: ?php $html = hello .'img src=/articles-blog/imgs/paul-fat.jpg alt= width=272 height=289 align=left'. Paul! ; $html = preg_replace('/?img((\s+\w+(\s*=\s*(?:.*?|\'.*?\'|[^\'\s]+))?)+\s*|\s*)/?', '', $html); echo $html; ? Any help appreciated. TIA, Ryan -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs why not a simple: $html = preg_replace('#([/]?img.*)#U', '', $html); ? Wouldn't your example do this? pimg src=... /br / some description/p ^--catch from here to here ??-^ Would it not be better if the .* was [^]+ instead. Wouldn't the .* catch an even if it was like this? Jim - Tul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: problem with this regex to remove img tag...
Jim Lucas wrote: M. Sokolewicz wrote: Ryan A wrote: Hey All, After searching I found this regex to remove img tags from a post, but running it is giving me an error, being a total noob with regex i have no idea what the heck is wrong heres the whole script as its tiny: ?php $html = hello .'img src=/articles-blog/imgs/paul-fat.jpg alt= width=272 height=289 align=left'. Paul! ; $html = preg_replace('/?img((\s+\w+(\s*=\s*(?:.*?|\'.*?\'|[^\'\s]+))?)+\s*|\s*)/?', '', $html); echo $html; ? Any help appreciated. TIA, Ryan -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs why not a simple: $html = preg_replace('#([/]?img.*)#U', '', $html); ? Wouldn't your example do this? pimg src=... /br / some description/p ^--catch from here to here ??-^ Would it not be better if the .* was [^]+ instead. Wouldn't the .* catch an even if it was like this? Jim - Tul The U modifier prevents that, it makes the expression ungreedy. So unless the OP has a tag with an embedded in it, it should be fine. - Tul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: problem with this regex to remove img tag...
Thanks guys! This (From Tul/Sokolewicz): $html = preg_replace('#([/]?img.*)#U', '', $html); worked perfectly! I'm just learning this stuff so its extremly hard for me... i have been messing around with PHP for years but rarely even dipped my toes into the REGEX part as I think it would be easier for me to learn greek :) Now that thats over... can anybody recommend a good starting point to learn regex in baby steps? Cheers! R Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: problem with download script on safari and ie 7
I changes it now so it is... header('Content-Type: application/octet-stream'); header(Content-Disposition: attachment; filename=$file_name); echo $content; exit; Which works on ie7 but safari still downloads the .php R. Hulf [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] The problem I am getting is safari just downloads the .php file. IE7 corrupts the binary file. It opens fine on FF and IE6. Is this a headers problem? Thanks, R. ?php if(isset($_GET['id'])) { $id= $_GET['id']; $query = SELECT file_name, type, size, content FROM results WHERE id = '$id'; $result = mysql_query($query) or die(mysql_error());; list($file_name, $type, $size, $content) = mysql_fetch_array($result); /*echo $file_name; echo $type; echo $size;*/ header(Content-Type: $type); header(Content-Disposition: attachment; filename=$file_name); header(Content-Length: .filesize($file)); header(Accept-Ranges: bytes); header(Pragma: no-cache); header(Expires: 0); header(Cache-Control: must-revalidate, post-check=0, pre-check=0); header(Content-transfer-encoding: binary); echo $content; exit; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: problem with install php 5.2.3 on apache 2.2.4 in windows xp sp2
Could you Specifiy which error messages you were getting? --- Anton C. Swartz IV Phoenix Edge Network L.L.C. http://www.phpopenid.com - Owner PHPLogic Development Services http://www.phplogic.net - Co-Owner Necrogami http://www.necrogami.com - Personal Blog Based in Indianapolis, IN The Opposite of war is not Peace it is Creation. Don't let sin rule your body. After all, your body is bound to die, so dont obey its desires or let any part of it become slave to evil. Give yourselves to God, as people who have been raised from death to life. Make every part of your body a slavethat pleases God. Don't let sin keep ruling your lives.You are ruled by God's Kindness and not by the law. Romans 6:12-14 -Original Message- From: Ryan Lao [mailto:[EMAIL PROTECTED] Sent: Monday, July 23, 2007 10:36 PM To: php-general@lists.php.net Subject: [PHP] Re: problem with install php 5.2.3 on apache 2.2.4 in windows xp sp2 Arvin, You inserted the codes ?php phpinfo(); ? to your index.html file? arvin lee [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] system: windows xp sp 2 apache: apache_2.2.4-win32-x86-no_ssl PHP: php-5.2.3-win32-installer.msi i try to install php on my computer so that i can finish my homework, but after download these files nightmare begins. Install apache with default settings, install php with default settings. Restart apache server .While I modify index.html add ?php phpinfo(); ? , open 127.0.0.1 , apache server default page pops up with no change. Creat a new file named as phpinfo.php, modify httpd.conf , add line AddType application/x-httpd-php .php then restart apache. open broswer key in address 127.0.0.1/phpinfo.php ,it show me nothing. is there anyone can help ? PS. I have reinstall my windows system, nothing change.( Now I am using Appserv to finish my homewhere.) one thing, after install php 5.2.3 on apache server, when I stop apache server ,windows system show my two error message. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.476 / Virus Database: 269.10.14/912 - Release Date: 7/22/2007 7:02 PM -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.476 / Virus Database: 269.10.16/914 - Release Date: 7/23/2007 7:45 PM -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problem compile 5.2.3 souce under SUSE 10.1
Jeff Lanzarotta wrote: Hello, I am not sure if this is the right mailing list or not, but here goes... I am attempting to compile php 5.2.3 from source under SUSE 10.1. The compile is fine, it is the 'make test' that is failing... When I run 'make test' I am getting: = FAILED TEST SUMMARY - double to string conversion tests [Zend/tests/double_to_string.phpt] Bug #16069 (ICONV transliteration failure) [ext/iconv/tests/bug16069.phpt] iconv stream filter [ext/iconv/tests/iconv_stream_filter.phpt] strripos() offset integer overflow [ext/standard/tests/strings/strripos_offset.phpt] = There are (almost) always _some_ tests that fail. It's normal :) I have sent the automatic report, but have not heard anything back. And you won't hear anything back, the report is sent to the QA mailinglist, collected there and if there are enough reports to warrant an investigation into what the cause of this problem is, it will be investigated. You won't hear anything back though. Does anyone have any ideas on how to fix this? Regards, Jeff There is nothing to fix, they are tests, they check if everything works as expected. Apparently a few tests failed (ie. did not return _exactly_ what was expected), this doesn't mean your php install isn't functioning, because (certainly in this case) it should work just fine. Ignore these few testresults. - Tul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Problem compile 5.2.3 souce under SUSE 10.1
Oh, OK, thanks. - Original Message From: M. Sokolewicz [EMAIL PROTECTED] To: Jeff Lanzarotta [EMAIL PROTECTED] Cc: PHP General List php-general@lists.php.net Sent: Monday, July 23, 2007 11:32:17 AM Subject: [PHP] Re: Problem compile 5.2.3 souce under SUSE 10.1 Jeff Lanzarotta wrote: Hello, I am not sure if this is the right mailing list or not, but here goes... I am attempting to compile php 5.2.3 from source under SUSE 10.1. The compile is fine, it is the 'make test' that is failing... When I run 'make test' I am getting: = FAILED TEST SUMMARY - double to string conversion tests [Zend/tests/double_to_string.phpt] Bug #16069 (ICONV transliteration failure) [ext/iconv/tests/bug16069.phpt] iconv stream filter [ext/iconv/tests/iconv_stream_filter.phpt] strripos() offset integer overflow [ext/standard/tests/strings/strripos_offset.phpt] = There are (almost) always _some_ tests that fail. It's normal :) I have sent the automatic report, but have not heard anything back. And you won't hear anything back, the report is sent to the QA mailinglist, collected there and if there are enough reports to warrant an investigation into what the cause of this problem is, it will be investigated. You won't hear anything back though. Does anyone have any ideas on how to fix this? Regards, Jeff There is nothing to fix, they are tests, they check if everything works as expected. Apparently a few tests failed (ie. did not return _exactly_ what was expected), this doesn't mean your php install isn't functioning, because (certainly in this case) it should work just fine. Ignore these few testresults. - Tul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: problem with install php 5.2.3 on apache 2.2.4 in windows xp sp2
Arvin, You inserted the codes ?php phpinfo(); ? to your index.html file? arvin lee [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] system: windows xp sp 2 apache: apache_2.2.4-win32-x86-no_ssl PHP: php-5.2.3-win32-installer.msi i try to install php on my computer so that i can finish my homework, but after download these files nightmare begins. Install apache with default settings, install php with default settings. Restart apache server .While I modify index.html add ?php phpinfo(); ? , open 127.0.0.1 , apache server default page pops up with no change. Creat a new file named as phpinfo.php, modify httpd.conf , add line AddType application/x-httpd-php .php then restart apache. open broswer key in address 127.0.0.1/phpinfo.php ,it show me nothing. is there anyone can help ? PS. I have reinstall my windows system, nothing change.( Now I am using Appserv to finish my homewhere.) one thing, after install php 5.2.3 on apache server, when I stop apache server ,windows system show my two error message. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: problem with pcode function
Ross wrote: I have this postcode selector working on my localhost but remotely it gives a parse error. It should only call the function when the postcode is submitted. Any ideas? The error is: Parse error: parse error, unexpected T_NEW in /homepages/3/d154908384/htdocs/legalsuk/consultants/nearest.php on line 26 ?php function pcaStoredNearest($origin, $units, $distance, $items, $account_code, $license_code, $machine_id) { //Build the url $url = http://services.postcodeanywhere.co.uk/xml.aspx?;; $url .= action=stored_nearest; $url .= origin= . urlencode($origin); $url .= units= . urlencode($units); $url .= distance= . urlencode($distance); $url .= items= . urlencode($items); $url .= account_code= . urlencode($account_code); $url .= license_code= . urlencode($license_code); $url .= machine_id= . urlencode($machine_id); //Make the request $data = simplexml_load_string(file_get_contents($url)); //Check for an error if ($data-Schema['Items']==2) { throw new exception ($data-Data-Item['message']); } //Create the response foreach ($data-Data-children() as $row) { $rowItems=; foreach($row-attributes() as $key = $value) { $rowItems[$key]=strval($value); } $output[] = $rowItems; } //Return the result return $output; } } ? !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd; html xmlns=http://www.w3.org/1999/xhtml; head meta http-equiv=Content-Type content=text/html; charset=iso-8859-1 / title/title ?php include ('../pageElements/doc_head.php'); ? style type=text/css table { width:400px; } th { text-align:right; text-decoration:none; font-weight:normal; } td{ width:400px; } /style link href=../css/lss.css rel=stylesheet type=text/css / /head body id=services div id=container ?php include ('../pageElements/header.php'); ? div id=content-top /div div id=content-middle /div Find Your Nearest Consultant by Entering Your Postcode Belowbr /br / form action= method=post input name=pcode type=text style=width:100px; input name= type=submit style=width:50px; /form /div div id=result ?php if (isset($_POST['pcode'])){ $result = pcaStoredNearest($pcode, 'MILES', 'STRAIGHT', '2', 'x', 'x', ''); echo $result[0]['description']; } ? /div /div Is your server running PHP5, the same as your localhost? Darren -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: problem with array
Do a print_r($result); and you'll see the problem. Ross wrote: I am using postcode anywhere for a 'where's my nearest' function. All the geographical info is contained in an array, which when dumped looks like this var_dump ($result); array(1) { [0]= array(13) { [origin_postcode]= string(7) EH2 2BE [destination_postcode]= string(6) EH2 2BE [distance]= string(3) 0.0 [id]= string(1) 1 [description]= string(8) good man [grid_east_m]= string(6) 326513 [grid_north_m]= string(6) 675115 [longitude]= string(17) -3.17731851516552 [latitude]= string(16) 55.9634587262473 [os_reference]= string(14) NT 26513 75115 [wgs84_longitude]= string(17) -3.17876048499117 [wgs84_latitude]= string(16) 55.9634451567764 [name]= string(12) Jim Smith } } however, when I try and echo out a single index by name I get an undefined index. echo $result[description]; I can't seem to extract the bits I want from it. Thanks, R. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problem extending mysqli - No database connected
Actually, the post by hans at lintoo dot dk (22-Mar-2005 11:33) @ http://theserverpages.com/php/manual/en/ref.mysqli.php show why. Weird. On 6/29/07, Lee PHP [EMAIL PROTECTED] wrote: Hi, I have a class that extends msyqli that AFAIK can connect to the database, but gives me an error when I try and query it. Here's my class: -- BEGIN DATABASE CLASS -- require_once('Configuration.php'); require_once('RSFSException.php'); class Database extends mysqli { private $strUrl = DEV; private $strUser; private $strPass; private $strHost; private $intPort; private $strName; private static $INSTANCE; private static $CONFIG; private function __construct() { $this-CONFIG = Configuration::getInstance(); $this-establishConnectionSettings(); $this-connect($this-getHost(), $this-getUser(), $this-getPass(), $this-getName); if (mysqli_connect_errno()) { throw new RSFSException(Connect exception:\n . mysqli_connect_error(), -1); } } public static function getInstance($url = null) { // Set the URL if one is provided. if (isset($url)) { $this-setUrl($url); } // Instantiate the Singleton if not already instantiated. if(empty(self::$INSTANCE)) { self::$INSTANCE = new Database(); } return self::$INSTANCE; } public function establishConnectionSettings() { // DEVELOPMENT (default) database settings. if ($this-getUrl() == DEV) { $this-setUser($this-CONFIG-getProperty(rsfsTestDbUser)); $this-setPass($this-CONFIG-getProperty(rsfsTestDbPass)); $this-setHost($this-CONFIG-getProperty(rsfsTestDbHost)); $this-setPort($this-CONFIG-getProperty(rsfsTestDbPort)); $this-setName($this-CONFIG-getProperty(rsfsTestDbName)); } // PRODUCTION database settings. else if ($this-getUrl() == PROD) { $this-setUser($this-CONFIG-getProperty(rsfsDbUser)); $this-setPass($this-CONFIG-getProperty(rsfsDbPass)); $this-setHost($this-CONFIG-getProperty(rsfsDbHost)); $this-setPort($this-CONFIG-getProperty(rsfsDbPort)); $this-setName($this-CONFIG-getProperty(rsfsDbName)); } else { // Throw an exception. } } public function query($sql) { $result = parent::query($sql); if(mysqli_error($this)){ throw new RSFSException(mysqli_error($this), mysqli_errno($this)); } return $result; } public function valueExists($table, $column, $value, $caseInsensitive = false) { if (!$caseInsensitive) { $sql = SELECT * FROM $table WHERE $column = $value; } else { $sql = SELECT * FROM $table . WHERE upper($column) = ($value); } $result = $this-query($sql); echo Result: $result\n; $count = $result-num_rows; if ($count 0) { return true; } else { return false; } } public function valuesExist($table, $columns, $values) { // Placeholder. } public function procedureQuery($name, $params) { return $this-query(call $name($params)); } /** Return the URL. */ public function getUrl() { return $this-strUrl; } . . . /** Set the database URL. */ public function setName($url) { $this-strUrl = $$url; } } -- END DATABASE CLASS -- To test it, I'm doing the following: -- BEGIN -- echo Attempting to establish connection.\n; $CONN = Database::getInstance(); if ($CONN-ping()) { printf (Our connection is ok!\n); } else { printf (Danger, Will Robinson!!!\n); } echo Attempting to test query() method.\n; if ($result = $CONN-query(SELECT * FROM country)) { echo In result set\n; while( $row = mysqli_fetch_assoc($result) ){ printf(%s (%s)\n, $row['cnt_code'], $row['cnt_name']); } } -- END -- Which outputs the following: Attempting to establish connection. localhost:rsfs:rsfs:rsfs Our connection is ok! Attempting to test query() method. Fatal
[PHP] Re: problem with string floats in PHP
?php$var = '5.812E-08';var_dump($var);$var = (float)$var;var_dump($var);var_dump($var + 2);?Outputs:string(9) 5.812E-08 float(5.812E-8) float(2.0005812) All you need is to cast it (float) to float, (int) to int. Regards, Emil Ivanov Pablo Luque [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hello, Im designing a website in which I have to read some data (numbers) from a txt file and then send this data to a function which prints a graphic with them. When I read the data I save it in an array and the numbers are in this format: 5.812E-08. I have read the php documentation about it, and I have use the example given there to check which type is the data saved in the array. The response I got is $vectorIc[1]== 5.812E-08 type is string I dont understand why. In the documentation it is clear that this kind of data should be considerer float, or thats what I understood. I cant continue with my web designing if I dont get to turn the vector elements into float numbers, because the function that prints the graphic gives errors when recieving strings. I would be very thankful if you could help me trying to solve this. In using PHP 4.4.7 and Apache 2.0.59. Thank you very much! _ Descubre la descarga digital con MSN Music. Más de un millón de canciones. http://music.msn.es/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problem with timeout
Frank Arensmeier a écrit : Hello. I am currently working on a script that parses a given http adress by looking for anchor tags, background images and so on - a crawler if you like. The downloaded content is temporarily stored on the server (Mac OS X Server 10.4.9 with PHP 5) and, when the script is done, the content is packed into a ZIP archive. It seems that I am having trouble with my Apache timeout setting. Because the script downloads between 250 and 300MB of html, pdf, css files and so on, it is terminated automatically after the specified timeout setting (currently 1200 seconds). Setting max execution time to -1 in the script has no effect (which has been noticed previously on the php.net manual page). Is there any other way (with PHP) to come around this problem besides setting the time-out in the Apache config to more than 1200 seconds? The Apache manual says that the time out value can only be changed within the core configuration scope. My initial idea was to set the value in a .htaccess file which unfortunately is not allowed. I might also add that the script is already optimized for speed so to say. Hope you get what I mean. //frank Hello Frank Are you really sure you need an Apache-spawned PHP script to do all that long stuff ? Even if Apache does not give up on your PHP script, the HTTP client might do so. This is also not a good idea for a site with several clients because Apache could easily run low on available sockets, causing a DoS. I suggest you just spawn a background process from your PHP script, through some shell command like batch and nohup. The background process can still be coded in PHP with the CLI interface. At the end of the long process, you alert the user job was done (e.g. by mail or by some kind of AJAX mechanism) and let him download the result. In the Apache-spawned script: ?php // This will launch the process in background. // Be sure to set $job_id. $cmd_path = /path/to/some/job/dir/job$job_id.sh; $cmd = fopen( $cmd_path, 'w' ); fwrite( $cmd, #!/bin/sh\n. nohup php -f /path/to/your/scripts/long_process.php someargs\n. rm -f $cmd_path ); fclose( $cmd ); shell_exec( batch -f $cmd_path ); // Tell the user the job was scheduled... ? In long_process.php: ?php // Do your stuff... // Send an e-mail to the user or change a persistent server-side // state so that a script called periodically by the client will let // her know it was done. ? You may need to give the right to www-data, or whatever account running Apache, to create jobs through at/batch. Regards -- Emmanuel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Problem with timeout
// sorry for posting my answer off list... // 4 maj 2007 kl. 17.35 skrev Emmanuel Raulo-Kumagai: Frank Arensmeier a écrit : Hello. I am currently working on a script that parses a given http adress by looking for anchor tags, background images and so on - a crawler if you like. The downloaded content is temporarily stored on the server (Mac OS X Server 10.4.9 with PHP 5) and, when the script is done, the content is packed into a ZIP archive. It seems that I am having trouble with my Apache timeout setting. Because the script downloads between 250 and 300MB of html, pdf, css files and so on, it is terminated automatically after the specified timeout setting (currently 1200 seconds). Setting max execution time to -1 in the script has no effect (which has been noticed previously on the php.net manual page). Is there any other way (with PHP) to come around this problem besides setting the time-out in the Apache config to more than 1200 seconds? The Apache manual says that the time out value can only be changed within the core configuration scope. My initial idea was to set the value in a .htaccess file which unfortunately is not allowed. I might also add that the script is already optimized for speed so to say. Hope you get what I mean. //frank Hello Frank Are you really sure you need an Apache-spawned PHP script to do all that long stuff ? Even if Apache does not give up on your PHP script, the HTTP client might do so. This is also not a good idea for a site with several clients because Apache could easily run low on available sockets, causing a DoS. I suggest you just spawn a background process from your PHP script, through some shell command like batch and nohup. The background process can still be coded in PHP with the CLI interface. Thank you for sharing your suggestions. The idea of running the script as a background process seems very elegant to me, I have to admit. Since my script is executed only once a week, it would be sufficient to set up a simple cron job. Modifications to the script are also rather small, since I already have e.g. functions for output logging, process locking and so on. At the end of the long process, you alert the user job was done (e.g. by mail or by some kind of AJAX mechanism) and let him download the result. In the Apache-spawned script: ?php // This will launch the process in background. // Be sure to set $job_id. $cmd_path = /path/to/some/job/dir/job$job_id.sh; $cmd = fopen( $cmd_path, 'w' ); fwrite( $cmd, #!/bin/sh\n. nohup php -f /path/to/your/scripts/long_process.php someargs\n. rm -f $cmd_path ); fclose( $cmd ); shell_exec( batch -f $cmd_path ); // Tell the user the job was scheduled... ? In long_process.php: ?php // Do your stuff... // Send an e-mail to the user or change a persistent server-side // state so that a script called periodically by the client will let // her know it was done. ? You may need to give the right to www-data, or whatever account running Apache, to create jobs through at/batch. Regards -- Emmanuel -- 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
[PHP] Re: problem with shared object file
Marten Lehmann wrote: Hello, I'm trying to include a shared object file with the function dl(). But I always get: Warning: dl() [function.dl]: Unable to load dynamic library '/homepages/xyz/util.so' - /homepages/xyz/util.so: cannot open shared object file: No such file or directory in /homepages/xyz/test.php on line 5 But it is definetely there and readable (also executable)! Is your .so in turn missing any libs? ldd /homepages/xyz/util.so? (it may be statically compiled anyway) Never tried this in PHP before so other than that I don't know much. Col. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: problem with shared object file
Marten Lehmann wrote: Hello, I'm trying to include a shared object file with the function dl(). But I always get: Warning: dl() [function.dl]: Unable to load dynamic library '/homepages/xyz/util.so' - /homepages/xyz/util.so: cannot open shared object file: No such file or directory in /homepages/xyz/test.php on line 5 Some other notes from the docs you may have missed. This kinda zaps it's usefulness IMO. Note: dl() is not supported in multithreaded Web servers. Use the extensions statement in your php.ini when operating under such an environment. However, the CGI and CLI build are not affected ! Note: As of PHP 5, the dl() function is deprecated in every SAPI except CLI. Use Extension Loading Directives method instead. Note: Since PHP 6 this function is disabled in all SAPIs, except CLI, CGI and embed. Note: dl() is case sensitive on Unix platforms. Note: This function is disabled in safe mode. Col -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: problem with shared object file
Marten Lehmann wrote: Hello, I'm trying to include a shared object file with the function dl(). But I always get: Warning: dl() [function.dl]: Unable to load dynamic library '/homepages/xyz/util.so' - /homepages/xyz/util.so: cannot open shared object file: No such file or directory in /homepages/xyz/test.php on line 5 A. I got curious and looked at the docs: http://uk.php.net/manual/en/function.dl.php Parameters library This parameter is only the filename of the extension to load which also depends on your platform. For example, the sockets extension (if compiled as a shared module, not the default!) would be called sockets.so on Unix platforms whereas it is called php_sockets.dll on the Windows platform. Are you specifying the full path or just the filename? I'm guessing the former judging by it's location in your filesystem - e.g. not in the right place ;) Col. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problem with XSLT importStyleSheet
posted mailed Tijnema ! wrote: I've been trying to use PHP/XSLT on my desktop, running Fedora-6 Linux (with all current updates). The function importStyleSheet() seems to cause a Segmentation Violation, Thanks for your response. I have no problem with testing, i'm running home-made linux system with PHP5 PHP6 (Apache). Also running PHP5 under windows (Apache). Just need an example XSL/XML file to test:) Could you send one? (Off-list maybe because attachments are giving trouble sometimes on this list) Actually, the first example I gave comes from what I assume is the official PHP manual at http://ie.php.net/xsl%22%3E. There are 3 files, collection.xml, collection.xsl and the actual PHP script, Example 2526 (which I call ex2526.php), from http://ie.php.net/manual/en/function.xsl-xsltprocessor-transform-to-xml.php All 3 files are very short, so I give them here: collection cd titleFight for your mind/title artistBen Harper/artist year1995/year /cd cd titleElectric Ladyland/title artistJimi Hendrix/artist year1997/year /cd /collection xsl:stylesheet version=1.0 xmlns:xsl=http://www.w3.org/1999/XSL/Transform; xsl:param name=owner select=Nicolas Eliaszewicz'/ xsl:output method=html encoding=iso-8859-1 indent=no/ xsl:template match=collection Hey! Welcome to xsl:value-of select=$owner/'s sweet CD collection! xsl:apply-templates/ /xsl:template xsl:template match=cd h1xsl:value-of select=title//h1 h2by xsl:value-of select=artist/ - xsl:value-of select=year//h2 hr / /xsl:template /xsl:stylesheet ?php // Load the XML source $xml = new DOMDocument; $xml-load('collection.xml'); $xsl = new DOMDocument; $xsl-load('collection.xsl'); // Configure the transformer $proc = new XSLTProcessor; $proc-importStyleSheet($xsl); // attach the xsl rules echo $proc-transformToXML($xml); ? Now I get [EMAIL PROTECTED] Test]# php ex2526.php Segmentation fault I tried a few other examples, but all those with importStyleSheet() in them caused the same Segmentation fault. -- Timothy Murphy e-mail (80k only): tim /at/ birdsnest.maths.tcd.ie tel: +353-86-2336090, +353-1-2842366 s-mail: School of Mathematics, Trinity College, Dublin 2, Ireland -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problem with APC
No one else having problems? On 3/7/07, steve [EMAIL PROTECTED] wrote: Hi, I upgraded to PHP 4.4.6 and APC 3.0.13 at the same time. Every day at some point, it starts having a problem and the load on that machine styrockets. It does not happen with the opcode cache in Zend Platform for PHP 4.4.6. Also, in the error log I see a lot of things like this: [apc-warning] GC cache entry 'path_to_file.php' (dev=64768 ino=0) was on gc-list for 4590172 seconds Any ideas? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problem with file reading
===ORIGINAL=== Hi, I'm a beginner and i'm still learning PHP and I got a problem: $file = http://localhost/test_folder/test1.txt;;http://localhost/test_folder/test1.txt//I have also tried test_folder/test1.txt and text1.txt $fh = fopen($file, r) or die(Could not open file!); $data = fread($fh, filesize($file)) or die (Could not read file!); fclose($fh); echo $data; The file exist, I'm using apache server on my PC for practicing and the file is located in the servers root folder on the subfolder test_folder. Help would be greatly appreaciated Thanks in advance! ===END ORIGINAL=== Try using the complete path in $file... you can get the complete path by using $_SERVER['DOCUMENT_ROOT'] Also be sure that path given in $file variable is relatvie to location of php file that is executing -- Regards Fahad Pervaiz www.ecommerce-xperts.com (Shopping Cart, Web Design, SEO)
[PHP] Re: problem with mysql_real_escape_string()
You need to have established a database connection before using that function, see manual. [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi to all! I moved my website from one php4/mysql4 based server to new hosting company and php5/mysq5 based server. Everything worked fine on old server, though now, on one page after I submit new record, I'll get this error: Warning: mysql_real_escape_string() [function.mysql-real-escape-string https://www.mydomain.com/function.mysql-real-escape-string ]: Access denied for user 'daemon'@'localhost' (using password: NO) in /srv/www/mydomain/add_record.php on line 30 Warning: mysql_real_escape_string() [function.mysql-real-escape-string https://www.mydomain.com/function.mysql-real-escape-string ]: A link to the server could not be established in /srv/www/mydomain.com/add_record.php on line 30 and this is a code: 26 if(isset($_POST['SubmitNewRecord'])) 27 { 28 foreach($_POST as $key = $value) 29 { 30 ${$key} = mysql_real_escape_string($value); 31 } 32 } Never got such a error message before. Any thoughts? Thanks. -afan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: problem with imagestring()
Ave! Forget it. It turned out that the culprit was Debian-specific patch of libgd2. Sorry for bothering you. Regards, Piotr Sulecki. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problem compiling PHP 4.4.2 with mcrypt
Found this on Google: http://marc2.theaimsgroup.com/?l=php-installm=108030891925096w=2 Then Goto: http://mcrypt.hellug.gr/mcrypt/index.html where it says: The 2.6.x versions of mcrypt do not include Libmcrypt The 2.6.x versions of mcrypt need Libmhash 0.8.15 or newer It has a download facility. Tom Ray [Lists] wrote: I have to get a temporary server in place under a tight time frame and am using a pre-existing server that wasn't configured really for hosting websites. I've upgraded all the services on it like going from Apache 1.3.x to Apache 2.0.59 and PHP from it's old version to 4.4.2 however I need to have mcrypt compiled with PHP and I'm running into a problem. If I compile PHP without mcrypt I can install PHP without issue. However, when I try to compile PHP with --with-mcrypt=/usr/local/mcrypt I get the following error: main/internal_functions.lo -lcrypt -lcrypt -lmcrypt -lltdl -lresolv -lm -ldl -lnsl -lcrypt -lcrypt -o libphp4.la /usr/lib/gcc-lib/i486-suse-linux/3.2/../../../../i486-suse-linux/bin/ld: cannot find -lltdl collect2: ld returned 1 exit status make: *** [libphp4.la] Error 1 Now I went back and compiled without mcrypt and looked for that line and this is what was there: main/internal_functions.lo -lcrypt -lcrypt -lresolv -lm -ldl -lnsl -lcrypt -lcrypt -o libphp4.la I see that along with -lmcrypt not being there neither is -lltdl is there something I'm missing? Do I need to have something else installed on the box? Normally I haven't had this problem with this. But this is an old suse 8.x box that is being used due to time frame issues. Like I said I can compile PHP without mcrypt, but the project requires mcrypt so any help on this would be appreciated. Thanks! -- _ Myron Turner http://www.room535.org http://www.bstatzero.org http://www.mturner.org/XML_PullParser/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Problem with EXEC and PASSTHRU
# [EMAIL PROTECTED] / 2006-10-26 08:46:27 +1300: I'm LOVING php now - its a very simple language limited only by your imagination as to how you use it! My knowledge seems to be lacking more in HTML and Browser server relationships - I'm basing things on my background in Basic programming as a kid - you do Print Hello world and it does that instantly to the screen - little different with browsers! It's a little different with network communication. Try programming something for the console using the CLI (Command-Line Interface) version of PHP, should be much less confusing. -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problem with EXEC and PASSTHRU
On Wed, 25 Oct 2006 20:35:29 +1300, Matt Beechey wrote: I am writing a php website for users to edit a global whitelist for Spam Assassin - all is going fairly well considering I hadn't ever used php until a couple of days ago. My problem is I need to restart AMAVISD-NEW after the user saves the changes. I've acheived this using SUDO and giving the www-data users the rights to SUDO amavisd-new. My problem is simply a user friendlyness issue - below is the code I'm running - if(isset($_POST[SAVE])) { file_put_contents(/etc/spamassassin/whitelist.cf, $_SESSION[whitelist]); $_SESSION[count]=0; echo Restarting the service./A/P; exec('sudo /usr/sbin/amavisd-new reload'); echo Service was restarted.. Returning to the main page.; sleep(4) echo 'meta http-equiv=refresh content=0;URL=index.php'; } The problem is that the Restarting the Service dialogue doesn't get displayed until AFTER the Service Restarts even though it appears before the shell_exec command. I've tried exec and passthru and its always the same - I want it to display the Service was restarted - wait for 4 seconds and then redirect to the main page. Instead nothing happens on screen for the browser user until the service has restarted at which point they are returned to index.php - its as if the exec and the sleep and the refresh to index.php are all kind of running concurently. Can someone PLEASE tell me what I'm doing wrong - or shed light on how I should do this. www.php.net/flush may help you out, but there are many reasons for even that not to work... such as IE needing at least 256 (out the top of my head) bytes before showing anything, IE needing all data in a TABLE before showing it and commonly to make sure you send at least some 20 characters or so before being able to flush() again. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problem with EXEC and PASSTHRU
Matt Beechey wrote: I am writing a php website for users to edit a global whitelist for Spam Assassin - all is going fairly well considering I hadn't ever used php until a couple of days ago. My problem is I need to restart AMAVISD-NEW after the user saves the changes. I've acheived this using SUDO and giving the www-data users the rights to SUDO amavisd-new. My problem is simply a user friendlyness issue - below is the code I'm running - if(isset($_POST[SAVE])) { file_put_contents(/etc/spamassassin/whitelist.cf, $_SESSION[whitelist]); $_SESSION[count]=0; echo Restarting the service./A/P; exec('sudo /usr/sbin/amavisd-new reload'); echo Service was restarted.. Returning to the main page.; sleep(4) echo 'meta http-equiv=refresh content=0;URL=index.php'; } The problem is that the Restarting the Service dialogue doesn't get displayed until AFTER the Service Restarts even though it appears before the shell_exec command. I've tried exec and passthru and its always the same - I want it to display the Service was restarted - wait for 4 seconds and then redirect to the main page. Instead nothing happens on screen for the browser user until the service has restarted at which point they are returned to index.php - its as if the exec and the sleep and the refresh to index.php are all kind of running concurently. Can someone PLEASE tell me what I'm doing wrong - or shed light on how I should do this. Thanks, Matt -- You have to keep in mind that you are dealing with the difference in speed between something that is taking place on the sever and something that is being transmitted over a network. You don't make it clear whether this is an in-house site or whether it is used by people at a distance. If the latter, what you describe is not surprising at all. I've never had a reason to look into how PHP sequences events when it pumps out a web page, but it's not unusual for scripts in Perl, for instance, to show delays in browser output when doing something on the server. One consideration would be how long amavisd-new takes to reload. I'm not very well-informed about hacking and security, but it would seem to me that you are taking a risk by giving users root privileges to restart amavisd-new. _ Myron Turner http://www.mturner.org/XML_PullParser/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problem with EXEC and PASSTHRU
Ok - This is a reply to ALL - Thanks for the great help - I now understand why it wasn't displaying - it was all due to caching of data at the client end before displaying in blocks. With some help in the comments of the php manual for flush() I found a nice script that uses echo str_pad('',1024); to help pad things out - also displays a little countdown to keep people amused and convinced something is happening while the service restarts! I'm LOVING php now - its a very simple language limited only by your imagination as to how you use it! My knowledge seems to be lacking more in HTML and Browser server relationships - I'm basing things on my background in Basic programming as a kid - you do Print Hello world and it does that instantly to the screen - little different with browsers! Matt Myron Turner [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Matt Beechey wrote: I am writing a php website for users to edit a global whitelist for Spam Assassin - all is going fairly well considering I hadn't ever used php until a couple of days ago. My problem is I need to restart AMAVISD-NEW after the user saves the changes. I've acheived this using SUDO and giving the www-data users the rights to SUDO amavisd-new. My problem is simply a user friendlyness issue - below is the code I'm running - if(isset($_POST[SAVE])) { file_put_contents(/etc/spamassassin/whitelist.cf, $_SESSION[whitelist]); $_SESSION[count]=0; echo Restarting the service./A/P; exec('sudo /usr/sbin/amavisd-new reload'); echo Service was restarted.. Returning to the main page.; sleep(4) echo 'meta http-equiv=refresh content=0;URL=index.php'; } The problem is that the Restarting the Service dialogue doesn't get displayed until AFTER the Service Restarts even though it appears before the shell_exec command. I've tried exec and passthru and its always the same - I want it to display the Service was restarted - wait for 4 seconds and then redirect to the main page. Instead nothing happens on screen for the browser user until the service has restarted at which point they are returned to index.php - its as if the exec and the sleep and the refresh to index.php are all kind of running concurently. Can someone PLEASE tell me what I'm doing wrong - or shed light on how I should do this. Thanks, Matt -- You have to keep in mind that you are dealing with the difference in speed between something that is taking place on the sever and something that is being transmitted over a network. You don't make it clear whether this is an in-house site or whether it is used by people at a distance. If the latter, what you describe is not surprising at all. I've never had a reason to look into how PHP sequences events when it pumps out a web page, but it's not unusual for scripts in Perl, for instance, to show delays in browser output when doing something on the server. One consideration would be how long amavisd-new takes to reload. I'm not very well-informed about hacking and security, but it would seem to me that you are taking a risk by giving users root privileges to restart amavisd-new. _ Myron Turner http://www.mturner.org/XML_PullParser/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: problem with email characters
Actually I think it is a carriage return! Ross Ross [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Is there a function that sorts out all the dodgy characters in an email... e.g. ? An update on Scottish Social Networks Forum ? A summary of the conference Social Networks - Evidence and Potential ? Information on two organisations playing their part in supporting positive social networks - Counselling Psychotherapy in Scotland and Neighbourhood Networks ? I can use stripslashes(string); to remove the backslashes but what about the blocks. I assume they are spaces. Ross -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: problem with email characters
Hello, on 09/28/2006 02:27 PM Ross said the following: Is there a function that sorts out all the dodgy characters in an email... e.g. ? An update on Scottish Social Networks Forum ? A summary of the conference Social Networks - Evidence and Potential ? Information on two organisations playing their part in supporting positive social networks - Counselling Psychotherapy in Scotland and Neighbourhood Networks ? I can use stripslashes(string); to remove the backslashes but what about the blocks. I assume they are spaces. There are no dodgy characters for e-mail. What you may need is to encode those characters to send them by e-mail. You may need to use quoted-printable for bodies and q-encoding for headers. If you are not sure how to do that, you may want to try this MIME message composing and sending class that takes care of that for you: http://www.phpclasses.org/mimemessage -- Regards, Manuel Lemos Metastorage - Data object relational mapping layer generator http://www.metastorage.net/ PHP Classes - Free ready to use OOP components written in PHP http://www.phpclasses.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: problem with Firefox print preview?
Angelo Zanetti wrote: Hi all, I've developed this site in PHP and its basically finished, now I have a problem with the printing and print preview. I have a dynamic table that can span various pages depending on the number of records pulled from the database. The print preview (and printed page) doesnt print the first few rows but instead just prints blank then only prints the last line of the table on a new page. The table is embedded inside a fieldset component. Im not sure if its a mozilla/firefox bug because it seems fine in IE. Has anyone come across this problem before? Thanks in advance Angelo I'm very familiar with the problem. Suggest: All modern browsers are W3C compliant. IE6 is not; but, IE7 will be. You may as well fix it now. Otherwise, you'll need to do later this year for IE7. To fix the problem, start by running the W3C markup and css validators. If you are not using css for presentation; do so. Get your code to generate W3C compliant html code. Check it with Firefox. If necessary, which is rare, you many need to check the client's browser type and send a special IE6 version of the page. Al... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problem using fgetcsv()
Don wrote: Hi, I have a CSV file, comma delimited with the data enclosed by double quotes. I am using the fgetcsv() function to read and into an array and update a database. It works great except for the odd record. After investigating, I have ascertained that it is due to a backslash character in the data which fgetcsv() cannot parse properly. I don;t see anyway around this using fgetcsv(). Has anyone written a custom routine for this? Code Snippet --- $vvFile = 'myfile.csv'; $fph = fopen($vvFile,r) if ($fph) { while (($data = fgetcsv($fph,4096,',','')) !== FALSE) {M // Insert fields from array '$data' to my MySQL database - will fail on bad data } fclose($fph); } Sample Data -- 123456,135679048754,7154904875,HD INDOOR INSECT KILR 33 OZ 6,EA 654321,246809052607,7154905260,59-2 CACTUS SUCCULENTS \,EA Note: The first line is OK; the second will fail due to the backslash in the fourth field When I print the array contents, here is what I see. For the second line, it is not parsing the row properly and joining the fourth and fifth fields. When I edit and remove the backslash, all is OK. first line: data[0] = 123456 data[1] = 135679048754 data[2] = 7154904875 data[3] = HD INDOOR INSECT KILR 33 OZ 6 data[4] = EA second line: data[0] = 654321 data[1] = 246809052607 data[2] = 7154905260 data[3] = 59-2 CACTUS SUCCULENTS ,EA data[4] = You can use stripslashes() on the data first. Or, I generally use file_get_contents() and do my own parsing. That way I control the parsing. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: problem with mktime
On 4/30/06, Ross [EMAIL PROTECTED] wrote: soted it ! Thanks. please enlighten us in case someone else has the same sort of issue... Ross [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I am using this to compare todays date with dates retieved from a database. The problem is it seem to retrun the same value for the $then variable and can be seen ot working here http://nationalservicesscotland.com/cms/time.php ? session_start(); include ('../shared/connect.php'); $query= SELECT headline, id, expiry, link FROM events; $result= mysql_query($query); while ($row = @mysql_fetch_array($result, MYSQL_ASSOC)){ $compare= explode(/, $row['expiry']); $day = isset($compare[0]) ? $compare[0] : null; echo day is $daybrbrbr; $month = isset($compare[1]) ? $compare[1] : null; echo month is $monthbrbrbr; $year = isset($compare[2]) ? $compare[2] : null; echo year is $yearbrbrbr; $then = mktime(0,0,0,$month,$day, $year); $now = mktime (0,0,0,date(m),date(d),date(Y)); $diff = $now - $then; echo today is $todayBR; echo expiry date is $rossbr; echo now mktime value is is $nowbr; echo then mkvalue is $thenbrbr; if ($diff 0 ) { /*$text = stripslashes ($row['headline']); $newtext = wordwrap($text, 12, \n, 1); $link=$row['link']; echo $newtext.a href=\$link\...read more/a.br /br /;*/ } } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- 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] Re: problem with greek language
Rosen wrote: I have one very big problem: I create website with english and greek language. I use iso-8859-1 encoding for my website. I show the greek language text with encoded chars like tau;eta;lambda;epsilon;#972;rho;alpha;si; Representing such characters as HTML entities is fine. On the website I have no problems - everything shows ok, but when I pass this greek encoded string to javascript - i.e. alert('tau;eta;'); the browser doesn't decode the greek symbols and the alert shows me the same :tau;eta; The data between script and /script is, in HTML documents, CDATA, so HTML entities are not decoded. You either have to encode the document using a character encoding which supports the characters you want (such as UTF-8), configure your server to emit a suitable HTTP header, and use literal versions of those characters or represent those characters as \u (where is the Unicode character specified by four hexadecimal digits), or \XXX (three octal digits representing the Latin-1 character), or \xXX (two hexadecimal digits representing the Latin-1 character). -- David Dorward http://blog.dorward.me.uk/ http://dorward.me.uk/ Home is where the ~/.bashrc is -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problem
Thanks for all your replies. I have changed the include_path settings in php.ini which is in c:\wamp\php but still it takes the include path as c:\php5\PEAR Please help regards Bikram Bikram Suri [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi, I do phpinfo(); and I see the include path set to c:\php5\Pear. I have wamp installed on my machine but before wamp I had done a standalone installation of PHP 5 in c:\PHP5 diretory. I have since uninstalled it and deleted the c:\PHP5 directory from my system. How can i reset the include path?? I'm running Windows XP with latest wamp installatin(MYSQL+PHP+Apache) Any help would be greatly appreciated regards -- Bikram Suri -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: problem with large arrays in php 4.3.2
Jesse Guardiani jesse at wingnet.net writes: Hello, I have an old version of php (4.3.2) that is acting rather strangely. I'm searching two large arrays (approx 22,000 records in each) using array_diff_key() from the PEAR PHP_Compat library: $result = $args[0]; foreach ($args[0] as $key1 = $value1) { for ($i = 1; $i !== $array_count; $i++) { foreach ($args[$i] as $key2 = $value2) { if ((string) $key1 === (string) $key2) { unset($result[$key2]); break 2; } } } } And I'm getting aweful performance. I know it's a ton of records (22,000 * 22,000), but it shouldn't take 16 minutes on a P4 Xeon 2.4ghz! Has anyone seen this before? Is this a bug? Or are my math skills lacking and this is perfectly normal performance for the size of the data set? Thanks! I've conducted a little multi-language benchmark to see how other languages compare to PHP with regard to associative arrays of this size: http://www.guardiani.us/index.php/Hash_Array_Benchmark The result in short? PHP is a pretty typical performer, IMO. Thanks! P.S. Please read the disclaimer carefully before submitting criticism. Unless you have a neat optimization to share or code from another language to contribute, I've probably heard it already and don't care. :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: problem with large arrays in php 4.3.2
Their should be no problem with what your trying to do, try the following function, should act pretty much like array_diff(); if(!function_exists('array_diff')) { function array_diff($array1, $array2) { $difference = array(); foreach($array1 as $key = $value) { if(is_numeric($key)) { if(!in_array($value, $array2)) { $difference[] = $value; } } else { if(!array_key_exists($key, $array2)) { $difference[] = $key; } } } return $difference; } } // small test $array1 = array_fill(0, 2, 'banana'); $array2 = array(); print_r(array_diff($array1, $array2)); It also depends how much data the arrays contain James Jesse Guardiani wrote: Hello, I have an old version of php (4.3.2) that is acting rather strangely. I'm searching two large arrays (approx 22,000 records in each) using array_diff_key() from the PEAR PHP_Compat library: $result = $args[0]; foreach ($args[0] as $key1 = $value1) { for ($i = 1; $i !== $array_count; $i++) { foreach ($args[$i] as $key2 = $value2) { if ((string) $key1 === (string) $key2) { unset($result[$key2]); break 2; } } } } And I'm getting aweful performance. I know it's a ton of records (22,000 * 22,000), but it shouldn't take 16 minutes on a P4 Xeon 2.4ghz! Has anyone seen this before? Is this a bug? Or are my math skills lacking and this is perfectly normal performance for the size of the data set? Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php