[PHP] Problem with mbstring.internal_encoding, mcrypt and php-fpm
Hello, from two days I have strange problem with this param mbstring.internal_encoding on nginx and php-fpm. I use php version 5.4.20 and when I setting mbstring.internal_encoding I have a problem with mcrypt. NOTICE: PHP message: PHP Warning: mcrypt_generic_init(): Iv size incorrect; supplied length: 12, needed: 8 in file.php I setup php.ini file: zend.multibyte = On default_mimetype = text/html default_charset = UTF-8 mbstring.internal_encoding = UTF-8 and here is function: 85 private function decrypt($blob) 86 { 87 $deckey = $_SESSION['key']; 88 $realkey = sha1($deckey, true); 89 $rawblob = hex2bin($blob); /* binary blob */ 90 $td = mcrypt_module_open($this-CIPHER, , MCRYPT_MODE_CFB, ); 91 $iv = mb_substr($rawblob, 0, mcrypt_enc_get_iv_size($td)); /* IV */ 92 if (mb_strlen($iv) mcrypt_enc_get_iv_size($td)) return FALSE; 93 $ct = mb_substr($rawblob, mcrypt_enc_get_iv_size($td)); /* CipherText */ 94--- mcrypt_generic_init($td, $realkey, $iv); 95 $unblob = mdecrypt_generic($td, $ct); 96 mcrypt_generic_deinit($td); 97 $pt = mb_substr($unblob, 20); 98 $check = mb_substr($unblob, 0, 20); 99 if ($check != sha1($pt, true)) 100 { 101 return FALSE; 102 } else { 103 return $pt; 104 } 105 } The same code with the same config options is worked fine with apache httpd. Any one can give me a little help ? Thanks Regards, Hristo S. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with mbstring.internal_encoding, mcrypt and php-fpm
Hristo, Try changing the php.ini config: mbstring.func_overload 0 See if that helps your issue, more on what it does: http://php.net/manual/en/mbstring.overload.php Aziz On Mon, Sep 23, 2013 at 8:23 AM, Condor con...@stz-bg.com wrote: Hello, from two days I have strange problem with this param mbstring.internal_encoding on nginx and php-fpm. I use php version 5.4.20 and when I setting mbstring.internal_encoding I have a problem with mcrypt. NOTICE: PHP message: PHP Warning: mcrypt_generic_init(): Iv size incorrect; supplied length: 12, needed: 8 in file.php I setup php.ini file: zend.multibyte = On default_mimetype = text/html default_charset = UTF-8 mbstring.internal_encoding = UTF-8 and here is function: 85 private function decrypt($blob) 86 { 87 $deckey = $_SESSION['key']; 88 $realkey = sha1($deckey, true); 89 $rawblob = hex2bin($blob); /* binary blob */ 90 $td = mcrypt_module_open($this-**CIPHER, , MCRYPT_MODE_CFB, ); 91 $iv = mb_substr($rawblob, 0, mcrypt_enc_get_iv_size($td)); /* IV */ 92 if (mb_strlen($iv) mcrypt_enc_get_iv_size($td)) return FALSE; 93 $ct = mb_substr($rawblob, mcrypt_enc_get_iv_size($td)); /* CipherText */ 94--- mcrypt_generic_init($td, $realkey, $iv); 95 $unblob = mdecrypt_generic($td, $ct); 96 mcrypt_generic_deinit($td); 97 $pt = mb_substr($unblob, 20); 98 $check = mb_substr($unblob, 0, 20); 99 if ($check != sha1($pt, true)) 100 { 101 return FALSE; 102 } else { 103 return $pt; 104 } 105 } The same code with the same config options is worked fine with apache httpd. Any one can give me a little help ? Thanks Regards, Hristo S. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with mbstring.internal_encoding, mcrypt and php-fpm
On 2013-09-23 15:42, Aziz Saleh wrote: Hristo, Try changing the php.ini config: mbstring.func_overload 0 See if that helps your issue, more on what it does: http://php.net/manual/en/mbstring.overload.php [3] Aziz On Mon, Sep 23, 2013 at 8:23 AM, Condor con...@stz-bg.com wrote: Hello, from two days I have strange problem with this param mbstring.internal_encoding on nginx and php-fpm. I use php version 5.4.20 and when I setting mbstring.internal_encoding I have a problem with mcrypt. NOTICE: PHP message: PHP Warning: mcrypt_generic_init(): Iv size incorrect; supplied length: 12, needed: 8 in file.php I setup php.ini file: zend.multibyte = On default_mimetype = text/html default_charset = UTF-8 mbstring.internal_encoding = UTF-8 and here is function: 85 private function decrypt($blob) 86 { 87 $deckey = $_SESSION['key']; 88 $realkey = sha1($deckey, true); 89 $rawblob = hex2bin($blob); /* binary blob */ 90 $td = mcrypt_module_open($this-CIPHER, , MCRYPT_MODE_CFB, ); 91 $iv = mb_substr($rawblob, 0, mcrypt_enc_get_iv_size($td)); /* IV */ 92 if (mb_strlen($iv) mcrypt_enc_get_iv_size($td)) return FALSE; 93 $ct = mb_substr($rawblob, mcrypt_enc_get_iv_size($td)); /* CipherText */ 94 --- mcrypt_generic_init($td, $realkey, $iv); 95 $unblob = mdecrypt_generic($td, $ct); 96 mcrypt_generic_deinit($td); 97 $pt = mb_substr($unblob, 20); 98 $check = mb_substr($unblob, 0, 20); 99 if ($check != sha1($pt, true)) 100 { 101 return FALSE; 102 } else { 103 return $pt; 104 } 105 } The same code with the same config options is worked fine with apache httpd. Any one can give me a little help ? Thanks Regards, Hristo S. Hello, I just try and no effect after reload the php-fpm. Regards, Hristo S. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problem with dba_open() on db4 database
Hi, I am using a db4 database to store some values (on the local filesystem). Here the sample code: $handle = dba_open(/var/cache/mydb.db, cd, db4); [...] $result = dba_replace($key, serialize($data), $handle); [...] dba_close($handle); This Code is used in a CLI-Script (in an Asterisk-AGI-Script) and will be used by some processes in parallel. The online documentation (http://de1.php.net/manual/en/function.dba-open.php) shows, that the function should wait if more than a process has a lock on the database. This works fine if I use the script an execute it in differnt shells in parallel. But SOMETIMES(!) I get (in the Asterisk-Environment) the following error message: dba_open(/var/cache/mydb.db,cd): Driver initialization failed for handler: db4: Unable to establish lock (database file already open) So it seems, that the function dba_open() returns immediatly without waiting for lock release. But I do not know why ... ?! I am using the following versions: Ubuntu 12.04. LTS (up to date) with PHP 5.3.10-1ubuntu3.6 with Suhosin-Patch Any idea? Thank in advance -Thorsten- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with variables
Fernando A soporteallpurp...@gmail.com wrote: 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? Hi, Fernando, welcome. I'm just a little unsure what you mean by number of company -- is this a count, as in 10 companies, or is it a phone number, or is it something else? Jim's reply is workable -- storing session values is quite useful, but sessions are tied to a specific browser client/ip, and I'm not sure that's what you want/need here. If you are looking for setting a global variable that will be available everywhere in your application, you can use $GLOBALS, or set it from the very top level context of the application. Given you're using CodeIgniter, which sadly I am not versed in, you may need to set it with $GLOBALS: $GLOBALS['my_var'] = 10; // whatever you need to do here When you say it changes, how and when exactly does it change? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problem with variables
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
[PHP] Problem with soap - Error Fetching http headers
Hello, I am starting to make my first soap server/client. I found nice tutorial (manual pages on PHP is not detailed) and I have this server script: http://codeviewer.org/view/code:3131 boxing.wsdl looks: http://codeviewer.org/view/code:3132 and client script looks http://codeviewer.org/view/code:3133 (I am trying to experiment with user_agent without success) After running this I got http://codeviewer.org/view/code:3134 (full view) message - Error Fetching http headers What I have wrong? I am using lighttp with php-cgi and this test is possible to try on cutter.starnet.cz/soap.php (server) and cutter.starnet.cz/soap_client.php (client). Thank you Radek -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problem with my login script
Hello Thomas. The if are being evaluated in all iterations of the while, the problem is you didn't stop the loop when it finds what it's searching for. Try putting a break in the end of the if, them, when the condition match, the while will stop. And hey! You're using a lot of legacy code for one that is learning php. If you want, I can give you some tips to modernize your script ;) Regards, Rodrigo Silva dos Santos. Enviado por Samsung Mobile Thomas Conrad koopasfore...@gmail.com escreveu: I'm currently learning php and as a challenge, I'm creating a login script using text files to store the information (until I learn how to handle databases with php). The problem I'm having is the if statement in my while loop is only evaluated on the last iteration of the while loop, so its only comparing the last username in the file and no others. Heres the code: ?php session_start(); $users = file(../inc/users.inc.php); if($_POST['username'] $_POST['password']){ if(ereg(^[^@ ]+@[^@ ]+\.[^@ \.]+$, $_POST['username'])){ while(list($id ,$username) = each($users)){ if($_POST['username'] == $username){ $_SESSION['logged_in'] = 1; $_SESSION['username'] = $username; } } if($_SESSION['logged_in'] != 1){ $error = 2; } }else{ $error = 4; } }else{ $error = 3; } if($error){ header(Location: http://koopasforever.com/scripts/login.php?error=$error;); }else{ header(Location: http://koopasforever.com/;); } ? I have checked all my variables and they all contain the proper information Some help would be greatly appriciated, Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problem with my login script
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) In the other hand Thomas, you should use while and count the lines and u need to test if username found... Yeah, this script is near to the good solution: ?php session_start(); $users = file(users.inc.php); if (!empty($_POST['username']) !empty($_POST['password'])) { if (filter_var($_POST['username'], FILTER_VALIDATE_EMAIL)) { $ui = 0; while ($ui count($users) $error != 0) { $user = explode(' ', trim($users[$ui])); if ($_POST['username'] == $user[1]) { $_SESSION['logged_in'] = 1; $_SESSION['username'] = $user[1]; $error = 0; } else{ $error = 2; } $ui++; } } else { $error = 4; } } else { $error = 3; } if ($error == 0) { print(redirecting); } else { print(error: . $error); } ? On Tue, Oct 2, 2012 at 8:52 AM, Thomas Conrad koopasfore...@gmail.comwrote: I'm currently learning php and as a challenge, I'm creating a login script using text files to store the information (until I learn how to handle databases with php). The problem I'm having is the if statement in my while loop is only evaluated on the last iteration of the while loop, so its only comparing the last username in the file and no others. Heres the code: ?php session_start(); $users = file(../inc/users.inc.php); if($_POST['username'] $_POST['password']){ if(ereg(^[^@ ]+@[^@ ]+\.[^@ \.]+$, $_POST['username'])){ while(list($id ,$username) = each($users)){ if($_POST['username'] == $username){ $_SESSION['logged_in'] = 1; $_SESSION['username'] = $username; } } if($_SESSION['logged_in'] != 1){ $error = 2; } }else{ $error = 4; } }else{ $error = 3; } if($error){ header(Location: http://koopasforever.com/scripts/login.php?error=$error;); }else{ header(Location: http://koopasforever.com/;); } ? I have checked all my variables and they all contain the proper information Some help would be greatly appriciated, Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problem with my login script
Better solution than mine (that don't even make a code) As a Oo developer, a run away from using switch, so I should never use break too... Good to know. By the way, what's the problem with it? Enviado por Samsung Mobile Bálint Horváth hbal...@gmail.com escreveu: 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) In the other hand Thomas, you should use while and count the lines and u need to test if username found... Yeah, this script is near to the good solution: ?php session_start(); $users = file(users.inc.php); if (!empty($_POST['username']) !empty($_POST['password'])) { if (filter_var($_POST['username'], FILTER_VALIDATE_EMAIL)) { $ui = 0; while ($ui count($users) $error != 0) { $user = explode(' ', trim($users[$ui])); if ($_POST['username'] == $user[1]) { $_SESSION['logged_in'] = 1; $_SESSION['username'] = $user[1]; $error = 0; } else{ $error = 2; } $ui++; } } else { $error = 4; } } else { $error = 3; } if ($error == 0) { print(redirecting); } else { print(error: . $error); } ? On Tue, Oct 2, 2012 at 8:52 AM, Thomas Conrad koopasfore...@gmail.comwrote: I'm currently learning php and as a challenge, I'm creating a login script using text files to store the information (until I learn how to handle databases with php). The problem I'm having is the if statement in my while loop is only evaluated on the last iteration of the while loop, so its only comparing the last username in the file and no others. Heres the code: ?php session_start(); $users = file(../inc/users.inc.php); if($_POST['username'] $_POST['password']){ if(ereg(^[^@ ]+@[^@ ]+\.[^@ \.]+$, $_POST['username'])){ while(list($id ,$username) = each($users)){ if($_POST['username'] == $username){ $_SESSION['logged_in'] = 1; $_SESSION['username'] = $username; } } if($_SESSION['logged_in'] != 1){ $error = 2; } }else{ $error = 4; } }else{ $error = 3; } if($error){ header(Location: http://koopasforever.com/scripts/login.php?error=$error;); }else{ header(Location: http://koopasforever.com/;); } ? I have checked all my variables and they all contain the proper information Some help would be greatly appriciated, Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problem with my login script
As a Oo developer, a run away from using switch - I don't understand this: OOP and switch could be good together and I also prefer switch eg. at action or page selection... break is an old stuff and not a nice solution (like goto)... killing a procedure!? -means wrong planning of an app! (and jumping in the code with goto also like this) On Tue, Oct 2, 2012 at 12:11 PM, Rodrigo Silva dos Santos rodrigos.santo...@gmail.com wrote: Better solution than mine (that don't even make a code) As a Oo developer, a run away from using switch, so I should never use break too... Good to know. By the way, what's the problem with it? Enviado por Samsung Mobile Bálint Horváth hbal...@gmail.com escreveu: 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) In the other hand Thomas, you should use while and count the lines and u need to test if username found... Yeah, this script is near to the good solution: ?php session_start(); $users = file(users.inc.php); if (!empty($_POST['username']) !empty($_POST['password'])) { if (filter_var($_POST['username'], FILTER_VALIDATE_EMAIL)) { $ui = 0; while ($ui count($users) $error != 0) { $user = explode(' ', trim($users[$ui])); if ($_POST['username'] == $user[1]) { $_SESSION['logged_in'] = 1; $_SESSION['username'] = $user[1]; $error = 0; } else{ $error = 2; } $ui++; } } else { $error = 4; } } else { $error = 3; } if ($error == 0) { print(redirecting); } else { print(error: . $error); } ? On Tue, Oct 2, 2012 at 8:52 AM, Thomas Conrad koopasfore...@gmail.com wrote: I'm currently learning php and as a challenge, I'm creating a login script using text files to store the information (until I learn how to handle databases with php). The problem I'm having is the if statement in my while loop is only evaluated on the last iteration of the while loop, so its only comparing the last username in the file and no others. Heres the code: ?php session_start(); $users = file(../inc/users.inc.php); if($_POST['username'] $_POST['password']){ if(ereg(^[^@ ]+@[^@ ]+\.[^@ \.]+$, $_POST['username'])){ while(list($id ,$username) = each($users)){ if($_POST['username'] == $username){ $_SESSION['logged_in'] = 1; $_SESSION['username'] = $username; } } if($_SESSION['logged_in'] != 1){ $error = 2; } }else{ $error = 4; } }else{ $error = 3; } if($error){ header(Location: http://koopasforever.com/scripts/login.php?error=$error;); }else{ header(Location: http://koopasforever.com/;); } ? I have checked all my variables and they all contain the proper information Some help would be greatly appriciated, Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problem with my login script
Make sense, I haven't ever realizad how old the code appears like when it haves a break. Fell like C. Livin' n' learnin'. Thanks! Enviado por Samsung Mobile Bálint Horváth hbal...@gmail.com escreveu: As a Oo developer, a run away from using switch - I don't understand this: OOP and switch could be good together and I also prefer switch eg. at action or page selection... break is an old stuff and not a nice solution (like goto)... killing a procedure!? -means wrong planning of an app! (and jumping in the code with goto also like this) On Tue, Oct 2, 2012 at 12:11 PM, Rodrigo Silva dos Santos rodrigos.santo...@gmail.com wrote: Better solution than mine (that don't even make a code) As a Oo developer, a run away from using switch, so I should never use break too... Good to know. By the way, what's the problem with it? Enviado por Samsung Mobile Bálint Horváth hbal...@gmail.com escreveu: 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) In the other hand Thomas, you should use while and count the lines and u need to test if username found... Yeah, this script is near to the good solution: ?php session_start(); $users = file(users.inc.php); if (!empty($_POST['username']) !empty($_POST['password'])) { if (filter_var($_POST['username'], FILTER_VALIDATE_EMAIL)) { $ui = 0; while ($ui count($users) $error != 0) { $user = explode(' ', trim($users[$ui])); if ($_POST['username'] == $user[1]) { $_SESSION['logged_in'] = 1; $_SESSION['username'] = $user[1]; $error = 0; } else{ $error = 2; } $ui++; } } else { $error = 4; } } else { $error = 3; } if ($error == 0) { print(redirecting); } else { print(error: . $error); } ? On Tue, Oct 2, 2012 at 8:52 AM, Thomas Conrad koopasfore...@gmail.comwrote: I'm currently learning php and as a challenge, I'm creating a login script using text files to store the information (until I learn how to handle databases with php). The problem I'm having is the if statement in my while loop is only evaluated on the last iteration of the while loop, so its only comparing the last username in the file and no others. Heres the code: ?php session_start(); $users = file(../inc/users.inc.php); if($_POST['username'] $_POST['password']){ if(ereg(^[^@ ]+@[^@ ]+\.[^@ \.]+$, $_POST['username'])){ while(list($id ,$username) = each($users)){ if($_POST['username'] == $username){ $_SESSION['logged_in'] = 1; $_SESSION['username'] = $username; } } if($_SESSION['logged_in'] != 1){ $error = 2; } }else{ $error = 4; } }else{ $error = 3; } if($error){ header(Location: http://koopasforever.com/scripts/login.php?error=$error;); }else{ header(Location: http://koopasforever.com/;); } ? I have checked all my variables and they all contain the proper information Some help would be greatly appriciated, Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problem with my login script
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. You don't honestly believe that: while(list($key,$user) = each(file('someUserList')) and $foundUser=false) { if($user == $usernameWeAreLookingFor) { $foundUser = true; } } looks oh so much better than a simple: foreach(file('someUserList') as $key=$val) { if($user == $usernameWeAreLookingFor) { break; } } Also do note that it is very hard to use your do not use break, ever when you want to use foreach and want to stop at the first find. Seriously, stop giving advice to never use perfectly good code. In very complicated, long, loops, I agree that using break in various places can make debugging difficult. The solution however is not to refrain from ever using break, but rather to change your code into a clearer format. This is like saying you can make bombs from fertilizer, ergo fertilizer should not ever be used!. Everything has its use, and abuse. Same goes for goto, it can also be used for good. In the other hand Thomas, you should use while and count the lines and u need to test if username found... Ehr, he could also use foreach, for or any other loop construct... On a sidenote: please, please, please do not say u need. There is no u in english, it's written (and pronounced) you. Stick to that, you sound like a damned dumb teenager to me when using such needlessly abbreviated words. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problem with PHP in Moodle LMS
Has anyone ever heard of a problem with the Moodle LMS when trying to edit an activity (quiz, resource) in which there is a timeout after only a few seconds and a message saying something to the effect of that the system is sorry but there was a time out, please retry. When I look in the URL I see the following after my domain name: .../course/modeit.php Is this purely a Moodle thing, or something someone can help me with. (I've already searched the Moodle site for information about this error, but can't see anything related to version 2.2.3, which I am using.) Any help would be appreciated. I thought I might want to up the timout figure in the php5.ini file in the root directory of my shared Linux hosting with Godaddy, but I don't think that's really the problem. Regards, Gary
RE: [PHP] Problem with PHP in Moodle LMS
Has anyone ever heard of a problem with the Moodle LMS when trying to edit an activity (quiz, resource) in which there is a timeout after only a few seconds and a message saying something to the effect of that the system is sorry but there was a time out, please retry. When I look in the URL I see the following after my domain name: .../course/modeit.php Is this purely a Moodle thing, or something someone can help me with. (I've already searched the Moodle site for information about this error, but can't see anything related to version 2.2.3, which I am using.) Any help would be appreciated. I thought I might want to up the timout figure in the php5.ini file in the root directory of my shared Linux hosting with Godaddy, but I don't think that's really the problem. Regards, Gary Gary, Yes Moodle has a configuration issue. I would switch it to Debug mode and check the error logs it will tell you exactly what is going wrong. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problem with ssh2 public/private key connecting
Hi, I have problem with ssh2_Auth_Pubkey_File. I have one server for connecting to others. On all of theese is FreeBSD installed, but different versions. I am using dsa keys for connecting. From command line works everything fine (with using the same key files). But from php I have problem - a few servers with new version of FreeBSD dont accept connection. On machine where is php installed I have this message in php errorlog: [Tue Jun 12 12:15:37 2012] [error] [client ::1] PHP Warning: ssh2_auth_pubkey_file(): Authentication failed for useruser using public key: Username/PublicKey combination invalid in /usr/local/www/pokus.php on line 119 and in auth.log on remote machine I have: Jun 12 12:15:37 remote10 sshd[14012]: Did not receive identification string from 92.62.224.xx I thing, that problem is not in script - I am able to connect to some machines. But where could be a problem, I dont know. Here are methods, which I have to tried: #private $_METHODS = Array('hostkey' = 'ssh-dss'); private $_METHODS = Array('kex' = 'diffie-hellman-group1-sha1','hostkey' = 'ssh-dss','client_to_server' = Array('crypt' = '3des-cbc','mac' = 'hmac-md5','comp' = 'none'),'server_to_client' = Array('crypt' = '3des-cbc','mac' = 'hmac-md5','comp' = 'none')); private function Set_Connection() { $this-_connection = ssh2_Connect($this-_device_hostname, $this-_device_port, $this-_METHODS); if(!$this-_connection) { $this-_connection = NULL; return false; } if(!ssh2_Auth_Pubkey_File($this-_connection, $this-_USER, $this-_PUBLIC_KEY_PATH, $this-_PRIVATE_KEY_PATH)) { $this-_connection = NULL; return false; } return true; } Thank you for any suggestion. Radek
[PHP] problem sending email
hi all,i'm having this problem in sending email using pear. it just wont send :( here's the code .. ?php require_once 'Mail.php'; $from_name = My Self; $to_name = My Friend; $subject = Sending Trial; $mailmsg = GOD please make it work; $From = From: .$from_name. mym...@gmail.com; $To = To: .$to_name. some...@yahoo.com; $recipients = some...@yahoo.com; $headers[From] = $From; $headers[To] = $To; $headers[Subject] = $subject; $headers[Content-Type] = text/plain; charset=iso-8859-1; $smtpinfo[host] = smtp.gmail.com; $smtpinfo[port] = 465; $smtpinfo[auth] = true; $smtpinfo[username] = mym...@gmail.com; $smtpinfo[password] = mypassword; $mail_object = Mail::factory(smtp, $smtpinfo); $mail_object-send($recipients, $headers, $mailmsg); if (PEAR::isError($mail_object)) echo $mail_object-getMessage(); ?
Re: [PHP] problem sending email
On Thu, May 24, 2012 at 2:00 PM, As'ad Djamalilleil asad@gmail.com wrote: hi all,i'm having this problem in sending email using pear. it just wont send :( here's the code .. ?php require_once 'Mail.php'; $from_name = My Self; $to_name = My Friend; $subject = Sending Trial; $mailmsg = GOD please make it work; $From = From: .$from_name. mym...@gmail.com; $To = To: .$to_name. some...@yahoo.com; Don't prefix with From: and To: here. $recipients = some...@yahoo.com; $headers[From] = $From; $headers[To] = $To; $headers[Subject] = $subject; $headers[Content-Type] = text/plain; charset=iso-8859-1; $smtpinfo[host] = smtp.gmail.com; $smtpinfo[port] = 465; $smtpinfo[auth] = true; $smtpinfo[username] = mym...@gmail.com; $smtpinfo[password] = mypassword; $mail_object = Mail::factory(smtp, $smtpinfo); $mail_object-send($recipients, $headers, $mailmsg); if (PEAR::isError($mail_object)) echo $mail_object-getMessage(); ? Also, Gmail SMTP supports only SSL connections. I don't know this PEAR module, but I think you need to host set to something like ssl://smtp.gmail.com, to enforce SSL connection. - Matijn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] problem loading php extension: undefined reference to __gxx_personality_v0
Hi, I'm having trouble loading a PHP extension that I made. When starting PHP, I get the following error: PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626/libtg.so' - /usr/lib/php5/20090626/libtg.so: undefined symbol: __gxx_personality_v0 in Unknown on line 0 libtg.so is my extension. It is a wrapper around a C++ library, made using SWIG (http://www.swig.org/). I know __gxx_personality_v0 is a symbol from libstdc++, but my extension, libtg.so, is linked to libstdc++. I have confirmed this using ldd: $ ldd libtg.so linux-vdso.so.1 = (0x7fff5f932000) libstdc++.so.6 = /usr/lib/libstdc++.so.6 (0x7f3fc937c000) libm.so.6 = /lib/libm.so.6 (0x7f3fc90f9000) libgcc_s.so.1 = /lib/libgcc_s.so.1 (0x7f3fc8ee2000) libc.so.6 = /lib/libc.so.6 (0x7f3fc8b5f000) /lib64/ld-linux-x86-64.so.2 (0x7f3fc98fc000) Any ideas as to why PHP is not finding this symbol, or how I can further diagnose the problem? Thanks, Nate -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problem with AssertTag: children count wrong
Hi List! I'm trying to use phpUnit's AssertTag function to make sure that some html code contains an ul element with exactly li items in it. My test looks like this: function testUnconfiguredFilter() { $matcher = array( 'tag' = 'ul', 'children' = array( 'count' = 3, 'only' = array('tag' = 'li') ) ); $this-assertTag($matcher, $this-html, $message, $isHtml = FALSE); } the value of $html is: div class=flFilterbox id=flFilterunconfiguredFilter h3unconfiguredFilter/h3 ul class=flFilterboxInner lia href= FilterValue1/a ()/li lia href= FilterValue2/a ()/li lia href= FilterValue3/a ()/li /ul /div So I think the assertion SHOULD work - but it does not, no matter what I use for count! Sadly PHPUnit's output ist not very helpful, all it gives me is: 1) GeneratedFiltersTest::testUnconfiguredFilter Failed asserting that false is true. Has someone got an idea whats going on? This is really freakin me out, could not find anything about it anywhere on the web. Kind regards, Michael
Re: [PHP] Problem with AssertTag: children count wrong
On 05/02/2012 10:55 AM, Michael Otteneder wrote: Hi List! I'm trying to use phpUnit's AssertTag function to make sure that some html code contains an ul element with exactly li items in it. My test looks like this: function testUnconfiguredFilter() { $matcher = array( 'tag' = 'ul', 'children' = array( 'count' = 3, 'only' = array('tag' = 'li') ) ); $this-assertTag($matcher, $this-html, $message, $isHtml = FALSE); } the value of $html is: div class=flFilterbox id=flFilterunconfiguredFilter h3unconfiguredFilter/h3 ul class=flFilterboxInner lia href= FilterValue1/a ()/li lia href= FilterValue2/a ()/li lia href= FilterValue3/a ()/li /ul /div So I think the assertion SHOULD work - but it does not, no matter what I use for count! Sadly PHPUnit's output ist not very helpful, all it gives me is: 1) GeneratedFiltersTest::testUnconfiguredFilter Failed asserting that false is true. When dealing with classes, and specifically calling a static method within a class, the variable $this does not exist. You must use 'self' instead. You would need to do this instead if you wanted to use the $this way of things $test = new GeneratedFiltersTest; $test-testUnconfiguredFilter(); Plus, I am going to assume (since I don't see your code), that the method assertTag() is in a parent class that is inherited by the class GeneratedFiltersTest and again, since you are calling it via a static method, the inheritance would not have taken place. Has someone got an idea whats going on? This is really freakin me out, could not find anything about it anywhere on the web. Kind regards, Michael -- Jim Lucas http://www.cmsws.com/ http://www.cmsws.com/examples/ http://www.bendsource.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with AssertTag: children count wrong
Hi, sorry, I forgot to include the class definition: class GeneratedFiltersTest extends PHPUnit_Framework_Testcase { function testUnconfiguredFilter() { $matcher = array( 'tag' = 'ul', 'children' = array( 'count' = 3, 'only' = array('tag' = 'li') ) ); $this-assertTag($matcher, $this-html, $message, $isHtml = FALSE); } } I dont think that the problem is that $this does not exist. Other examples of assertTag() and other assert* functions work perfectly well. The only problem I have is when I use the 'children' option with assertTag, because the count never hast the value it should have. kind regards, Michael On Wed, May 2, 2012 at 9:22 PM, Jim Lucas li...@cmsws.com wrote: On 05/02/2012 10:55 AM, Michael Otteneder wrote: Hi List! I'm trying to use phpUnit's AssertTag function to make sure that some html code contains an ul element with exactly li items in it. My test looks like this: function testUnconfiguredFilter() { $matcher = array( 'tag' = 'ul', 'children' = array( 'count' = 3, 'only' = array('tag' = 'li') ) ); $this-assertTag($matcher, $this-html, $message, $isHtml = FALSE); } the value of $html is: div class=flFilterbox id=**flFilterunconfiguredFilter h3unconfiguredFilter/h3 ul class=flFilterboxInner lia href= FilterValue1/a ()/li lia href= FilterValue2/a ()/li lia href= FilterValue3/a ()/li /ul /div So I think the assertion SHOULD work - but it does not, no matter what I use for count! Sadly PHPUnit's output ist not very helpful, all it gives me is: 1) GeneratedFiltersTest::**testUnconfiguredFilter Failed asserting that false is true. When dealing with classes, and specifically calling a static method within a class, the variable $this does not exist. You must use 'self' instead. You would need to do this instead if you wanted to use the $this way of things $test = new GeneratedFiltersTest; $test-testUnconfiguredFilter(**); Plus, I am going to assume (since I don't see your code), that the method assertTag() is in a parent class that is inherited by the class GeneratedFiltersTest and again, since you are calling it via a static method, the inheritance would not have taken place. Has someone got an idea whats going on? This is really freakin me out, could not find anything about it anywhere on the web. Kind regards, Michael -- Jim Lucas http://www.cmsws.com/ http://www.cmsws.com/examples/ http://www.bendsource.com/
[PHP] problem about PHP-FPM in TCP socket and Unix socket
Hello all, I am trying to config some new server All of my servers are using TCP Socket(127.0.0.1:9000) between nginx and php-fpm before But, I run ab(ab -n 2 -c50 http://192.168.74.130:81/) to test the performance of Unix Socket and TCP Socket, the result is Unix is little better than TCP Usually we run php and web server in the same server, So, TCP socket and Unix socket Which method do you prefer ? Thank you -- *Yuchen Wang*
Re: [PHP] problem about PHP-FPM in TCP socket and Unix socket
This how I would look at it, if it on the same box use socket, and yes it is expected that socket is faster than TCP since (as far as I know) you don't need to deal with the overhead of TCP. Regards, Daniel Fenn On Sat, Mar 3, 2012 at 3:56 AM, Yuchen Wang phob...@gmail.com wrote: Hello all, I am trying to config some new server All of my servers are using TCP Socket(127.0.0.1:9000) between nginx and php-fpm before But, I run ab(ab -n 2 -c50 http://192.168.74.130:81/) to test the performance of Unix Socket and TCP Socket, the result is Unix is little better than TCP Usually we run php and web server in the same server, So, TCP socket and Unix socket Which method do you prefer ? Thank you -- *Yuchen Wang* -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problem about PHP-FPM in TCP socket and Unix socket
On Fri, Mar 2, 2012 at 5:56 PM, Yuchen Wang phob...@gmail.com wrote: Hello all, I am trying to config some new server All of my servers are using TCP Socket(127.0.0.1:9000) between nginx and php-fpm before But, I run ab(ab -n 2 -c50 http://192.168.74.130:81/) to test the performance of Unix Socket and TCP Socket, the result is Unix is little better than TCP Usually we run php and web server in the same server, So, TCP socket and Unix socket Which method do you prefer ? Thank you -- *Yuchen Wang* Always go for Unix sockets. TCP has quite a bit overhead which includes stuff you really don't need if two processes live on the same server. Think about error detection, flow control, congestion control, packet loss. None of these are needed if your system is functioning correctly. - Matijn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problem about PHP-FPM in TCP socket and Unix socket
Something else that should be said: You won't need to muck around with firewall settings as well (that if your running a firewall on the same box On Sat, Mar 3, 2012 at 11:22 AM, Matijn Woudt tijn...@gmail.com wrote: On Fri, Mar 2, 2012 at 5:56 PM, Yuchen Wang phob...@gmail.com wrote: Hello all, I am trying to config some new server All of my servers are using TCP Socket(127.0.0.1:9000) between nginx and php-fpm before But, I run ab(ab -n 2 -c50 http://192.168.74.130:81/) to test the performance of Unix Socket and TCP Socket, the result is Unix is little better than TCP Usually we run php and web server in the same server, So, TCP socket and Unix socket Which method do you prefer ? Thank you -- *Yuchen Wang* Always go for Unix sockets. TCP has quite a bit overhead which includes stuff you really don't need if two processes live on the same server. Think about error detection, flow control, congestion control, packet loss. None of these are needed if your system is functioning correctly. - Matijn -- 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] Problem with date
Hello All, I have a problem where Dates are coming out as 12.31.1969 19:00:00 which of course we didn't have PC's in 1969 I'm not able to see where the date is getting screwed up, any ideas?? // # function ShowFeed_RSS($XmlRoot) { $title = GetFirstChildContentByPath($XmlRoot, channel/title); $link = GetFirstChildContentByPath($XmlRoot, channel/link); $desc = GetFirstChildContentByPath($XmlRoot, channel/description); # Next 2 lines display the title of the feed, and feed description # echo font face=arial color=blue size =2ba href=\$link\$title/a/b\n; # echo $desc; $nodelist = GetChildrenByPathAndName($XmlRoot, channel, item); if (!$nodelist) return 0; foreach ($nodelist as $nl) { $title = GetFirstChildContentByName($nl, title); $link= GetFirstChildContentByName($nl, link); $desc= GetFirstChildContentByName($nl, description); $creator = GetFirstChildContentByName($nl, author); #if (!$creator) $creator = GetFirstChildContentByName($nl, dc:creator); # echo JACK . $nl . br; #$pubdate = GetFirstChildContentByName($nl, pubDate); if (!isset($pubdate)) $pubdate = GetFirstChildContentByName($nl, dc:date); #if (!$pubdate) $pubdate = GetFirstChildContentByName($nl, dc:date); if (isset($pubdate)) $pubdate = strtotime($pubdate); if (isset($pubdate)) $pubdate = strftime(%m.%d.%Y %H:%M:%S, $pubdate); $out = $creator; if ( ($creator != ) ($pubdate != ) ) $out .= @ ; $out .= $pubdate; echo a class=\rss-link\ href=\$link\b$title/b/a; echo font size=1 color=\black\$outbr; echo font size=2$descbrbr; # echo font size=1 class=rss-linkThis is not green/font; } # this line is after each rss feed group # echo hr\n; } Thanks! Jack
Re: [PHP] Problem with date
$pubdate is probably null or something. Regards, –Josh Joshua Kehn | @joshkehn http://joshuakehn.com On Dec 7, 2011, at 1:48 PM, Jack wrote: Hello All, I have a problem where Dates are coming out as 12.31.1969 19:00:00 which of course we didn't have PC's in 1969 I'm not able to see where the date is getting screwed up, any ideas?? // # function ShowFeed_RSS($XmlRoot) { $title = GetFirstChildContentByPath($XmlRoot, channel/title); $link = GetFirstChildContentByPath($XmlRoot, channel/link); $desc = GetFirstChildContentByPath($XmlRoot, channel/description); # Next 2 lines display the title of the feed, and feed description # echo font face=arial color=blue size =2ba href=\$link\$title/a/b\n; # echo $desc; $nodelist = GetChildrenByPathAndName($XmlRoot, channel, item); if (!$nodelist) return 0; foreach ($nodelist as $nl) { $title = GetFirstChildContentByName($nl, title); $link= GetFirstChildContentByName($nl, link); $desc= GetFirstChildContentByName($nl, description); $creator = GetFirstChildContentByName($nl, author); #if (!$creator) $creator = GetFirstChildContentByName($nl, dc:creator); # echo JACK . $nl . br; #$pubdate = GetFirstChildContentByName($nl, pubDate); if (!isset($pubdate)) $pubdate = GetFirstChildContentByName($nl, dc:date); #if (!$pubdate) $pubdate = GetFirstChildContentByName($nl, dc:date); if (isset($pubdate)) $pubdate = strtotime($pubdate); if (isset($pubdate)) $pubdate = strftime(%m.%d.%Y %H:%M:%S, $pubdate); $out = $creator; if ( ($creator != ) ($pubdate != ) ) $out .= @ ; $out .= $pubdate; echo a class=\rss-link\ href=\$link\b$title/b/a; echo font size=1 color=\black\$outbr; echo font size=2$descbrbr; # echo font size=1 class=rss-linkThis is not green/font; } # this line is after each rss feed group # echo hr\n; } Thanks! Jack
Re: [PHP] Problem with date
On 12/7/2011 10:48 AM, Jack wrote: Hello All, I have a problem where Dates are coming out as 12.31.1969 19:00:00 which of course we didn't have PC's in 1969 I'm not able to see where the date is getting screwed up, any ideas?? // # function ShowFeed_RSS($XmlRoot) { $title = GetFirstChildContentByPath($XmlRoot, channel/title); $link = GetFirstChildContentByPath($XmlRoot, channel/link); $desc = GetFirstChildContentByPath($XmlRoot, channel/description); # Next 2 lines display the title of the feed, and feed description # echo font face=arial color=blue size =2ba href=\$link\$title/a/b\n; # echo $desc; $nodelist = GetChildrenByPathAndName($XmlRoot, channel, item); if (!$nodelist) return 0; foreach ($nodelist as $nl) { $title = GetFirstChildContentByName($nl, title); $link= GetFirstChildContentByName($nl, link); $desc= GetFirstChildContentByName($nl, description); $creator = GetFirstChildContentByName($nl, author); #if (!$creator) $creator = GetFirstChildContentByName($nl, dc:creator); # echo JACK . $nl . br; #$pubdate = GetFirstChildContentByName($nl, pubDate); if (!isset($pubdate)) $pubdate = GetFirstChildContentByName($nl, dc:date); #if (!$pubdate) $pubdate = GetFirstChildContentByName($nl, dc:date); if (isset($pubdate)) $pubdate = strtotime($pubdate); if (isset($pubdate)) $pubdate = strftime(%m.%d.%Y %H:%M:%S, $pubdate); $out = $creator; if ( ($creator != ) ($pubdate != ) ) $out .= @ ; $out .= $pubdate; echo a class=\rss-link\ href=\$link\b$title/b/a; echo font size=1 color=\black\$outbr; echo font size=2$descbrbr; # echo font size=1 class=rss-linkThis is not green/font; } # this line is after each rss feed group # echo hr\n; } Thanks! Jack Can you supply an example of the data you are feeding this. -- 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
RE: [PHP] Problem with date
How about a little debugging here (and possibly elsewhere): if (isset($pubdate) ($pubdate 0)) { $pubdate=strtotime($pubdate); } else { die(Barf. Can't run a string to time conversion on 0 or -1.); } Thanks Kevin, This bombs and gives me the BARF! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Problem with date
How about a little debugging here (and possibly elsewhere): if (isset($pubdate) ($pubdate 0)) { $pubdate=strtotime($pubdate); } else { die(Barf. Can't run a string to time conversion on 0 or -1.); } Thanks Kevin, This bombs and gives me the BARF! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Problem with date
To: PHP Subject: RE: [PHP] Problem with date How about a little debugging here (and possibly elsewhere): if (isset($pubdate) ($pubdate 0)) { $pubdate=strtotime($pubdate); } else { die(Barf. Can't run a string to time conversion on 0 or -1.); } Thanks Kevin, This bombs and gives me the BARF! FYI the date field is stored in a MySQL DB as a datetime type -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Problem with date
-Original Message- From: Jack [mailto:jacklistm...@gmail.com] Sent: Wednesday, December 07, 2011 1:49 PM To: PHP Subject: [PHP] Problem with date Hello All, I have a problem where Dates are coming out as 12.31.1969 19:00:00 which of course we didn't have PC's in 1969 I'm not able to see where the date is getting screwed up, any ideas?? // ### # # function ShowFeed_RSS($XmlRoot) { $title = GetFirstChildContentByPath($XmlRoot, channel/title); $link = GetFirstChildContentByPath($XmlRoot, channel/link); $desc = GetFirstChildContentByPath($XmlRoot, channel/description); # Next 2 lines display the title of the feed, and feed description # echo font face=arial color=blue size =2ba href=\$link\$title/a/b\n; # echo $desc; $nodelist = GetChildrenByPathAndName($XmlRoot, channel, item); if (!$nodelist) return 0; foreach ($nodelist as $nl) { $title = GetFirstChildContentByName($nl, title); $link= GetFirstChildContentByName($nl, link); $desc= GetFirstChildContentByName($nl, description); $creator = GetFirstChildContentByName($nl, author); #if (!$creator) $creator = GetFirstChildContentByName($nl, dc:creator); # echo JACK . $nl . br; #$pubdate = GetFirstChildContentByName($nl, pubDate); if (!isset($pubdate)) $pubdate = GetFirstChildContentByName($nl, dc:date); #if (!$pubdate) $pubdate = GetFirstChildContentByName($nl, dc:date); if (isset($pubdate)) $pubdate = strtotime($pubdate); if (isset($pubdate)) $pubdate = strftime(%m.%d.%Y %H:%M:%S, $pubdate); $out = $creator; if ( ($creator != ) ($pubdate != ) ) $out .= @ ; $out .= $pubdate; echo a class=\rss-link\ href=\$link\b$title/b/a; echo font size=1 color=\black\$outbr; echo font size=2$descbrbr; # echo font size=1 class=rss-linkThis is not green/font; } # this line is after each rss feed group # echo hr\n; } Thanks! Jack Suggestion only. if (isset($pubdate)) $pubdate = strtotime($pubdate); if (isset($pubdate)) $pubdate = strftime(%m.%d.%Y %H:%M:%S, $pubdate); could be if (isset($pubdate)) $pubdate = mktime(m d Y H:i:s,strtotime($pubdate)); Reducing the code I also changed this to MKtime from strftime because The %e modifier is not supported in the Windows implementation of this function. To achieve this value, the %#d modifier can be used instead. The example below illustrates how to write a cross platform compatible function. Please read on the MKTIME function http://php.net/manual/en/function.mktime.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problem with sending AT command in php
In The Name Of Allah Thank you all for attentions ; Weird but solved with using another symbolink of Device Weird because other App in linux in the same time were using for example /dev/ttyusb1 but php code works with /dev/ttyusb3 .. Regards dehqan On Tue, Nov 15, 2011 at 7:39 PM, Richard Quadling rquadl...@gmail.comwrote: On 15 November 2011 15:12, Mike Mackintosh mike.mackint...@angrystatic.com wrote: On Nov 15, 2011, at 8:25, Richard Quadling rquadl...@gmail.com wrote: On 15 November 2011 11:50, a dehqan dehqa...@gmail.com wrote: \n is for Linux \r is for Windows On 11/14/11, Richard Quadling rquadl...@gmail.com wrote: On 12 November 2011 20:02, a dehqan dehqa...@gmail.com wrote: dio_write($handle, 'AT') dio_write($handle, AT) make firefox times out on Waiting for localhost ... . But dio_write($handle, AT\n) makes it prints AT exactly the same command or A A , .. On Sat, Nov 12, 2011 at 10:02 PM, Negin Nickparsa nickpa...@gmail.comwrote: are you sure about ATD03518726535\n? can you try if ( dio_write($handle, 'AT') )? Don't use \n, use \r. http://en.wikipedia.org/wiki/AT_commands#Example_session -- Richard Quadling Twitter : EE : Zend : PHPDoc : Fantasy Shopper @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea : fan.sh/6/370 No, \r is the requirement of the modem. Nothing to do with the OS. Windows uses \r\n as its line terminators, but when you talk to a modem, you use \r. -- Richard Quadling Twitter : EE : Zend : PHPDoc : Fantasy Shopper @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea : fan.sh/6/370 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I've had better luck with PHP_EOL instead of \r or \n. I think I've not explained myself properly. The modem wants a carriage return. That is a \r. It doesn't matter what OS you are on. If you don't send the right string to the modem, then the modem won't process it properly. If your OS maps \r to PHP_EOL, then, obviously PHP_EOL will be just fine. But I would recommend ... ?php define('CR', chr(13)); ? -- Richard Quadling Twitter : EE : Zend : PHPDoc : Fantasy Shopper @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea : fan.sh/6/370
Re: [PHP] problem with sending AT command in php
\n is for Linux \r is for Windows On 11/14/11, Richard Quadling rquadl...@gmail.com wrote: On 12 November 2011 20:02, a dehqan dehqa...@gmail.com wrote: dio_write($handle, 'AT') dio_write($handle, AT) make firefox times out on Waiting for localhost ... . But dio_write($handle, AT\n) makes it prints AT exactly the same command or A A , .. On Sat, Nov 12, 2011 at 10:02 PM, Negin Nickparsa nickpa...@gmail.comwrote: are you sure about ATD03518726535\n? can you try if ( dio_write($handle, 'AT') )? Don't use \n, use \r. http://en.wikipedia.org/wiki/AT_commands#Example_session -- Richard Quadling Twitter : EE : Zend : PHPDoc : Fantasy Shopper @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea : fan.sh/6/370 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problem with sending AT command in php
On 15 November 2011 11:50, a dehqan dehqa...@gmail.com wrote: \n is for Linux \r is for Windows On 11/14/11, Richard Quadling rquadl...@gmail.com wrote: On 12 November 2011 20:02, a dehqan dehqa...@gmail.com wrote: dio_write($handle, 'AT') dio_write($handle, AT) make firefox times out on Waiting for localhost ... . But dio_write($handle, AT\n) makes it prints AT exactly the same command or A A , .. On Sat, Nov 12, 2011 at 10:02 PM, Negin Nickparsa nickpa...@gmail.comwrote: are you sure about ATD03518726535\n? can you try if ( dio_write($handle, 'AT') )? Don't use \n, use \r. http://en.wikipedia.org/wiki/AT_commands#Example_session -- Richard Quadling Twitter : EE : Zend : PHPDoc : Fantasy Shopper @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea : fan.sh/6/370 No, \r is the requirement of the modem. Nothing to do with the OS. Windows uses \r\n as its line terminators, but when you talk to a modem, you use \r. -- Richard Quadling Twitter : EE : Zend : PHPDoc : Fantasy Shopper @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea : fan.sh/6/370 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problem with sending AT command in php
On Nov 15, 2011, at 8:25, Richard Quadling rquadl...@gmail.com wrote: On 15 November 2011 11:50, a dehqan dehqa...@gmail.com wrote: \n is for Linux \r is for Windows On 11/14/11, Richard Quadling rquadl...@gmail.com wrote: On 12 November 2011 20:02, a dehqan dehqa...@gmail.com wrote: dio_write($handle, 'AT') dio_write($handle, AT) make firefox times out on Waiting for localhost ... . But dio_write($handle, AT\n) makes it prints AT exactly the same command or A A , .. On Sat, Nov 12, 2011 at 10:02 PM, Negin Nickparsa nickpa...@gmail.comwrote: are you sure about ATD03518726535\n? can you try if ( dio_write($handle, 'AT') )? Don't use \n, use \r. http://en.wikipedia.org/wiki/AT_commands#Example_session -- Richard Quadling Twitter : EE : Zend : PHPDoc : Fantasy Shopper @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea : fan.sh/6/370 No, \r is the requirement of the modem. Nothing to do with the OS. Windows uses \r\n as its line terminators, but when you talk to a modem, you use \r. -- Richard Quadling Twitter : EE : Zend : PHPDoc : Fantasy Shopper @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea : fan.sh/6/370 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I've had better luck with PHP_EOL instead of \r or \n. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problem with sending AT command in php
On 15 November 2011 15:12, Mike Mackintosh mike.mackint...@angrystatic.com wrote: On Nov 15, 2011, at 8:25, Richard Quadling rquadl...@gmail.com wrote: On 15 November 2011 11:50, a dehqan dehqa...@gmail.com wrote: \n is for Linux \r is for Windows On 11/14/11, Richard Quadling rquadl...@gmail.com wrote: On 12 November 2011 20:02, a dehqan dehqa...@gmail.com wrote: dio_write($handle, 'AT') dio_write($handle, AT) make firefox times out on Waiting for localhost ... . But dio_write($handle, AT\n) makes it prints AT exactly the same command or A A , .. On Sat, Nov 12, 2011 at 10:02 PM, Negin Nickparsa nickpa...@gmail.comwrote: are you sure about ATD03518726535\n? can you try if ( dio_write($handle, 'AT') )? Don't use \n, use \r. http://en.wikipedia.org/wiki/AT_commands#Example_session -- Richard Quadling Twitter : EE : Zend : PHPDoc : Fantasy Shopper @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea : fan.sh/6/370 No, \r is the requirement of the modem. Nothing to do with the OS. Windows uses \r\n as its line terminators, but when you talk to a modem, you use \r. -- Richard Quadling Twitter : EE : Zend : PHPDoc : Fantasy Shopper @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea : fan.sh/6/370 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I've had better luck with PHP_EOL instead of \r or \n. I think I've not explained myself properly. The modem wants a carriage return. That is a \r. It doesn't matter what OS you are on. If you don't send the right string to the modem, then the modem won't process it properly. If your OS maps \r to PHP_EOL, then, obviously PHP_EOL will be just fine. But I would recommend ... ?php define('CR', chr(13)); ? -- Richard Quadling Twitter : EE : Zend : PHPDoc : Fantasy Shopper @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea : fan.sh/6/370 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problem with sending AT command in php
On 12 November 2011 20:02, a dehqan dehqa...@gmail.com wrote: dio_write($handle, 'AT') dio_write($handle, AT) make firefox times out on Waiting for localhost ... . But dio_write($handle, AT\n) makes it prints AT exactly the same command or A A , .. On Sat, Nov 12, 2011 at 10:02 PM, Negin Nickparsa nickpa...@gmail.comwrote: are you sure about ATD03518726535\n? can you try if ( dio_write($handle, 'AT') )? Don't use \n, use \r. http://en.wikipedia.org/wiki/AT_commands#Example_session -- Richard Quadling Twitter : EE : Zend : PHPDoc : Fantasy Shopper @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea : fan.sh/6/370 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] problem with sending AT command in php
In The Name Of Allah The compassionate merciful Hello ; Am trying to send AT commands to my GSMmodem device , in linux with PHP Am sure it is /dev/ttyusb1 But with [URL=http://pastebin.com/aut4ygXf]this code[/URL] device respond the same command and code prints that command e.g if we send ATD00 it responds ATD00 , or with AT it responds AT instead of Ok, why ? Regards dehqan
Re: [PHP] problem with sending AT command in php
are you sure about ATD03518726535\n? can you try if ( dio_write($handle, 'AT') )?
Re: [PHP] problem with sending AT command in php
dio_write($handle, 'AT') dio_write($handle, AT) make firefox times out on Waiting for localhost ... . But dio_write($handle, AT\n) makes it prints AT exactly the same command or A A , .. On Sat, Nov 12, 2011 at 10:02 PM, Negin Nickparsa nickpa...@gmail.comwrote: are you sure about ATD03518726535\n? can you try if ( dio_write($handle, 'AT') )?
[PHP] Problem of load balance among php-cgi process
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
[PHP] Problem with base64_encode and openssl_verify
openssl_sign($dados, $signature, $pkeyid)); // return 1 $signatureValue = base64_encode($signature); $funcionam = base64_decode($dados_que_nao); $pubKey = file_get_contents('protected/models/nfe/certs/cert.pem'); openssl_verify($funcionam,$signature, $pubKey)); // return 0; if I remove the de base64 encrypt and decrypt. It works fine. Can someone helpme with this?
[PHP] Problem with code...
Hi everyone, Have a question about this block of code ?PHP //SETUP VARIABLES $mailTo = li...@pruimphotography.com; $mailFrom = li...@pruimphotography.com; //These 2 can be changed IF you know what you are doing and why! $returnPath = $mailFrom; $replyTo = $mailFrom; $mailSubject = New Convention registration!; $message = ; //DO NOT CHANGE UNDER PENALITY OF BEING SLAPPED WITH A WET NOODLE!!! $headers = From: .$mailFrom.\n; $headers .= Return-Path: .$returnPath.\n; $headers .= Reply-To: .$replyTo.\n; function send_email($mailTo, $mailSubject, $mailMessage, $headers) { if(mail( $mailTo, $mailSubject, $mailMessage, $headers )) { $message = Thank you for registering!; }else { echo There was an issue with your registration.. Please try again later; } }//Close Function if(!empty($errorCount)) { }else { //Build Email message $mailmessage = Full Name: . $_POST['firstname'] . . $_POST['lastname'] . \n\n; $mailmessage .= Address: . $_POST['address'] . \n\n; $mailmessage .= City, State, Zip: . $_POST['city'] . . $_POST['state'] . . $_POST['zip'] . \n\n; $mailmessage .= Phone: . $_POST['phone'] . \n\n; $mailmessage .= Email address: . $_POST['email'] . \n\n; if($_POST['affiliation'] == NFBOther) { $mailmessage .= Chapter Affiliation: . $_POST['other'] . \n\n; }else{ $mailmessage .= Chapter Affiliation: . $_POST['affiliation'] . \n\n; } if($_POST['person'] ==Other){ $mailmessage .= Who will pick up the ticket? . $_POST['Pfirstname'] . . $_POST['Llastname'] . \n\n; }else{ $mailmessage .= Who will pick up the ticket? I will pick it up my self! \n\n; } $mailmessage .= Payment Method: . $_POST['paymentMethod']; send_email($mailTo, $mailSubject, $mailmessage, $headers); } ? Sometimes... It is dropping the last $mailmessage line... The payment method in the actual email it sends... Anyone have any ideas? I'm stumped Jason Pruim li...@pruimphotography.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with code...
On 2011-10-06, at 6:28 PM, Jason Pruim wrote: ?PHP //SETUP VARIABLES $mailTo = li...@pruimphotography.com; $mailFrom = li...@pruimphotography.com; //These 2 can be changed IF you know what you are doing and why! $returnPath = $mailFrom; $replyTo = $mailFrom; $mailSubject = New Convention registration!; $message = ; //DO NOT CHANGE UNDER PENALITY OF BEING SLAPPED WITH A WET NOODLE!!! $headers = From: .$mailFrom.\n; $headers .= Return-Path: .$returnPath.\n; $headers .= Reply-To: .$replyTo.\n; function send_email($mailTo, $mailSubject, $mailMessage, $headers) { if(mail( $mailTo, $mailSubject, $mailMessage, $headers )) { $message = Thank you for registering!; }else { echo There was an issue with your registration.. Please try again later; } }//Close Function if(!empty($errorCount)) { }else { //Build Email message $mailmessage = Full Name: . $_POST['firstname'] . . $_POST['lastname'] . \n\n; $mailmessage .= Address: . $_POST['address'] . \n\n; $mailmessage .= City, State, Zip: . $_POST['city'] . . $_POST['state'] . . $_POST['zip'] . \n\n; $mailmessage .= Phone: . $_POST['phone'] . \n\n; $mailmessage .= Email address: . $_POST['email'] . \n\n; if($_POST['affiliation'] == NFBOther) { $mailmessage .= Chapter Affiliation: . $_POST['other'] . \n\n; }else{ $mailmessage .= Chapter Affiliation: . $_POST['affiliation'] . \n\n; } if($_POST['person'] ==Other){ $mailmessage .= Who will pick up the ticket? . $_POST['Pfirstname'] . . $_POST['Llastname'] . \n\n; }else{ $mailmessage .= Who will pick up the ticket? I will pick it up my self! \n\n; } $mailmessage .= Payment Method: . $_POST['paymentMethod']; send_email($mailTo, $mailSubject, $mailmessage, $headers); } ? Sometimes... It is dropping the last $mailmessage line... The payment method in the actual email it sends... Anyone have any ideas? I'm stumped Hi there. First thought is perhaps it is not getting a value for paymentMethod and if it doesn't exist, will the line still get added? I would always check to see if every post variable isset, before adding the line. Can write a default line in its place if missing. George Langley Interactive Developer RIP, Mr. Jobs.
Re: [PHP] Problem with code...
Jason Pruim li...@pruimphotography.com On Oct 6, 2011, at 9:04 PM, George Langley wrote: On 2011-10-06, at 6:28 PM, Jason Pruim wrote: ?PHP //SETUP VARIABLES $mailTo = li...@pruimphotography.com; $mailFrom = li...@pruimphotography.com; //These 2 can be changed IF you know what you are doing and why! $returnPath = $mailFrom; $replyTo = $mailFrom; $mailSubject = New Convention registration!; $message = ; //DO NOT CHANGE UNDER PENALITY OF BEING SLAPPED WITH A WET NOODLE!!! $headers = From: .$mailFrom.\n; $headers .= Return-Path: .$returnPath.\n; $headers .= Reply-To: .$replyTo.\n; function send_email($mailTo, $mailSubject, $mailMessage, $headers) { if(mail( $mailTo, $mailSubject, $mailMessage, $headers )) { $message = Thank you for registering!; }else { echo There was an issue with your registration.. Please try again later; } }//Close Function if(!empty($errorCount)) { }else { //Build Email message $mailmessage = Full Name: . $_POST['firstname'] . . $_POST['lastname'] . \n\n; $mailmessage .= Address: . $_POST['address'] . \n\n; $mailmessage .= City, State, Zip: . $_POST['city'] . . $_POST['state'] . . $_POST['zip'] . \n\n; $mailmessage .= Phone: . $_POST['phone'] . \n\n; $mailmessage .= Email address: . $_POST['email'] . \n\n; if($_POST['affiliation'] == NFBOther) { $mailmessage .= Chapter Affiliation: . $_POST['other'] . \n\n; }else{ $mailmessage .= Chapter Affiliation: . $_POST['affiliation'] . \n\n; } if($_POST['person'] ==Other){ $mailmessage .= Who will pick up the ticket? . $_POST['Pfirstname'] . . $_POST['Llastname'] . \n\n; }else{ $mailmessage .= Who will pick up the ticket? I will pick it up my self! \n\n; } $mailmessage .= Payment Method: . $_POST['paymentMethod']; send_email($mailTo, $mailSubject, $mailmessage, $headers); } ? Sometimes... It is dropping the last $mailmessage line... The payment method in the actual email it sends... Anyone have any ideas? I'm stumped Hi there. First thought is perhaps it is not getting a value for paymentMethod and if it doesn't exist, will the line still get added? I would always check to see if every post variable isset, before adding the line. Can write a default line in its place if missing. The variable is being set with a default value of nothing else... But for some reason it's not bringing it through when the form is submitted... Any other ideas? hehe :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with code...
On Thu, Oct 6, 2011 at 7:29 PM, Jason Pruim li...@pruimphotography.comwrote: Jason Pruim li...@pruimphotography.com On Oct 6, 2011, at 9:04 PM, George Langley wrote: On 2011-10-06, at 6:28 PM, Jason Pruim wrote: ?PHP //SETUP VARIABLES $mailTo = li...@pruimphotography.com; $mailFrom = li...@pruimphotography.com; //These 2 can be changed IF you know what you are doing and why! $returnPath = $mailFrom; $replyTo = $mailFrom; $mailSubject = New Convention registration!; $message = ; //DO NOT CHANGE UNDER PENALITY OF BEING SLAPPED WITH A WET NOODLE!!! $headers = From: .$mailFrom.\n; $headers .= Return-Path: .$returnPath.\n; $headers .= Reply-To: .$replyTo.\n; function send_email($mailTo, $mailSubject, $mailMessage, $headers) { if(mail( $mailTo, $mailSubject, $mailMessage, $headers )) { $message = Thank you for registering!; }else { echo There was an issue with your registration.. Please try again later; } }//Close Function if(!empty($errorCount)) { }else { //Build Email message $mailmessage = Full Name: . $_POST['firstname'] . . $_POST['lastname'] . \n\n; $mailmessage .= Address: . $_POST['address'] . \n\n; $mailmessage .= City, State, Zip: . $_POST['city'] . . $_POST['state'] . . $_POST['zip'] . \n\n; $mailmessage .= Phone: . $_POST['phone'] . \n\n; $mailmessage .= Email address: . $_POST['email'] . \n\n; if($_POST['affiliation'] == NFBOther) { $mailmessage .= Chapter Affiliation: . $_POST['other'] . \n\n; }else{ $mailmessage .= Chapter Affiliation: . $_POST['affiliation'] . \n\n; } if($_POST['person'] ==Other){ $mailmessage .= Who will pick up the ticket? . $_POST['Pfirstname'] . . $_POST['Llastname'] . \n\n; }else{ $mailmessage .= Who will pick up the ticket? I will pick it up my self! \n\n; } $mailmessage .= Payment Method: . $_POST['paymentMethod']; send_email($mailTo, $mailSubject, $mailmessage, $headers); } ? Sometimes... It is dropping the last $mailmessage line... The payment method in the actual email it sends... Anyone have any ideas? I'm stumped Hi there. First thought is perhaps it is not getting a value for paymentMethod and if it doesn't exist, will the line still get added? I would always check to see if every post variable isset, before adding the line. Can write a default line in its place if missing. The variable is being set with a default value of nothing else... But for some reason it's not bringing it through when the form is submitted... Any other ideas? hehe :) Have you tested with the same payment method to see if somewhere in your code or a hiccup in the server is causing the problem? Does that happen to any or certain payment method (including blank entry)? I'm guessing it may happen with only certain payment method. From the line if(!empty($errorCount)) {, I presume you have a mechanism in place to sanitize and validate inputs? I'd suggest you start troubleshooting from there. If this is still development phase, try to bypass that mechanism for a quick confirmation that is causing the problem. Regards, Tommy
Re: [PHP] Problem with code...
On Thu, Oct 6, 2011 at 7:28 PM, Jason Pruim li...@pruimphotography.com wrote: Have a question about this block of code I'm not seeing anything immediately standing out as a problem. Sometimes... It is dropping the last $mailmessage line... The payment method in the actual email it sends... Can you see if the last line is actually in $mailmessage before sending the email? Maybe it's somehow getting truncated during the mail step. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Fwd: [PHP] Problem with code...
On Thu, Oct 6, 2011 at 7:28 PM, Jason Pruim li...@pruimphotography.com wrote: Have a question about this block of code I'm not seeing anything immediately standing out as a problem. Sometimes... It is dropping the last $mailmessage line... The payment method in the actual email it sends... Can you see if the last line is actually in $mailmessage before sending the email? Maybe it's somehow getting truncated during the mail step. *Update:* I just noticed this. The last line has no \r\n termination. I'm thinking that may be necessary for some mailers/transports/etc? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with inserting numbers...
On 11 Aug 2011 at 02:22, Jason Pruim pru...@gmail.com wrote: while ($num != 1) { while($row = mysql_fetch_assoc($result)) { $padnum = number_pad($num, 4); echo $row['areacode'] . - . $row['prefix'] . - . $padnum . BR; $num++; } } This is certain to fail. You've got the $num++ in the *inner* loop, and are checking its value in the *outer* loop. Think about it: suppose you enter the inner loop with $num being 9998. Suppose also that you then go round the inner loop 5 times. What is the value of $num when you then exit the inner loop in order to do the test against 1 in the outer loop? You need to rework that logic. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Problem with inserting numbers...
While no tusing just one while loop? $num = 0; while ( ( $row = mysql_fetch_assoc($result) ) $num++ = 1000 ) { //do whatever you want and you'll get all results or max. 1000 lines ( whatever comes first ) } Cheers, Tom -Original Message- From: Tim Streater [mailto:t...@clothears.org.uk] Sent: Thursday, August 11, 2011 11:22 AM To: Jason Pruim Cc: PHP General List Subject: Re: [PHP] Problem with inserting numbers... On 11 Aug 2011 at 02:22, Jason Pruim pru...@gmail.com wrote: while ($num != 1) { while($row = mysql_fetch_assoc($result)) { $padnum = number_pad($num, 4); echo $row['areacode'] . - . $row['prefix'] . - . $padnum . BR; $num++; } } This is certain to fail. You've got the $num++ in the *inner* loop, and are checking its value in the *outer* loop. Think about it: suppose you enter the inner loop with $num being 9998. Suppose also that you then go round the inner loop 5 times. What is the value of $num when you then exit the inner loop in order to do the test against 1 in the outer loop? You need to rework that logic. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with inserting numbers...
Replies below Jason Pruim li...@pruimphotography.com On Aug 10, 2011, at 11:08 PM, Ken Robinson wrote: At 09:22 PM 8/10/2011, Jason Pruim wrote: So here I am attempting to generate some numbers to be inserted into a database... eventually they will make up a phone number (Which I've emailed about before and know about the bad ideas with it.. But it's the customer :)) Here is the code I am working with: ?PHP function number_pad($number,$n) { return str_pad((int) $number,$n,0,STR_PAD_LEFT); } $SQL = SELECT * FROM Test WHERE `areacode` = '907' AND `prefix` = '200' LIMIT 5; $result = mysql_query($SQL); while ($num != 1) { while($row = mysql_fetch_assoc($result)) { $padnum = number_pad($num, 4); echo $row['areacode'] . - . $row['prefix'] . - . $padnum . BR; $num++; } } ? Try to avoid putting a database query in a loop. But that's exactly what I need to do... onceI have the code working with the echo I need to update the database with the numbers being displayed... $fullnumber = $row['areacode'].$row['prefix'].$padnum; $SQL = INSERT INTO Test ('fullnumber'( VALUES($fullnumber); So I want that to be in a loop since it will be inserting roughly 10,000 records for every areacode/prefix combination :) In the query only ask for the fields you are going to use, it's faster. Why use your own function to pad a string, when there is a built-in function? Because when I was doing my searching I came across the function I'm using before I saw the range function :) Try this code (untested): ?php $nums = range(0,); $q = SELECT areacode, prefix FROM Test WHERE `areacode` = '907' AND `prefix` = '200' LIMIT 5; $rs = mysql_query($q); while ($row = mysql_fetch_assoc($rs)) { foreach ($nums as $n) { echo sprintf('%03d-%03d-%04d',$row['areacode'],$row['prefix'],$n) br\n; } } ? I will try this later today after the day job gets done... Thanks for the help! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with inserting numbers...
On Aug 10, 2011, at 8:22 PM, Jason Pruim wrote: So here I am attempting to generate some numbers to be inserted into a database... eventually they will make up a phone number (Which I've emailed about before and know about the bad ideas with it.. But it's the customer :)) Here is the code I am working with: ?PHP function number_pad($number,$n) { return str_pad((int) $number,$n,0,STR_PAD_LEFT); } $SQL = SELECT * FROM Test WHERE `areacode` = '907' AND `prefix` = '200' LIMIT 5; $result = mysql_query($SQL); //$num = ; //foreach ($result as $key = $value) { //echo $key . - . $value . - . number_pad($num, 4) . BR; //$num++; //} while ($num != 1) { Problem is here ^ You are testing a numeric $num with a string 1, which $num will *never* equal. Leave off the quotes on the number. while($row = mysql_fetch_assoc($result)) { $padnum = number_pad($num, 4); echo $row['areacode'] . - . $row['prefix'] . - . $padnum . BR; $num++; } } ? basically all I'm trying to do is generate the last 4 digits starting at and going up to . for testing purposes I'm just echoing back but will eventually insert the complete number back into the database as a 7 digit string. The error I'm getting is: Fatal error: Maximum execution time of 30 seconds exceeded in /home/ pruimpho/public_html/jason/dev/clients/flewid/Phone/config/ phoneareacodes.php on line25 which is where the second while starts... Does anyone know a better way to do this? I'm off to finish searching google while waiting for some good news :) Thanks Everyone! Jason Pruim pru...@gmail.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with inserting numbers...
Le 11/08/2011 13:08, Tamara Temple a écrit : On Aug 10, 2011, at 8:22 PM, Jason Pruim wrote: while ($num != 1) { Problem is here ^ You are testing a numeric $num with a string 1, which $num will *never* equal. Leave off the quotes on the number. Hum, I suggest you read this page properly : http://www.php.net/manual/en/types.comparisons.php exemple : ?php $num = 1; $num++; print ($num != 2 ? different : equal) . PHP_EOL . ($num != 2 ? different : equal) . PHP_EOL; print ($num !== 2 ? different : equal) . PHP_EOL . ($num !== 2 ? different : equal) . PHP_EOL; result : equal equal equal different -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with inserting numbers...
Jason Pruim li...@pruimphotography.com wrote: Replies below Jason Pruim li...@pruimphotography.com On Aug 10, 2011, at 11:08 PM, Ken Robinson wrote: At 09:22 PM 8/10/2011, Jason Pruim wrote: So here I am attempting to generate some numbers to be inserted into a database... eventually they will make up a phone number (Which I've emailed about before and know about the bad ideas with it.. But it's the customer :)) Here is the code I am working with: ?PHP function number_pad($number,$n) { return str_pad((int) $number,$n,0,STR_PAD_LEFT); } $SQL = SELECT * FROM Test WHERE `areacode` = '907' AND `prefix` = '200' LIMIT 5; $result = mysql_query($SQL); while ($num != 1) { while($row = mysql_fetch_assoc($result)) { $padnum = number_pad($num, 4); echo $row['areacode'] . - . $row['prefix'] . - . $padnum . BR; $num++; } } ? Try to avoid putting a database query in a loop. But that's exactly what I need to do... onceI have the code working with the echo I need to update the database with the numbers being displayed... $fullnumber = $row['areacode'].$row['prefix'].$padnum; $SQL = INSERT INTO Test ('fullnumber'( VALUES($fullnumber); So I want that to be in a loop since it will be inserting roughly 10,000 records for every areacode/prefix combination :) In the query only ask for the fields you are going to use, it's faster. Why use your own function to pad a string, when there is a built-in function? Because when I was doing my searching I came across the function I'm using before I saw the range function :) Try this code (untested): ?php $nums = range(0,); $q = SELECT areacode, prefix FROM Test WHERE `areacode` = '907' AND `prefix` = '200' LIMIT 5; $rs = mysql_query($q); while ($row = mysql_fetch_assoc($rs)) { foreach ($nums as $n) { echo sprintf('%03d-%03d-%04d',$row['areacode'],$row['prefix'],$n) br\n; } } ? I will try this later today after the day job gets done... Thanks for the help! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php You might need to insert 10,000 rows, but that doesn't mean you need to perform 10,000 separate inserts. Use bulk inserts to ease the load. Also, try to run the script over the cli if you can, it will use less memory (no Apache and its posse) and it won't time out. Thanks, Ash http://www.ashleysheridan.co.uk -- Sent from my Android phone with K-9 Mail. Please excuse my brevity. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with inserting numbers...
On Wed, Aug 10, 2011 at 9:22 PM, Jason Pruim pru...@gmail.com wrote: So here I am attempting to generate some numbers to be inserted into a database... eventually they will make up a phone number (Which I've emailed about before and know about the bad ideas with it.. But it's the customer :)) Here is the code I am working with: ?PHP function number_pad($number,$n) { return str_pad((int) $number,$n,0,STR_PAD_LEFT); } $SQL = SELECT * FROM Test WHERE `areacode` = '907' AND `prefix` = '200' LIMIT 5; $result = mysql_query($SQL); //$num = ; //foreach ($result as $key = $value) { // echo $key . - . $value . - . number_pad($num, 4) . BR; // $num++; //} while ($num != 1) { while($row = mysql_fetch_assoc($result)) { $padnum = number_pad($num, 4); echo $row['areacode'] . - . $row['prefix'] . - . $padnum . BR; $num++; } } ? basically all I'm trying to do is generate the last 4 digits starting at and going up to . for testing purposes I'm just echoing back but will eventually insert the complete number back into the database as a 7 digit string. The error I'm getting is: Fatal error: Maximum execution time of 30 seconds exceeded in /home/pruimpho/public_html/jason/dev/clients/flewid/Phone/config/phoneareacodes.php on line25 which is where the second while starts... Does anyone know a better way to do this? I'm off to finish searching google while waiting for some good news :) Thanks Everyone! Jason Pruim pru...@gmail.com You could always push it off to MySQL. I don't have a MySQL instance available to test right now, but I ran this on SQL Server and it should be generic enough to port without much change. Basically, you just load a table with a single tinyint column with the digits between 0 and 9, and then allow the database to cross join that table 4 times to get 1 resulting rows numbered through . The cross join on this database server executes in around 44ms. -- Create a temporary table containing the digits 0 through 9 CREATE TABLE Digits ( n tinyint NOT NULL PRIMARY KEY CHECK (n BETWEEN 0 AND 9) ) INSERT INTO Digits VALUES (0), (1), (2), (3), (4), (5), (6), (7), (8), (9) -- Cross join the digits table 4 times to load into a table called numbers. SELECT CONVERT(char(1), Thousands.n) + CONVERT(char(1), Hundreds.n) + CONVERT(char(1), Tens.n) + CONVERT(char(1), Ones.n) AS Number INTONumbers FROMDigits AS Thousands, Digits AS Hundreds, Digits AS Tens, Digits AS Ones ORDER BY Thousands.n, Hundreds.n, Tens.n, Ones.n SELECT * FROMNumbers -- Drop the temporary digits table DROP TABLE Digits Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with inserting numbers...
On 8/10/2011 6:22 PM, Jason Pruim wrote: So here I am attempting to generate some numbers to be inserted into a database... eventually they will make up a phone number (Which I've emailed about before and know about the bad ideas with it.. But it's the customer :)) Here is the code I am working with: ?PHP function number_pad($number,$n) { return str_pad((int) $number,$n,0,STR_PAD_LEFT); } $SQL = SELECT * FROM Test WHERE `areacode` = '907' AND `prefix` = '200' LIMIT 5; $result = mysql_query($SQL); //$num = ; //foreach ($result as $key = $value) { //echo $key . - . $value . - . number_pad($num, 4) . BR; //$num++; //} while ($num != 1) { while($row = mysql_fetch_assoc($result)) { $padnum = number_pad($num, 4); echo $row['areacode'] . - . $row['prefix'] . - . $padnum . BR; $num++; } } ? basically all I'm trying to do is generate the last 4 digits starting at and going up to . for testing purposes I'm just echoing back but will eventually insert the complete number back into the database as a 7 digit string. The error I'm getting is: Fatal error: Maximum execution time of 30 seconds exceeded in /home/pruimpho/public_html/jason/dev/clients/flewid/Phone/config/phoneareacodes.php on line25 which is where the second while starts... Does anyone know a better way to do this? I'm off to finish searching google while waiting for some good news :) Thanks Everyone! Jason Pruim pru...@gmail.com Jason, Here is my rendition of what you should do. ?PHP $SQL = SELECT areacode, prefix FROMTest WHERE `areacode` = '907' AND `prefix` = '200'; $result = mysql_query($SQL); $values = ''; while( $row = mysql_fetch_assoc($result) ) { foreach ( range(0, ) AS $n ) { $values .= $row['areacode'] . '-' . $row['prefix'] . '-' . str_pad($n, 4, '0', STR_PAD_LEFT); } } echo $values; ? It will be much faster if you build the complete string in memory then echo out the built string. Jim Lucas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with inserting numbers...
Jason Pruim pru...@gmail.com On Aug 11, 2011, at 9:35 AM, Andrew Ballard wrote: On Wed, Aug 10, 2011 at 9:22 PM, Jason Pruim pru...@gmail.com wrote: So here I am attempting to generate some numbers to be inserted into a database... eventually they will make up a phone number (Which I've emailed about before and know about the bad ideas with it.. But it's the customer :)) Here is the code I am working with: ?PHP function number_pad($number,$n) { return str_pad((int) $number,$n,0,STR_PAD_LEFT); } $SQL = SELECT * FROM Test WHERE `areacode` = '907' AND `prefix` = '200' LIMIT 5; $result = mysql_query($SQL); //$num = ; //foreach ($result as $key = $value) { //echo $key . - . $value . - . number_pad($num, 4) . BR; //$num++; //} while ($num != 1) { while($row = mysql_fetch_assoc($result)) { $padnum = number_pad($num, 4); echo $row['areacode'] . - . $row['prefix'] . - . $padnum . BR; $num++; } } ? basically all I'm trying to do is generate the last 4 digits starting at and going up to . for testing purposes I'm just echoing back but will eventually insert the complete number back into the database as a 7 digit string. The error I'm getting is: Fatal error: Maximum execution time of 30 seconds exceeded in /home/pruimpho/public_html/jason/dev/clients/flewid/Phone/config/phoneareacodes.php on line25 which is where the second while starts... Does anyone know a better way to do this? I'm off to finish searching google while waiting for some good news :) Thanks Everyone! Jason Pruim pru...@gmail.com You could always push it off to MySQL. I don't have a MySQL instance available to test right now, but I ran this on SQL Server and it should be generic enough to port without much change. Basically, you just load a table with a single tinyint column with the digits between 0 and 9, and then allow the database to cross join that table 4 times to get 1 resulting rows numbered through . The cross join on this database server executes in around 44ms. -- Create a temporary table containing the digits 0 through 9 CREATE TABLE Digits ( n tinyint NOT NULL PRIMARY KEY CHECK (n BETWEEN 0 AND 9) ) INSERT INTO Digits VALUES (0), (1), (2), (3), (4), (5), (6), (7), (8), (9) -- Cross join the digits table 4 times to load into a table called numbers. SELECT CONVERT(char(1), Thousands.n) + CONVERT(char(1), Hundreds.n) + CONVERT(char(1), Tens.n) + CONVERT(char(1), Ones.n) AS Number INTONumbers FROMDigits AS Thousands, Digits AS Hundreds, Digits AS Tens, Digits AS Ones ORDER BY Thousands.n, Hundreds.n, Tens.n, Ones.n SELECT * FROMNumbers -- Drop the temporary digits table DROP TABLE Digits Andrew Hey Andrew, Interesting idea... I'm so used to doing it all from PHP that I forget a database can be more then just a storage engine sometimes :) I'll definitely give it a try tonight! Thanks Andrew! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with inserting numbers...
Jason Pruim pru...@gmail.com On Aug 11, 2011, at 11:52 AM, Jim Lucas wrote: On 8/10/2011 6:22 PM, Jason Pruim wrote: So here I am attempting to generate some numbers to be inserted into a database... eventually they will make up a phone number (Which I've emailed about before and know about the bad ideas with it.. But it's the customer :)) Here is the code I am working with: ?PHP function number_pad($number,$n) { return str_pad((int) $number,$n,0,STR_PAD_LEFT); } $SQL = SELECT * FROM Test WHERE `areacode` = '907' AND `prefix` = '200' LIMIT 5; $result = mysql_query($SQL); //$num = ; //foreach ($result as $key = $value) { //echo $key . - . $value . - . number_pad($num, 4) . BR; //$num++; //} while ($num != 1) { while($row = mysql_fetch_assoc($result)) { $padnum = number_pad($num, 4); echo $row['areacode'] . - . $row['prefix'] . - . $padnum . BR; $num++; } } ? basically all I'm trying to do is generate the last 4 digits starting at and going up to . for testing purposes I'm just echoing back but will eventually insert the complete number back into the database as a 7 digit string. The error I'm getting is: Fatal error: Maximum execution time of 30 seconds exceeded in /home/pruimpho/public_html/jason/dev/clients/flewid/Phone/config/phoneareacodes.php on line25 which is where the second while starts... Does anyone know a better way to do this? I'm off to finish searching google while waiting for some good news :) Thanks Everyone! Jason Pruim pru...@gmail.com Jason, Here is my rendition of what you should do. ?PHP $SQL = SELECT areacode, prefix FROMTest WHERE `areacode` = '907' AND `prefix` = '200'; $result = mysql_query($SQL); $values = ''; while( $row = mysql_fetch_assoc($result) ) { foreach ( range(0, ) AS $n ) { $values .= $row['areacode'] . '-' . $row['prefix'] . '-' . str_pad($n, 4, '0', STR_PAD_LEFT); } } echo $values; ? It will be much faster if you build the complete string in memory then echo out the built string. Hey Jim, Would that still hold true with inserting into a database which is the true end of it? This is going to be a one time thing I'm doing and I'm trying to make it a learning experience as I go since that's what everything should be right? Jim Lucas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with inserting numbers...
On 8/11/2011 9:34 AM, Jason Pruim wrote: Hey Jim, Would that still hold true with inserting into a database which is the true end of it? This is going to be a one time thing I'm doing and I'm trying to make it a learning experience as I go since that's what everything should be right? Yes, taking one of your other emails, you would do something like this. ?PHP $SQL = SELECT areacode, prefix FROMTest WHERE `areacode` = '907' AND `prefix` = '200'; $result = mysql_query($SQL); $values = ''; while( $row = mysql_fetch_assoc($result) ) { foreach ( range(0, ) AS $n ) { $values .= VALUES ('. sprintf('%03d-%03d-%04d', $row['areacode'], $row['prefix'], $n) . '); } } echo 'INSERT INTO Test (fullnumber) ' . $values; ? You should see... INSERT INTO Test (fullnumber) VALUES ('907-200-') VALUES ('907-200-0001') VALUES ('907-200-0001') etc... What this allows you to do is have one long string generated in memory then inserted into the DB. If you have any type of indexes on this table/column then it would only require one re-indexing of the table for the single INSERT statement vs 1 re-indexes for 1 separate INSERT statements. Cuts the DB processing time down a lot. Also, just so you know, if you place set_time_limit(0); at the top of the script, it will allow the script to run as long as it needs to. See: http://php.net/manual/en/function.set-time-limit.php Jim Lucas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problem with inserting numbers...
So here I am attempting to generate some numbers to be inserted into a database... eventually they will make up a phone number (Which I've emailed about before and know about the bad ideas with it.. But it's the customer :)) Here is the code I am working with: ?PHP function number_pad($number,$n) { return str_pad((int) $number,$n,0,STR_PAD_LEFT); } $SQL = SELECT * FROM Test WHERE `areacode` = '907' AND `prefix` = '200' LIMIT 5; $result = mysql_query($SQL); //$num = ; //foreach ($result as $key = $value) { //echo $key . - . $value . - . number_pad($num, 4) . BR; //$num++; //} while ($num != 1) { while($row = mysql_fetch_assoc($result)) { $padnum = number_pad($num, 4); echo $row['areacode'] . - . $row['prefix'] . - . $padnum . BR; $num++; } } ? basically all I'm trying to do is generate the last 4 digits starting at and going up to . for testing purposes I'm just echoing back but will eventually insert the complete number back into the database as a 7 digit string. The error I'm getting is: Fatal error: Maximum execution time of 30 seconds exceeded in /home/pruimpho/public_html/jason/dev/clients/flewid/Phone/config/phoneareacodes.php on line25 which is where the second while starts... Does anyone know a better way to do this? I'm off to finish searching google while waiting for some good news :) Thanks Everyone! Jason Pruim pru...@gmail.com
Re: [PHP] Problem with inserting numbers...
On Aug 10, 2011, at 9:36 PM, MUAD SHIBANI wrote: Basically you can increase time limit for this file to handle your request by using set_time_limit function ... Hi Maud, Looked into set_time_limit and even tried running it with a value of 120 but it didn't help... I'm affraid I have a problem with the way the 2 while loops are interacting and creating a infinite loop... BUT... I'm thinking there must be a better way... Maybe a while with a foreach? Now I'm just thinking outloud :) Jason Pruim pru...@gmail.com
Re: [PHP] Problem with inserting numbers...
basically all I'm trying to do is generate the last 4 digits starting at and going up to . for testing purposes I'm just echoing back but will eventually insert the complete number back into the database as a 7 digit string. The error I'm getting is: Fatal error: Maximum execution time of 30 seconds exceeded in /home/pruimpho/public_html/jason/dev/clients/flewid/Phone/config/phoneareacodes.php on line25 I'm not sure the to while loops is the best control structure. Why not try the following and see if it gets you the results you want? __untested__ while($row = mysql_fetch_assoc($result)) { if ($num != 1) $padnum = number_pad($num, 4) { echo $row['areacode'] . - . $row['prefix'] . - . $padnum . BR; $num++; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with inserting numbers...
when $num++; executed $num will never be '1'; you may change the while loop to while ($num 1) { while ($row = ... 2011/8/11 Jason Pruim pru...@gmail.com On Aug 10, 2011, at 9:36 PM, MUAD SHIBANI wrote: Basically you can increase time limit for this file to handle your request by using set_time_limit function ... Hi Maud, Looked into set_time_limit and even tried running it with a value of 120 but it didn't help... I'm affraid I have a problem with the way the 2 while loops are interacting and creating a infinite loop... BUT... I'm thinking there must be a better way... Maybe a while with a foreach? Now I'm just thinking outloud :) Jason Pruim pru...@gmail.com
Re: [PHP] Problem with inserting numbers...
At 09:22 PM 8/10/2011, Jason Pruim wrote: So here I am attempting to generate some numbers to be inserted into a database... eventually they will make up a phone number (Which I've emailed about before and know about the bad ideas with it.. But it's the customer :)) Here is the code I am working with: ?PHP function number_pad($number,$n) { return str_pad((int) $number,$n,0,STR_PAD_LEFT); } $SQL = SELECT * FROM Test WHERE `areacode` = '907' AND `prefix` = '200' LIMIT 5; $result = mysql_query($SQL); while ($num != 1) { while($row = mysql_fetch_assoc($result)) { $padnum = number_pad($num, 4); echo $row['areacode'] . - . $row['prefix'] . - . $padnum . BR; $num++; } } ? Try to avoid putting a database query in a loop. In the query only ask for the fields you are going to use, it's faster. Why use your own function to pad a string, when there is a built-in function? Try this code (untested): ?php $nums = range(0,); $q = SELECT areacode, prefix FROM Test WHERE `areacode` = '907' AND `prefix` = '200' LIMIT 5; $rs = mysql_query($q); while ($row = mysql_fetch_assoc($rs)) { foreach ($nums as $n) { echo sprintf('%03d-%03d-%04d',$row['areacode'],$row['prefix'],$n) br\n; } } ? Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] problem installing CakePHP on Linux
Hello List I want to use Cake PHP ,I have downloaded it from it's site,rename the folder to first_app and copied it to /srv/www/htdocs my root is here: /srv/www/htdocs by entering http://localhost/first_app/ it has some errors like these outputs: Warning: _cake_core_ cache was unable to write 'default_en-us' to cache in /srv/www/htdocs/first_app/cake/libs/cache.php on line 295 Warning: _cake_core_ cache was unable to write 'default_en-us' to cache in /srv/www/htdocs/first_app/cake/libs/cache.php on line 295 Warning: /srv/www/htdocs/first_app/app/tmp/cache/persistent/ is not writable in /srv/www/htdocs/first_app/cake/libs/cache/file.php on line 299 Warning: /srv/www/htdocs/first_app/app/tmp/cache/models/ is not writable in /srv/www/htdocs/first_app/cake/libs/cache/file.php on line 299 I wanted to identify another root in default-server I used this one: Directory /srv/www/htdocs/first_app/app/webroot AllowOverride All Options FollowSymLinks # Order deny,allow # Deny from all /Directory I restarted the apache but again the same warnings then I changed httpd.conf too. I tried hard to figure it out. if it is about the permissions I tried this one: chmod -R 0755 /srv/www/htdocs/first_app/ would you please tell me how to change the root correctly? or if it is not related to it What is the problem? Thanks in Advance.
Re: [PHP] problem installing CakePHP on Linux
On 8/7/2011 9:53 AM, Negin Nickparsa wrote: Hello List I want to use Cake PHP ,I have downloaded it from it's site,rename the folder to first_app and copied it to /srv/www/htdocs my root is here: /srv/www/htdocs by entering http://localhost/first_app/ it has some errors like these outputs: Warning: _cake_core_ cache was unable to write 'default_en-us' to cache in /srv/www/htdocs/first_app/cake/libs/cache.php on line 295 Warning: _cake_core_ cache was unable to write 'default_en-us' to cache in /srv/www/htdocs/first_app/cake/libs/cache.php on line 295 Warning: /srv/www/htdocs/first_app/app/tmp/cache/persistent/ is not writable in /srv/www/htdocs/first_app/cake/libs/cache/file.php on line 299 Warning: /srv/www/htdocs/first_app/app/tmp/cache/models/ is not writable in /srv/www/htdocs/first_app/cake/libs/cache/file.php on line 299 Try $ chown -R www-data:www-data /srv/www/htdocs/first_app Replace www-data:www-data with what is appropriate on your system. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problem installing CakePHP on Linux
Thank you, I found that only the tmp directory must be writable then I used this one: also by right clicking and using wwwrun for user I tried to set them as you told chmod -R 0777 /srv/www/htdocs/first_app/app/tmp/ and the I get fatal Error: http://cakephp.org/changelogs/1.3.6 Fatal error: Class 'Debugger' not found in /srv/www/htdocs/first_app/cake/libs/view/pages/home.ctp on line 26
Re: [PHP] problem installing CakePHP on Linux
I have debugger.php in cake/libs I don't know why it doesn't access to this file and tell me can't find the class
Re: [PHP] problem installing CakePHP on Linux
cool I found this hidden file .htaccess: IfModule mod_rewrite.c RewriteEngine on RewriteRule^$ app/webroot/[L] RewriteRule(.*) app/webroot/$1 [L] /IfModule well I don't know that this apache module is enabled or not I changed the apache2 in /etc/sysconfig and add the rewrite in modules right here: APACHE_MODULES=actions alias auth_basic authn_file authz_host authz_groupfile authz_default authz_user authn_dbm autoindex cgi dir env expires include log_config mime negotiation setenvif ssl suexec userdir php5 rewrite
Re: [PHP] problem installing CakePHP on Linux
Finally I solved my problem! I have downloaded another version of cake that is less than 2 now it works like a charm:)
[PHP] Problem with header(Location: )...
So I'm attempting to redirect back to the main site of a page after a successful insert into a database... Here's my code: ?PHP if (!$resp-is_valid) { // What happens when the CAPTCHA was entered incorrectly die (The reCAPTCHA wasn't entered correctly. Go back and try it again. . (reCAPTCHA said: . $resp-error . )); } else { $name = mysql_real_escape_string($_POST['txtName']); $comment = mysql_real_escape_string($_POST['areaComment']); $phonelink = mysql_real_escape_string($_POST['phonelink']); $SQL = INSERT INTO comments (name, comment, phonelink) VALUES ('$name', '$comment', '$phonelink'); mysql_query($SQL) or die(Unable to insert at this time. Sorry for the inconvience); //echo Insert successful!; header(Location: HTTP://jason.pruimphotography.com/dev/clients/flewid/Phone/); // Your code here to handle a successful verification } ? The insert happens, BUT it won't redirect back to the site There isn't any reason I should be able to do a header() redirect at that point is there? Or is there a better way to do it? Thanks Everyone! Jason Pruim li...@pruimphotography.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Problem with header(Location: )...
Try lowercase 'http'. Anything in error log? Try turning on display_errors. Cheers, Tamas -Original Message- From: Jason Pruim [mailto:li...@pruimphotography.com] Sent: Sunday, July 31, 2011 8:40 PM To: php-general@lists.php.net Subject: [PHP] Problem with header(Location: )... So I'm attempting to redirect back to the main site of a page after a successful insert into a database... Here's my code: ?PHP if (!$resp-is_valid) { // What happens when the CAPTCHA was entered incorrectly die (The reCAPTCHA wasn't entered correctly. Go back and try it again. . (reCAPTCHA said: . $resp-error . )); } else { $name = mysql_real_escape_string($_POST['txtName']); $comment = mysql_real_escape_string($_POST['areaComment']); $phonelink = mysql_real_escape_string($_POST['phonelink']); $SQL = INSERT INTO comments (name, comment, phonelink) VALUES ('$name', '$comment', '$phonelink'); mysql_query($SQL) or die(Unable to insert at this time. Sorry for the inconvience); //echo Insert successful!; header(Location: HTTP://jason.pruimphotography.com/dev/clients/flewid/Phone/); // Your code here to handle a successful verification } ? The insert happens, BUT it won't redirect back to the site There isn't any reason I should be able to do a header() redirect at that point is there? Or is there a better way to do it? Thanks Everyone! Jason Pruim li...@pruimphotography.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with header(Location: )...
Jason Pruim li...@pruimphotography.com On Jul 31, 2011, at 2:50 PM, Dajka Tamas wrote: Try lowercase 'http'. Anything in error log? Try turning on display_errors. Tried both, upper and lower case http nothing changed... And nothing in the error log... I try a simple echo with a link and that works just fine... Starting to get frustrated with it -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with header(Location: )...
On Jul 31, 2011, at 1:40 PM, Jason Pruim wrote: So I'm attempting to redirect back to the main site of a page after a successful insert into a database... Here's my code: ?PHP if (!$resp-is_valid) { // What happens when the CAPTCHA was entered incorrectly die (The reCAPTCHA wasn't entered correctly. Go back and try it again. . (reCAPTCHA said: . $resp-error . )); } else { $name = mysql_real_escape_string($_POST['txtName']); $comment = mysql_real_escape_string($_POST['areaComment']); $phonelink = mysql_real_escape_string($_POST['phonelink']); $SQL = INSERT INTO comments (name, comment, phonelink) VALUES ('$name', '$comment', '$phonelink'); mysql_query($SQL) or die(Unable to insert at this time. Sorry for the inconvience); //echo Insert successful!; header(Location: HTTP://jason.pruimphotography.com/dev/clients/flewid/Phone/ ); // Your code here to handle a successful verification } ? The insert happens, BUT it won't redirect back to the site There isn't any reason I should be able to do a header() redirect at that point is there? Since the echo is commented out, there shouldn't be any output if that is sum total of the code executing on the http request. If this file is called from some other script, you might check to see if any output is sent from there. If display_errors is on, you should be getting something like Unable to send headers after output or some such (I can't offhand think of the actual error message). You can keep the error successful message for verification if you write it directly to the error log, via: error_log(Insert successful.PHP_EOL); Sometimes, it's also nice to insert markers to let you know where the log is emanating from: error_log(__FILE__.'@'.__LINE__.': '.Insert successful.PHP_EOL); Sometimes, a vexing sort of error is a blank line at the top or bottom of a file, outside the ?..? Or is there a better way to do it? Thanks Everyone! Jason Pruim li...@pruimphotography.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with header(Location: )...
On Jul 31, 2011, at 6:23 PM, Tamara Temple wrote: On Jul 31, 2011, at 1:40 PM, Jason Pruim wrote: So I'm attempting to redirect back to the main site of a page after a successful insert into a database... Here's my code: ?PHP if (!$resp-is_valid) { // What happens when the CAPTCHA was entered incorrectly die (The reCAPTCHA wasn't entered correctly. Go back and try it again. . (reCAPTCHA said: . $resp-error . )); } else { $name = mysql_real_escape_string($_POST['txtName']); $comment = mysql_real_escape_string($_POST['areaComment']); $phonelink = mysql_real_escape_string($_POST['phonelink']); $SQL = INSERT INTO comments (name, comment, phonelink) VALUES ('$name', '$comment', '$phonelink'); mysql_query($SQL) or die(Unable to insert at this time. Sorry for the inconvience); //echo Insert successful!; header(Location: HTTP://jason.pruimphotography.com/dev/clients/flewid/Phone/); // Your code here to handle a successful verification } ? The insert happens, BUT it won't redirect back to the site There isn't any reason I should be able to do a header() redirect at that point is there? Since the echo is commented out, there shouldn't be any output if that is sum total of the code executing on the http request. If this file is called from some other script, you might check to see if any output is sent from there. If display_errors is on, you should be getting something like Unable to send headers after output or some such (I can't offhand think of the actual error message). You can keep the error successful message for verification if you write it directly to the error log, via: error_log(Insert successful.PHP_EOL); Sometimes, it's also nice to insert markers to let you know where the log is emanating from: error_log(__FILE__.'@'.__LINE__.': '.Insert successful.PHP_EOL); Sometimes, a vexing sort of error is a blank line at the top or bottom of a file, outside the ?..? Just before I got your e-mail, I found there were 3 spaces at the very top of the file in front of my ?PHP I was fit to be tied as they say in the south... But it is up and working properly now! Thank you all for your help with this! :) Jason Pruim li...@pruimphotography.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] 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.) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Odd Apache2/PHP Problem
I am having a really odd Apache2/PHP problem. My employer set up a new Web server to migrate our Web sites to. One site requires a log in and I have the ability to log in a someone else. However, when I do this, Apache throws a Segmentation fault error. It's happening when it tries to get user information from the database of the user I'm logged in as. The data is stored in a FoxPro database and is retrieved through ODBC. What is really odd is that the same functions work fine until I log in as someone. All this does is swap my id with the person I'm logging in as in the session variable. I have no idea why this is happening. So, I'm hoping someone may have some ideas or point in the right direction to find answers. Thanks! Floyd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Odd Apache2/PHP Problem
On Fri, Jun 3, 2011 at 15:12, Floyd Resler fres...@adex-intl.com wrote: I am having a really odd Apache2/PHP problem. My employer set up a new Web server to migrate our Web sites to. One site requires a log in and I have the ability to log in a someone else. However, when I do this, Apache throws a Segmentation fault error. It's happening when it tries to get user information from the database of the user I'm logged in as. The data is stored in a FoxPro database and is retrieved through ODBC. What is really odd is that the same functions work fine until I log in as someone. All this does is swap my id with the person I'm logging in as in the session variable. I have no idea why this is happening. So, I'm hoping someone may have some ideas or point in the right direction to find answers. A lot of times, this happens because of a bad module, poorly-compiled core or extension, missing dependencies, or even mismatched architecture (for example, trying to run x86_64 code on an i386 platform). Do you have the capability to recompile PHP and the extensions? Also, presuming the logs strictly show segmentation fault (which is less than helpful, I know), are there any filesystem logs that might give a hint, such as bad blocks on the drive? Have you tried running an fsck on the drive? Finally, you may want to check your core dumps and see if you can glean any hints from there. The file sizes themselves may even be helpful --- for example, are you running out of disk space or memory on that box when the code is executing? -- /Daniel P. Brown Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting (866-) 725-4321 http://www.parasane.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problem with PHP 5.3.3 under Debian/Squeeze
Hello *, since I have re-installed mail.tamay-dogan.net with Debian/Squeeze on a new machine, my /srv/log/apache/error.log ist arround 450 times bigger then the access.log du to following (and similar) entries [ '/srv/log/apache/error.log' ]- [Thu Mar 17 00:14:16 2011] [error] [client 89.204.153.240] PHP Notice: Use of undefined constant DIR_BASE - assumed 'DIR_BASE' in /srv/htdocs/index.php on line 3 [Thu Mar 17 00:14:16 2011] [error] [client 89.204.153.240] PHP Notice: Use of undefined constant DIR_TOOL - assumed 'DIR_TOOL' in /srv/htdocs/index.php on line 5 [Thu Mar 17 00:14:16 2011] [error] [client 89.204.153.240] PHP Notice: Use of undefined constant DEF_DIR_TOOL - assumed 'DEF_DIR_TOOL' in /srv/tdphp-vserver/includes/00_main.inc on line 42 [Thu Mar 17 00:14:16 2011] [error] [client 89.204.153.240] PHP Notice: Use of undefined constant DEF_DIR_BASE - assumed 'DEF_DIR_BASE' in /srv/tdphp-vserver/includes/00_main.inc on line 65 [Thu Mar 17 00:14:16 2011] [error] [client 89.204.153.240] PHP Notice: Use of undefined constant DIR_HOST - assumed 'DIR_HOST' in /srv/tdphp-vserver/includes/00_main.inc on line 88 [Thu Mar 17 00:14:16 2011] [error] [client 89.204.153.240] PHP Notice: Use of undefined constant SCRIPT_FILENAME - assumed 'SCRIPT_FILENAME' in /srv/tdphp-vserver/includes/00_main.inc on line 88 snip [ '/srv/htdocs/index.php' ]- ?php define(DIR_BASE, /srv); define(DIR_TOOL, /srv/tdphp-vserver); include DIR_TOOL . /includes/00_main.inc; ? Maybe I am sitting on the line? This index.php file and the website is working since ages. Whats the name of the error loging setting which produce this and WHY are they now reported? I have switched off anything but it continue to create more then 46 GByte error files (18) per day. Also I get [ '/srv/log/apache/error.log' ]- [Thu Mar 17 00:14:16 2011] [error] [client 89.204.153.240] PHP Notice: Undefined offset: 1 in /srv/tdphp-vserver/includes/04_l10n.inc on line 56 [Thu Mar 17 00:14:16 2011] [error] [client 89.204.153.240] PHP Notice: Undefined offset: 1 in /srv/tdphp-vserver/includes/04_l10n.inc on line 56 [Thu Mar 17 00:14:16 2011] [error] [client 89.204.153.240] PHP Notice: Undefined offset: 1 in /srv/tdphp-vserver/includes/04_l10n.inc on line 56 [Thu Mar 17 00:14:16 2011] [error] [client 89.204.153.240] PHP Notice: Undefined variable: locale in /srv/tdphp-vserver/includes/04_l10n.inc on line 74 [Thu Mar 17 00:14:16 2011] [error] [client 89.204.153.240] PHP Notice: Undefined index: what in /srv/tdphp-vserver/includes/00_main.inc on line 249 [Thu Mar 17 00:14:16 2011] [error] [client 89.204.153.240] PHP Notice: Undefined index: csslink in /srv/tdphp-vserver/includes/00_main.inc on line 284 [Thu Mar 17 00:14:16 2011] [error] [client 89.204.153.240] PHP Notice: Undefined index: cookie in /srv/tdphp-vserver/includes/00_main.inc on line 298 [ '/srv/tdphp-vserver/includes/04_l10n.inc' ]--- [0051] if ( $_SERVER['HTTP_ACCEPT_LANGUAGE'] != '') { [0052] foreach(explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $ACC1) { [0053] $ACC2=explode(';', $ACC1); [0054] $ACC3=explode('-', $ACC2[0]); [0055] $LL=$ACC3[0]; [0056] $CC=strtoupper($ACC3[1]); [0057] if ( $CC != '') { [0058] $LOC=$LL . _ . $CC; [0059] } else { [0060] $LOC=$LL; [0061] } [0062] if ( stristr( . LOCALES . , $LOC ) ) { [0063] $TMP_FILE=LOCALE_DIR . / . $LOC . /LC_MESSAGES/ . $_SERVER['SERVER_NAME'] . .mo; [0064] if (is_file($TMP_FILE)) { [0065] $locale=$LOC; [0066] break; [0067] } [0068] } [0069] } [0070] } else { [0071] $locale=(isset($_GET['lang']))? $_GET['lang'] : DEFAULT_LOCALE; [0072] } [0073] [0074] T_setlocale(LC_MESSAGES, $locale); [0075] $domain=$_SERVER['SERVER_NAME']; [0076] T_bind_textdomain_codeset($domain, $encoding); [0077] T_bindtextdomain($domain, LOCALE_DIR); [0078] T_textdomain($domain); [0079] /* *** END gettext stuff *** */ [0080] ? - [ '/srv/tdphp-vserver/includes/00_main.inc' ] [0248] /* DISPLAY admin * */ [0249] if ( $_POST['what'] == 'admin' ) { [0250] [0251] function do_auth() { snip [0283] /* *** FIX CSS */ [0284] if ($_GET['csslink'] != '') { [0285] if ($_GET['csslink'] == 'foo') { snip [0297] /* SET and UNSET COOKIES * */ [0298] if ( $_GET['cookie'] != '' ) { [0299] if ($_GET['cookie'] ==
Re: [PHP] Problem with PHP 5.3.3 under Debian/Squeeze
On Sunday, 20 March 2011 at 18:38, Michelle Konzack wrote: Hello *, since I have re-installed mail.tamay-dogan.net with Debian/Squeeze on a new machine, my /srv/log/apache/error.log ist arround 450 times bigger then the access.log du to following (and similar) entries [ '/srv/log/apache/error.log' ]- [Thu Mar 17 00:14:16 2011] [error] [client 89.204.153.240] PHP Notice: Use of undefined constant DIR_BASE - assumed 'DIR_BASE' in /srv/htdocs/index.php on line 3 [Thu Mar 17 00:14:16 2011] [error] [client 89.204.153.240] PHP Notice: Use of undefined constant DIR_TOOL - assumed 'DIR_TOOL' in /srv/htdocs/index.php on line 5 [Thu Mar 17 00:14:16 2011] [error] [client 89.204.153.240] PHP Notice: Use of undefined constant DEF_DIR_TOOL - assumed 'DEF_DIR_TOOL' in /srv/tdphp-vserver/includes/00_main.inc on line 42 [Thu Mar 17 00:14:16 2011] [error] [client 89.204.153.240] PHP Notice: Use of undefined constant DEF_DIR_BASE - assumed 'DEF_DIR_BASE' in /srv/tdphp-vserver/includes/00_main.inc on line 65 [Thu Mar 17 00:14:16 2011] [error] [client 89.204.153.240] PHP Notice: Use of undefined constant DIR_HOST - assumed 'DIR_HOST' in /srv/tdphp-vserver/includes/00_main.inc on line 88 [Thu Mar 17 00:14:16 2011] [error] [client 89.204.153.240] PHP Notice: Use of undefined constant SCRIPT_FILENAME - assumed 'SCRIPT_FILENAME' in /srv/tdphp-vserver/includes/00_main.inc on line 88 snip [ '/srv/htdocs/index.php' ]- ?php define(DIR_BASE, /srv); define(DIR_TOOL, /srv/tdphp-vserver); include DIR_TOOL . /includes/00_main.inc; ? Maybe I am sitting on the line? This index.php file and the website is working since ages. The first parameter of the define function should be a string. Whats the name of the error loging setting which produce this and WHY are they now reported? It would appear that your new server has defaulted to logging PHP notices. You can turn this off in your php.ini, or better yet fix the issues that are causing them. In my experience notices can often indicate more serious potential bugs. I have switched off anything but it continue to create more then 46 GByte error files (18) per day. Also I get [ '/srv/log/apache/error.log' ]- [Thu Mar 17 00:14:16 2011] [error] [client 89.204.153.240] PHP Notice: Undefined offset: 1 in /srv/tdphp-vserver/includes/04_l10n.inc on line 56 [Thu Mar 17 00:14:16 2011] [error] [client 89.204.153.240] PHP Notice: Undefined offset: 1 in /srv/tdphp-vserver/includes/04_l10n.inc on line 56 [Thu Mar 17 00:14:16 2011] [error] [client 89.204.153.240] PHP Notice: Undefined offset: 1 in /srv/tdphp-vserver/includes/04_l10n.inc on line 56 [Thu Mar 17 00:14:16 2011] [error] [client 89.204.153.240] PHP Notice: Undefined variable: locale in /srv/tdphp-vserver/includes/04_l10n.inc on line 74 [Thu Mar 17 00:14:16 2011] [error] [client 89.204.153.240] PHP Notice: Undefined index: what in /srv/tdphp-vserver/includes/00_main.inc on line 249 [Thu Mar 17 00:14:16 2011] [error] [client 89.204.153.240] PHP Notice: Undefined index: csslink in /srv/tdphp-vserver/includes/00_main.inc on line 284 [Thu Mar 17 00:14:16 2011] [error] [client 89.204.153.240] PHP Notice: Undefined index: cookie in /srv/tdphp-vserver/includes/00_main.inc on line 298 [ '/srv/tdphp-vserver/includes/04_l10n.inc' ]--- [0051] if ( $_SERVER['HTTP_ACCEPT_LANGUAGE'] != '') { [0052] foreach(explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $ACC1) { [0053] $ACC2=explode(';', $ACC1); [0054] $ACC3=explode('-', $ACC2[0]); [0055] $LL=$ACC3[0]; [0056] $CC=strtoupper($ACC3[1]); [0057] if ( $CC != '') { [0058] $LOC=$LL . _ . $CC; [0059] } else { [0060] $LOC=$LL; [0061] } [0062] if ( stristr( . LOCALES . , $LOC ) ) { [0063] $TMP_FILE=LOCALE_DIR . / . $LOC . /LC_MESSAGES/ . $_SERVER['SERVER_NAME'] . .mo; [0064] if (is_file($TMP_FILE)) { [0065] $locale=$LOC; [0066] break; [0067] } [0068] } [0069] } [0070] } else { [0071] $locale=(isset($_GET['lang']))? $_GET['lang'] : DEFAULT_LOCALE; [0072] } [0073] [0074] T_setlocale(LC_MESSAGES, $locale); [0075] $domain=$_SERVER['SERVER_NAME']; [0076] T_bind_textdomain_codeset($domain, $encoding); [0077] T_bindtextdomain($domain, LOCALE_DIR); [0078] T_textdomain($domain); [0079] /* *** END gettext stuff *** */ [0080] ? - Have a look at what $_SERVER['HTTP_ACCEPT_LANGUAGE'] is set to because it's clearly not in the format this code is expecting. [ '/srv/tdphp-vserver/includes/00_main.inc'
[PHP] problem compiling 5.3 with postgresql
I am having problems compiling 5.3.? with postgresql support. './configure' '--with-apxs2=/usr/local/apache2/bin/apxs' '--with-pdo-pgsql=/usr/local/postgresql-9.0.3' '--with-pgsql=/usr/local/postgresql-9.0.3' This configure works with 5.2.?, but 5.3.? gets this ext/standard/.libs/dns.o: In function `php_parserr': /usr/local/php-5.3.5/ext/standard/dns.c:418: undefined reference to `__dn_expand' and more lines like the last one. How can I fix this? I am using Ubuntu 10.10. JIm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problem with if and exact match
strpos example is much faster though On Tue, Mar 15, 2011 at 7:20 AM, Jack jacklistm...@gmail.com wrote: Thanks everyone... great examples...works ( both methods ) Thanks! Jack -Original Message- From: Alexis Antonakis [mailto:ad...@antonakis.co.uk] Sent: Tuesday, March 15, 2011 1:10 AM To: Jack Subject: Re: [PHP] problem with if and exact match http://php.net/manual/en/function.preg-match.php On 14/03/11 23:02, Jack wrote: I want to be able to match if a string is contained within the string I am evaluating. I know that if ( $name == xxjacksonxx); based on the below would be true. But I want to be able to say if jackson is contained within $name that it's a match. I tried the below without success.. Not getting the operand properly.. ? $name = xxjacksonxx; if ( preg_match($name, jackson)) { print true; } else { print false; } ? Thanks! Jack -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] problem with if and exact match
On Tue, 2011-03-15 at 01:20 -0400, Jack wrote: Thanks everyone... great examples...works ( both methods ) Thanks! Jack -Original Message- From: Alexis Antonakis [mailto:ad...@antonakis.co.uk] Sent: Tuesday, March 15, 2011 1:10 AM To: Jack Subject: Re: [PHP] problem with if and exact match http://php.net/manual/en/function.preg-match.php On 14/03/11 23:02, Jack wrote: I want to be able to match if a string is contained within the string I am evaluating. I know that if ( $name == xxjacksonxx); based on the below would be true. But I want to be able to say if jackson is contained within $name that it's a match. I tried the below without success.. Not getting the operand properly.. ? $name = xxjacksonxx; if ( preg_match($name, jackson)) { print true; } else { print false; } ? Thanks! Jack Wouldn't this be better to use, as it is meant to search for the string inside the string? (use use regex) if(stristr($name, 'Jackson')) { echo String is in String; } else { echo Failed; } http://ca.php.net/manual/en/function.strstr.php (case sensative) http://ca.php.net/manual/en/function.stristr.php (case insensative) Steve. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problem with if and exact match
On 03/15/2011 07:30 AM, Steve Staples wrote: Wouldn't this be better to use, as it is meant to search for the string inside the string? (use use regex) if(stristr($name, 'Jackson')) { echo String is in String; } else { echo Failed; } http://ca.php.net/manual/en/function.strstr.php (case sensative) http://ca.php.net/manual/en/function.stristr.php (case insensative) Steve. From your link: Note: If you only want to determine if a particular needle occurs within haystack, use the faster and less memory intensive function strpos() instead. -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] problem with if and exact match
I want to be able to match if a string is contained within the string I am evaluating. I know that if ( $name == xxjacksonxx); based on the below would be true. But I want to be able to say if jackson is contained within $name that it's a match. I tried the below without success.. Not getting the operand properly.. ? $name = xxjacksonxx; if ( preg_match($name, jackson)) { print true; } else { print false; } ? Thanks! Jack
Re: [PHP] problem with if and exact match
Try If(preg_match(/Jackson/i, $name)) {echo 'match'; }else{ echo 'fail'; } Richard Buskirk Sent from my iPhone On Mar 15, 2011, at 1:02 AM, Jack jacklistm...@gmail.com wrote: I want to be able to match if a string is contained within the string I am evaluating. I know that if ( $name == xxjacksonxx); based on the below would be true. But I want to be able to say if jackson is contained within $name that it's a match. I tried the below without success.. Not getting the operand properly.. ? $name = xxjacksonxx; if ( preg_match($name, jackson)) { print true; } else { print false; } ? Thanks! Jack -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problem with if and exact match
On 15/03/2011, at 6:02 PM, Jack wrote: I want to be able to match if a string is contained within the string I am evaluating. I know that if ( $name == xxjacksonxx); based on the below would be true. But I want to be able to say if jackson is contained within $name that it's a match. I tried the below without success.. Not getting the operand properly.. ? $name = xxjacksonxx; if ( preg_match($name, jackson)) { print true; } else { print false; } ? Thanks! Jack if(strpos($name, 'jackson') !== false) { true } You can use stripos for case-insentive matching. Using regex functions when you don't need the power is overkill and slower. Your call to preg_match wasn't working because you need your search term first, and it needs proper delimiters. --- Simon Welsh Admin of http://simon.geek.nz/ Who said Microsoft never created a bug-free program? The blue screen never, ever crashes! http://www.thinkgeek.com/brain/gimme.cgi?wid=81d520e5e -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] problem with if and exact match
Thanks everyone... great examples...works ( both methods ) Thanks! Jack -Original Message- From: Alexis Antonakis [mailto:ad...@antonakis.co.uk] Sent: Tuesday, March 15, 2011 1:10 AM To: Jack Subject: Re: [PHP] problem with if and exact match http://php.net/manual/en/function.preg-match.php On 14/03/11 23:02, Jack wrote: I want to be able to match if a string is contained within the string I am evaluating. I know that if ( $name == xxjacksonxx); based on the below would be true. But I want to be able to say if jackson is contained within $name that it's a match. I tried the below without success.. Not getting the operand properly.. ? $name = xxjacksonxx; if ( preg_match($name, jackson)) { print true; } else { print false; } ? Thanks! Jack -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with Include
On Tue, Dec 21, 2010 at 2:48 AM, Ravi Gehlot r...@ravigehlot.net wrote: My point is that you tried to Not me personally. take code from one page and put it all organized in another page and the include that page of includes back into the pages that you want it to feed off from. If stuff works the way that it does then there a reason for it to have been done that way. By the original designer, but maybe not the OP. That's why documenting code is so important. 99% doesn't do it (including me). For you, others, and for self, it's more than important, it can be essential, especially if you're trying to keep up with multiple languages, OS's, and platforms. Ravi. On Tue, Dec 21, 2010 at 2:35 AM, David Hutto smokefl...@gmail.com wrote: On Tue, Dec 21, 2010 at 2:29 AM, Ravi Gehlot r...@ravigehlot.net wrote: Why mess with something that is already working? If you are trying to make it pretty then you are not solving a problem. You are creating one. Define working. I've had programs 'work', but more experienced would say it's flawed in some respect. Does it perform the immediate task? Now define pretty. Is it aesthetically pleasing to you, or to someone else with less, or maybe more experience. By defining the two above, you then define whether it's a problem. To you, or to them, or to the original designer? Ravi. On Mon, Dec 20, 2010 at 7:40 AM, Daniel P. Brown daniel.br...@parasane.netwrote: On Mon, Dec 20, 2010 at 02:49, Simcha Younger sim...@syounger.com wrote: Since it is being included by PHP, and not served by Apache, the extension is not important. Correct, but keep in mind that it will likely be served as plain text if accessed directly, if the web server is not properly configured (which, by default, it isn't). -- /Daniel P. Brown Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting (866-) 725-4321 http://www.parasane.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- They're installing the breathalyzer on my email account next week. -- They're installing the breathalyzer on my email account next week. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with Include
On Tue, Dec 21, 2010 at 02:48, Ravi Gehlot r...@ravigehlot.net wrote: My point is that you tried to take code from one page and put it all organized in another page and the include that page of includes back into the pages that you want it to feed off from. If stuff works the way that it does then there a reason for it to have been done that way. So you think no one should ever do that because it's only making it look pretty? Ever hear of maintainability? That's why documenting code is so important. 99% doesn't do it (including me). Please cite your source. -- /Daniel P. Brown Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting (866-) 725-4321 http://www.parasane.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with Include
On Tue, Dec 21, 2010 at 9:50 AM, Daniel P. Brown daniel.br...@parasane.net wrote: On Tue, Dec 21, 2010 at 02:48, Ravi Gehlot r...@ravigehlot.net wrote: My point is that you tried to take code from one page and put it all organized in another page and the include that page of includes back into the pages that you want it to feed off from. If stuff works the way that it does then there a reason for it to have been done that way. So you think no one should ever do that because it's only making it look pretty? Ever hear of maintainability? That's why documenting code is so important. 99% doesn't do it (including me). Please cite your source. Personally, I'd even have to admit mine was less than 99% compatible with what I'd like it to be. -- /Daniel P. Brown Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting (866-) 725-4321 http://www.parasane.net/ -- They're installing the breathalyzer on my email account next week. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with Include
On Tue, Dec 21, 2010 at 9:54 AM, David Hutto smokefl...@gmail.com wrote: On Tue, Dec 21, 2010 at 9:50 AM, Daniel P. Brown daniel.br...@parasane.net wrote: On Tue, Dec 21, 2010 at 02:48, Ravi Gehlot r...@ravigehlot.net wrote: My point is that you tried to take code from one page and put it all organized in another page and the include that page of includes back into the pages that you want it to feed off from. If stuff works the way that it does then there a reason for it to have been done that way. So you think no one should ever do that because it's only making it look pretty? Ever hear of maintainability? That's why documenting code is so important. 99% doesn't do it (including me). Please cite your source. Personally, I'd even have to admit mine was(and is) less than 99% compatible with what I'd like it to be. -- /Daniel P. Brown Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting (866-) 725-4321 http://www.parasane.net/ -- They're installing the breathalyzer on my email account next week. -- They're installing the breathalyzer on my email account next week. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with Include
On Tue, Dec 21, 2010 at 02:35:33AM -0500, David Hutto wrote: On Tue, Dec 21, 2010 at 2:29 AM, Ravi Gehlot r...@ravigehlot.net wrote: Why mess with something that is already working? If you are trying to make it pretty then you are not solving a problem. You are creating one. Define working. I've had programs 'work', but more experienced would say it's flawed in some respect. Does it perform the immediate task? Now define pretty. Is it aesthetically pleasing to you, or to someone else with less, or maybe more experience. By defining the two above, you then define whether it's a problem. To you, or to them, or to the original designer? Beware of more experienced programmers. I recently talked to an ex-boss of mine who had a programmer flake out on him. One of his customers threatened to take this flaky code to another company and get their opinion about whether it was good code or not. My ex-boss explained that, of course, they'd shoot it down. Because that's what programmers do-- they complain about other programmers' code. I'd never heard that idea expressed aloud. But when I thought about it, I realized it was true. Hell, look at the content of this list. ;-} Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with Include
If something is working and you don't know exactly whats under the hood then you are wasting your time in trying to re-invent your own wheel and waste your time and resources to modify something that isn't needed to be touched. Good programmers make good use of their time as well. We need to keep in check with new technology, learn new trends and also master our weakness. If we keep changing this or that or moving that or this then oh well...there goes 1 day worth of work to figure stuff out. Just my take on this. If you think different, then no problems. Regards, Ravi. On Tue, Dec 21, 2010 at 10:23 AM, Paul M Foster pa...@quillandmouse.comwrote: On Tue, Dec 21, 2010 at 02:35:33AM -0500, David Hutto wrote: On Tue, Dec 21, 2010 at 2:29 AM, Ravi Gehlot r...@ravigehlot.net wrote: Why mess with something that is already working? If you are trying to make it pretty then you are not solving a problem. You are creating one. Define working. I've had programs 'work', but more experienced would say it's flawed in some respect. Does it perform the immediate task? Now define pretty. Is it aesthetically pleasing to you, or to someone else with less, or maybe more experience. By defining the two above, you then define whether it's a problem. To you, or to them, or to the original designer? Beware of more experienced programmers. I recently talked to an ex-boss of mine who had a programmer flake out on him. One of his customers threatened to take this flaky code to another company and get their opinion about whether it was good code or not. My ex-boss explained that, of course, they'd shoot it down. Because that's what programmers do-- they complain about other programmers' code. I'd never heard that idea expressed aloud. But when I thought about it, I realized it was true. Hell, look at the content of this list. ;-} Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with Include
(Apologies for top posting; on my mobile just now.) Not true. Refactoring code is one of the main tasks of a developer. None of us produce perfect code, and some code is less perfect than other code. It's instinct to want to fix bad code when we're maintaining it or having to add new features to it. For the same reason car enthusiasts tinker with and tune their cars, good developers will do the same with code, be it in the form of consolidating common code to include files or other ways. To not do so seems to me to avoid ones nature really! Thanks, Ash http://www.ashleysheridan.co.uk - Reply message - From: Ravi Gehlot r...@ravigehlot.net Date: Tue, Dec 21, 2010 18:12 Subject: [PHP] Problem with Include To: Paul M Foster pa...@quillandmouse.com Cc: php-general@lists.php.net If something is working and you don't know exactly whats under the hood then you are wasting your time in trying to re-invent your own wheel and waste your time and resources to modify something that isn't needed to be touched. Good programmers make good use of their time as well. We need to keep in check with new technology, learn new trends and also master our weakness. If we keep changing this or that or moving that or this then oh well...there goes 1 day worth of work to figure stuff out. Just my take on this. If you think different, then no problems. Regards, Ravi. On Tue, Dec 21, 2010 at 10:23 AM, Paul M Foster pa...@quillandmouse.comwrote: On Tue, Dec 21, 2010 at 02:35:33AM -0500, David Hutto wrote: On Tue, Dec 21, 2010 at 2:29 AM, Ravi Gehlot r...@ravigehlot.net wrote: Why mess with something that is already working? If you are trying to make it pretty then you are not solving a problem. You are creating one. Define working. I've had programs 'work', but more experienced would say it's flawed in some respect. Does it perform the immediate task? Now define pretty. Is it aesthetically pleasing to you, or to someone else with less, or maybe more experience. By defining the two above, you then define whether it's a problem. To you, or to them, or to the original designer? Beware of more experienced programmers. I recently talked to an ex-boss of mine who had a programmer flake out on him. One of his customers threatened to take this flaky code to another company and get their opinion about whether it was good code or not. My ex-boss explained that, of course, they'd shoot it down. Because that's what programmers do-- they complain about other programmers' code. I'd never heard that idea expressed aloud. But when I thought about it, I realized it was true. Hell, look at the content of this list. ;-} Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with Include
Hello, Good points. If you are getting paid to do that then fine. There is a difference between enhancing code and wasting time. I do my best to come up with the best I can. I always take notes to perform better in upcoming projects. It is imperative to make good use of time. Unless it is a security issue, no need to waste time. Again, if you are getting paid for it then fine. People tune cars for a reason, they want the attention or the thrill. If you want to tune your code for fun then nobody is against that either :) Ravi. On Tue, Dec 21, 2010 at 1:28 PM, a...@ashleysheridan.co.uk a...@ashleysheridan.co.uk wrote: (Apologies for top posting; on my mobile just now.) Not true. Refactoring code is one of the main tasks of a developer. None of us produce perfect code, and some code is less perfect than other code. It's instinct to want to fix bad code when we're maintaining it or having to add new features to it. For the same reason car enthusiasts tinker with and tune their cars, good developers will do the same with code, be it in the form of consolidating common code to include files or other ways. To not do so seems to me to avoid ones nature really! Thanks, Ash http://www.ashleysheridan.co.uk - Reply message - From: Ravi Gehlot r...@ravigehlot.net Date: Tue, Dec 21, 2010 18:12 Subject: [PHP] Problem with Include To: Paul M Foster pa...@quillandmouse.com Cc: php-general@lists.php.net If something is working and you don't know exactly whats under the hood then you are wasting your time in trying to re-invent your own wheel and waste your time and resources to modify something that isn't needed to be touched. Good programmers make good use of their time as well. We need to keep in check with new technology, learn new trends and also master our weakness. If we keep changing this or that or moving that or this then oh well...there goes 1 day worth of work to figure stuff out. Just my take on this. If you think different, then no problems. Regards, Ravi. On Tue, Dec 21, 2010 at 10:23 AM, Paul M Foster pa...@quillandmouse.com wrote: On Tue, Dec 21, 2010 at 02:35:33AM -0500, David Hutto wrote: On Tue, Dec 21, 2010 at 2:29 AM, Ravi Gehlot r...@ravigehlot.net wrote: Why mess with something that is already working? If you are trying to make it pretty then you are not solving a problem. You are creating one. Define working. I've had programs 'work', but more experienced would say it's flawed in some respect. Does it perform the immediate task? Now define pretty. Is it aesthetically pleasing to you, or to someone else with less, or maybe more experience. By defining the two above, you then define whether it's a problem. To you, or to them, or to the original designer? Beware of more experienced programmers. I recently talked to an ex-boss of mine who had a programmer flake out on him. One of his customers threatened to take this flaky code to another company and get their opinion about whether it was good code or not. My ex-boss explained that, of course, they'd shoot it down. Because that's what programmers do-- they complain about other programmers' code. I'd never heard that idea expressed aloud. But when I thought about it, I realized it was true. Hell, look at the content of this list. ;-} Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with Include
On Tue, Dec 21, 2010 at 1:28 PM, a...@ashleysheridan.co.uk a...@ashleysheridan.co.uk wrote: (Apologies for top posting; on my mobile just now.) Not true. Refactoring code is one of the main tasks of a developer. None of us produce perfect code, and some code is less perfect than other code. It's instinct to want to fix bad code when we're maintaining it or having to add new features to it. For the same reason car enthusiasts tinker with and tune their cars, good developers will do the same with code, be it in the form of consolidating common code to include files or other ways. To not do so seems to me to avoid ones nature really! Thanks, Ash http://www.ashleysheridan.co.uk - Reply message - From: Ravi Gehlot r...@ravigehlot.net Date: Tue, Dec 21, 2010 18:12 Subject: [PHP] Problem with Include To: Paul M Foster pa...@quillandmouse.com Cc: php-general@lists.php.net If something is working and you don't know exactly whats under the hood then you are wasting your time in trying to re-invent your own wheel and waste your time and resources to modify something that isn't needed to be touched. Good programmers make good use of their time as well. We need to keep in check with new technology, learn new trends and also master our weakness. If we keep changing this or that or moving that or this then oh well...there goes 1 day worth of work to figure stuff out. Just my take on this. If you think different, then no problems. Regards, Ravi. On Tue, Dec 21, 2010 at 10:23 AM, Paul M Foster pa...@quillandmouse.comwrote: On Tue, Dec 21, 2010 at 02:35:33AM -0500, David Hutto wrote: On Tue, Dec 21, 2010 at 2:29 AM, Ravi Gehlot r...@ravigehlot.net wrote: Why mess with something that is already working? If you are trying to make it pretty then you are not solving a problem. You are creating one. Define working. I've had programs 'work', but more experienced would say it's flawed in some respect. Does it perform the immediate task? Now define pretty. Is it aesthetically pleasing to you, or to someone else with less, or maybe more experience. By defining the two above, you then define whether it's a problem. To you, or to them, or to the original designer? Beware of more experienced programmers. I recently talked to an ex-boss of mine who had a programmer flake out on him. One of his customers threatened to take this flaky code to another company and get their opinion about whether it was good code or not. My ex-boss explained that, of course, they'd shoot it down. Because that's what programmers do-- they complain about other programmers' code. I'd never heard that idea expressed aloud. But when I thought about it, I realized it was true. Hell, look at the content of this list. ;-} Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php +1 -- Bastien Cat, the other other white meat -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with Include
On Mon, Dec 20, 2010 at 02:49, Simcha Younger sim...@syounger.com wrote: Since it is being included by PHP, and not served by Apache, the extension is not important. Correct, but keep in mind that it will likely be served as plain text if accessed directly, if the web server is not properly configured (which, by default, it isn't). -- /Daniel P. Brown Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting (866-) 725-4321 http://www.parasane.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php