[PHP] Problems with array_push?
I know that I must be missing something really ridiculous, but when I print_r these arrays they are empty. I have confirmed that $arrayElement is properly formed, it just seems that array_push is not working. I know I have done this before, but I cannot find my older code. Can someone clear the mud from my eyes? $issueDifferently = array(); $issueProblem = array(); $issueComment = array(); function addToArray($id, $namecred, $product, $level, $type, $message) { $arrayElement = $id .'|'.$namecred.'|'.$product.'|'.$level.'|'.$type.'|'.$message; if('DoDifferently' == $type) { array_push($issueDifferently, $arrayElement); } elseif ('Problem' == $type){ array_push($issueProblem, $arrayElement); } elseif ('Comments' == $type) { array_push($issueComment, $arrayElement); } } print_r($issueDifferently); print_r($issueProblem); print_r($issueComment); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems with array_push?
Globals being used in a function. -Stuart On Tue, May 7, 2013 at 11:06 PM, Jay Blanchard jay.blanch...@sigmaphinothing.org wrote: I know that I must be missing something really ridiculous, but when I print_r these arrays they are empty. I have confirmed that $arrayElement is properly formed, it just seems that array_push is not working. I know I have done this before, but I cannot find my older code. Can someone clear the mud from my eyes? $issueDifferently = array(); $issueProblem = array(); $issueComment = array(); function addToArray($id, $namecred, $product, $level, $type, $message) { $arrayElement = $id .'|'.$namecred.'|'.$product.'|'.$level.'|'.$type.'|'.$message; if('DoDifferently' == $type) { array_push($issueDifferently, $arrayElement); } elseif ('Problem' == $type){ array_push($issueProblem, $arrayElement); } elseif ('Comments' == $type) { array_push($issueComment, $arrayElement); } } print_r($issueDifferently); print_r($issueProblem); print_r($issueComment); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems with array_push?
On Tue, May 7, 2013 at 3:06 PM, Jay Blanchard jay.blanch...@sigmaphinothing.org wrote: I know that I must be missing something really ridiculous, but when I print_r these arrays they are empty. I have confirmed that $arrayElement is properly formed, it just seems that array_push is not working. I know I have done this before, but I cannot find my older code. Can someone clear the mud from my eyes? $issueDifferently = array(); $issueProblem = array(); $issueComment = array(); function addToArray($id, $namecred, $product, $level, $type, $message) { $arrayElement = $id .'|'.$namecred.'|'.$product.'|'.$level.'|'.$type.'|'.$message; if('DoDifferently' == $type) { array_push($issueDifferently, $arrayElement); } elseif ('Problem' == $type){ array_push($issueProblem, $arrayElement); } elseif ('Comments' == $type) { array_push($issueComment, $arrayElement); } } print_r($issueDifferently); print_r($issueProblem); print_r($issueComment); You have to declare the arrays as global inside your function. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems with array_push?
[snip]Globals being used in a function. [/snip] *smacks forehead* -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems with array_push?
On Tue, May 7, 2013 at 4:28 PM, Jay Blanchard jay.blanch...@sigmaphinothing.org wrote: [snip]Globals being used in a function. [/snip] *smacks forehead* It bites me all the time, too. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems with array_push?
On Tue, May 7, 2013 at 9:42 PM, tamouse mailing lists tamouse.li...@gmail.com wrote: On Tue, May 7, 2013 at 4:28 PM, Jay Blanchard jay.blanch...@sigmaphinothing.org wrote: [snip]Globals being used in a function. [/snip] *smacks forehead* It bites me all the time, too. (Might be worth a refactor to eliminate globals from this, in fact? I honestly do not see the benefit to embedding that into a function like that.) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] problems in extension development
hi, I just started to write a simple PHP extension hello, but encountered some problems. I followed tutorials step by step: 1. ./ext_skel --extname=hello 2. modified hello.c and php_hello.h, and wrote function hello_world() which simply return a string hello world. 3. phpize 4. ./configure ; make ; 5. the I encountered error in make. I looked up in Makefile and found that $(PHP_MODULE) is null, which I think is the reason. Makefile is automatically generated by ./configure. What mistake did I make? How to fix it? Thanks! Vic Hu -- Best regards, Rui Hu State Key Laboratory of Networking Switching Technology Beijing University of Posts and Telecommunications(BUPT) MSN: tchrb...@gmail.com -
Re: [PHP] Problems with CURL using an HTTP Proxy on PHP5
On Fri, Dec 16, 2011 at 10:09 PM, Francisco M. Marzoa Alonso franci...@marzoa.com wrote: I know it is NOT a problem with the website, because if I comment out the line curl_setopt ($ch, CURLOPT_HTTPPROXYTUNNEL, 1) disabling the use of a proxy, it works fine. I know the proxy is working fine, because if I use curl from command line like: curl -x 1.2.3.4: http://mycheckhost.com/ CURLOPT_HTTPPROXYTUNNEL is not for enabling/disabling proxy, it's for proxy tunneling. On the command line you should try curl --proxytunnel -x 1.2.3.4: http://mycheckhost.com/ to check if tunneling works. Do you really need a tunnel? Cheers, Matijn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problems with CURL using an HTTP Proxy on PHP5
Hello, The following code is failing and I do not find the cause (please, note that checkurl value and CURLOPT_PROXY are NOT the real values I'm using, of course): $ch = curl_init(); $checkurl = 'http://mycheckhost.com/'; curl_setopt ($ch, CURLOPT_TIMEOUT, 6000); curl_setopt ($ch, CURLOPT_URL, $checkurl); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt ($ch, CURLOPT_HEADER, false); curl_setopt ($ch, CURLOPT_HTTPPROXYTUNNEL, 1); curl_setopt ($ch, CURLOPT_PROXY, '1.2.3.4:' ); $data = curl_exec($ch); $curl_info = curl_getinfo ($ch); if ( $data === false ) { $rtn = false; } else { $rtn = true; } return $rtn; Every curl_exec returns false, and a var_dump of $curl_info looks as follows: array(21) { [url]= string(25) http://mycheckhost.com/; [content_type]= NULL [http_code]= int(0) [header_size]= int(0) [request_size]= int(99) [filetime]= int(-1) [ssl_verify_result]= int(0) [redirect_count]= int(0) [total_time]= float(1.843925) [namelookup_time]= float(0.00018) [connect_time]= float(0.333015) [pretransfer_time]= float(0) [size_upload]= float(0) [size_download]= float(0) [speed_download]= float(0) [speed_upload]= float(0) [download_content_length]= float(-1) [upload_content_length]= float(-1) [starttransfer_time]= float(0) [redirect_time]= float(0) [certinfo]= array(0) { } } I know it is NOT a problem with the website, because if I comment out the line curl_setopt ($ch, CURLOPT_HTTPPROXYTUNNEL, 1) disabling the use of a proxy, it works fine. I know the proxy is working fine, because if I use curl from command line like: curl -x 1.2.3.4: http://mycheckhost.com/ It also WORKS fine. So the problem may be or within the PHP5 curl implementation, or in my own code, but I have not been able to find the problem with my code. Any hints? BTW: $ php --version PHP 5.3.6-13ubuntu3.3 with Suhosin-Patch (cli) (built: Dec 13 2011 18:37:10) Copyright (c) 1997-2011 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies Thanks a lot in advance, -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problems with proc_open and getmypid
Hello, I'm developing a PHP application that runs on GNU/Linux with php cli. A process must launch another one and store its pid, so I use proc_open and then proc_status to achieve that. The child process must also get its own pid and write it down to a file. After that, the calling process should compare both pids and they should match, but in fact they shoudln't. The problem is that when calling to proc_open like: $res = proc_open (/usr/bin/php proc2.php, array(), $pipes); Two processes are created, one for the sh shell that launchs the php interpreter, and another for the php interpreter itself. Also, it seems like proc_get_status($res) returns the status of the sh, while getmypid in the second process returns the pid of the php interpreter. I wonder if there's anyway of do something of these: a) Get the pid of the php interpreter on proc_open instead of the sh one on the parent process, or... b) Get the pid of the sh process instead of the php interpreter on the child process. Or any manner in which two pids matches. Thanks a lot in advance, -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problems with interoperability: MCrypt AES PHP x Java
Hi, I am having problems while trying to decrypt an encrypted string (generated from a java system) in PHP. To take external factors out of the way I decided to make them work first in my local system. So I've created a sample encrypt/decrypt from PHP (using mcrypt's extension) and the java code found at http://java.sun.com/developer/technicalArticles/Security/AES/AES_v1.html. I've added a System.out.println(KEY: + asHex(raw)); to get the key used in the java and set the same in PHP. There is no mention in Java but since I didn't see a initialization vector I assume we are use ECB mode. Unfortunately the same string /key produces different encrypted values.
[PHP] Problems with pear install
Hi I can`t open the pear set up executing the go-pear.bat file. Alejandro
[PHP] Problems with PDO and LOB columns in mysql
Hi. The code I use to extract the data from a query which was just performed looks like this: $data = array(); $receiverRow = array(); $i = 0; foreach ($columns as $column = $type) $statement-bindColumn($i++, $receiverRow[$column], $type); while ($statement-fetch(PDO::FETCH_BOUND)) { $row = array(); foreach ($columns as $column = $type) $row[$column] = $receiverRow[$column]; $data[] = $row; } I know there is a record that fetch should fetch, since $statement- rowCount() says so. Everything works really well, and even if I check $statement-errorInfo() and $statement-errorCode() after each operation with the database, I can see no error. The types with which the variables are bound are also right. However, the $statement-fetch() inside the the while statement returns false at the very first call, so I can't fetch anything from within the $statement. There is no exception, no non-zero value in $statement-errorInfo(), and $statement-errorCode() says uninitialized. So I don't know what actually went wrong. The entire process happens inside a transaction. At the end, finding out that the record was not retrieved, the transaction is rolled back. The statement is an insert following by a select. When calling PDO::lastInsertId, I get a proper value, which means the insert is succesful. When checking $statement-rowCount() I also get a count of 1, which means the select also worked properly. I just fail to fetch the just inserted record into some PHP variables. What am I doing wrong? As far as I can tell, I did everything as the manual says. br, -- Fine counsel is confusing, but example is always clear. (Edgar A. Guest, The Light of Faith) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: [PHP-DB] Re: [PHP] Problems w/ goto
On Sat, Dec 18, 2010 at 17:02, David Hutto smokefl...@gmail.com wrote: or maybe it's saturday morning and i'm drunk? This seems to be the most likely, and considering how all messages are permanently and independently archived and propagate throughout the Internet, it might be a good reason not to go nuts in sending unrelated and unintelligible messages of this nature in the future. -- /Daniel P. Brown Network Infrastructure Manager Documentation, Webmaster Teams http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: [PHP-DB] Re: [PHP] Problems w/ goto
On Mon, Dec 20, 2010 at 7:37 AM, Daniel Brown danbr...@php.net wrote: On Sat, Dec 18, 2010 at 17:02, David Hutto smokefl...@gmail.com wrote: or maybe it's saturday morning and i'm drunk? This seems to be the most likely, and considering how all messages are permanently and independently archived and propagate throughout the Internet, it might be a good reason not to go nuts in sending unrelated and unintelligible messages of this nature in the future. Yeah, that hindsights 20/20 ain't it? -- /Daniel P. Brown Network Infrastructure Manager Documentation, Webmaster Teams http://www.php.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] Problems w/ goto
On Fri, Dec 17, 2010 at 10:05 AM, la...@garfieldtech.com la...@garfieldtech.com wrote: What PHP has implemented is named break statements, as I understand it. Not exactly. You can jump to arbitrary (labeled) lines within the same context (method/function), but you cannot enter loop constructs--only exit them. While the last bit implies they are only named break statements, you can use them outside of loops as a normal goto statement. firingSequence: if (!acquireTarget()) goto done; fireMainCannon(); fireMissiles(); if (enemiesInView()): goto firingSequence; done: The above implements a convoluted do...while loop using goto. Recommended? Certainly not! David
Re: [PHP] Problems w/ goto
On Mon, Dec 20, 2010 at 4:47 PM, David Harkness davi...@highgearmedia.com wrote: On Fri, Dec 17, 2010 at 10:05 AM, la...@garfieldtech.com la...@garfieldtech.com wrote: What PHP has implemented is named break statements, as I understand it. Not exactly. You can jump to arbitrary (labeled) lines within the same context (method/function), but you cannot enter loop constructs--only exit them. While the last bit implies they are only named break statements, you can use them outside of loops as a normal goto statement. firingSequence: if (!acquireTarget()) goto done; fireMainCannon(); fireMissiles(); if (enemiesInView()): goto firingSequence; done: The above implements a convoluted do...while loop using goto. Recommended? Is the problem with using the goto convolutedness(as I've seen other senior programmers in other languages when explaining, or 'showing off'), or is their an actual functional problem with it? Is it just the 'sphagetti code' aspect that it can lead to, meaning confusing another programmer? Not to hijack from the op, or dilute the conversation any further than I did over the weekend. Certainly not! David -- 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] Problems w/ goto
On Mon, Dec 20, 2010 at 7:45 PM, David Hutto smokefl...@gmail.com wrote: Is the problem with using the goto convolutedness(as I've seen other senior programmers in other languages when explaining, or 'showing off'), or is their an actual functional problem with it? It works perfectly well and is a great solution in extremely limited cases. The problem is that it can be used in many cases where other control flow statements are more clear. It was more of a problem before because people came from languages that had goto but not the other high-level control flow statements. Using goto often leads to hard-to-follow code. For example, rearranging the above code yields do { if (!acquireTarget()) { break; fireMainCannon(); fireMissiles(); } while (enemiesInView()); Even this doesn't get away from using break--a special form of goto for loops. One way around that is to introduce a loop variable like $done, but I think break is cleaner here. Sometimes goto, break, and continue are simply the best tools for the job. I wouldn't say never use goto, but I do feel that 99 times out of 100 you're probably better off using something else. One thing to keep in mind is that under the hood the PHP interpreter turns while(), for(), etc. into a bunch of gotos. for ( init ; check ; increment ) block is just a shorter way to write init goto check; loop: block increment check: if (check) goto loop; The same can be done for all the other control flow statements. David
RE: [PHP] Problems w/ goto
Ethan, I tried to test your code, but I get this error next to the labels and goto statements: Language feature not compatible with PHP version indicated in project settings I have PHP 5.3.0. Geoffrey _ From: Ethan Rosenberg [mailto:eth...@earthlink.net] Sent: 17 December 2010 06:39 PM To: php-db-lists.php.net; php-general@lists.php.net Subject: [PHP] Problems w/ goto Dear List - I am sending this again since it does not seem to have posted. Ethan +++ Dear List - Thank you with your excellent help in the past. Here is another puzzler I am trying to write a program that can have two(2) independent forms in one PHP file. When I run the code below [from PHP - A Beginner's Guide], to which I have added a second form, it freezes. Without the goto statements, it runs. When it does run, it displays both forms on one Web screen. What I desire is for the first form to be displayed, the data entered and then the second form displayed. In an actual, not test program like this one, the data in the second form would be dependent on the first form. What did I do wrong? Thanks in advance. Here is the code: !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN DTD/xhtml1-transitional.dtd html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en head titleProject 4-4: Age Calculator/title /head body h2Project 4-4: Age Calculator/h2 ?php // if form not yet submitted // display form $ender = 0; begin: if($ender == 1) exit(); if (!isset($_POST['dob'])) { start1: echo form method=\post\ action=\agecalc2.php\; echo Enter your date of birth, in mm/dd/ format: br /; echo input type=\text\ name=\dob\ /; echo p; echo input type=\submit\ name=\submit\ value=\Submit\ /; echo /form; goto begin; // if form submitted // process form input } else { starter: if (isset($_POST['cat'])) goto purr; // split date value into components $dateArr = explode('/', $_POST['dob']); // calculate timestamp corresponding to date value $dateTs = strtotime($_POST['dob']); // calculate timestamp corresponding to 'today' $now = strtotime('today'); // check that the value entered is in the correct format if (sizeof($dateArr) != 3) { die('ERROR: Please enter a valid date of birth'); } // check that the value entered is a valid date if (!checkdate($dateArr[0], $dateArr[1], $dateArr[2])) { die('ERROR: Please enter a valid date of birth'); } // check that the date entered is earlier than 'today' if ($dateTs = $now) { die('ERROR: Please enter a date of birth earlier than today'); } // calculate difference between date of birth and today in days // convert to years // convert remaining days to months // print output $ageDays = floor(($now - $dateTs) / 86400); $ageYears = floor($ageDays / 365); $ageMonths = floor(($ageDays - ($ageYears * 365)) / 30); echo You are approximately $ageYears years and $ageMonths months old.; goto meow; } meow: if (!isset($_POST['dob'])) goto begin; if (!isset($_POST['cat'])) { echo form method=\post\ action=\agecalc2.php\; echo br /br /Enter your kitten's name: br /; echo input type=\text\ name=\cat\ /; echo p; echo input type=\submit\ name=\submit\ value=\Submit Kitten\ /; echo /form; } else { purr: $name_cat = $_POST['cat']; echo Your Kitten is $name_cat; $ender = 1; } if ($ender == 0) goto begin; first_step: ? /body /html Ethan MySQL 5.1 PHP 5 Linux [Debian (sid)] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ No virus found in this message. Checked by AVG - www.avg.com Version: 10.0.1170 / Virus Database: 1435/3323 - Release Date: 12/18/10
Re: [PHP] Problems w/ goto
On Sat, Dec 18, 2010 at 12:45 PM, Geoffrey Bernardo Van Wyk geoffrey.van@gmail.com wrote: Ethan, I tried to test your code, but I get this error next to the labels and goto statements: As a 'professional' programmer, working for an entity, we deal with these problems as we go. As novices, we deal with it on a daily basis. As computer scientists, we think of it as a problem already solved, but in need of translation. Understand, buddy pal. Language feature not compatible with PHP version indicated in project settings I have PHP 5.3.0. Geoffrey _ From: Ethan Rosenberg [mailto:eth...@earthlink.net] Sent: 17 December 2010 06:39 PM To: php-db-lists.php.net; php-general@lists.php.net Subject: [PHP] Problems w/ goto Dear List - I am sending this again since it does not seem to have posted. Ethan +++ Dear List - Thank you with your excellent help in the past. Here is another puzzler I am trying to write a program that can have two(2) independent forms in one PHP file. When I run the code below [from PHP - A Beginner's Guide], to which I have added a second form, it freezes. Without the goto statements, it runs. When it does run, it displays both forms on one Web screen. What I desire is for the first form to be displayed, the data entered and then the second form displayed. In an actual, not test program like this one, the data in the second form would be dependent on the first form. What did I do wrong? Thanks in advance. Here is the code: !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN DTD/xhtml1-transitional.dtd html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en head titleProject 4-4: Age Calculator/title /head body h2Project 4-4: Age Calculator/h2 ?php // if form not yet submitted // display form $ender = 0; begin: if($ender == 1) exit(); if (!isset($_POST['dob'])) { start1: echo form method=\post\ action=\agecalc2.php\; echo Enter your date of birth, in mm/dd/ format: br /; echo input type=\text\ name=\dob\ /; echo p; echo input type=\submit\ name=\submit\ value=\Submit\ /; echo /form; goto begin; // if form submitted // process form input } else { starter: if (isset($_POST['cat'])) goto purr; // split date value into components $dateArr = explode('/', $_POST['dob']); // calculate timestamp corresponding to date value $dateTs = strtotime($_POST['dob']); // calculate timestamp corresponding to 'today' $now = strtotime('today'); // check that the value entered is in the correct format if (sizeof($dateArr) != 3) { die('ERROR: Please enter a valid date of birth'); } // check that the value entered is a valid date if (!checkdate($dateArr[0], $dateArr[1], $dateArr[2])) { die('ERROR: Please enter a valid date of birth'); } // check that the date entered is earlier than 'today' if ($dateTs = $now) { die('ERROR: Please enter a date of birth earlier than today'); } // calculate difference between date of birth and today in days // convert to years // convert remaining days to months // print output $ageDays = floor(($now - $dateTs) / 86400); $ageYears = floor($ageDays / 365); $ageMonths = floor(($ageDays - ($ageYears * 365)) / 30); echo You are approximately $ageYears years and $ageMonths months old.; goto meow; } meow: if (!isset($_POST['dob'])) goto begin; if (!isset($_POST['cat'])) { echo form method=\post\ action=\agecalc2.php\; echo br /br /Enter your kitten's name: br /; echo input type=\text\ name=\cat\ /; echo p; echo input type=\submit\ name=\submit\ value=\Submit Kitten\ /; echo /form; } else { purr: $name_cat = $_POST['cat']; echo Your Kitten is $name_cat; $ender = 1; } if ($ender == 0) goto begin; first_step: ? /body /html Ethan MySQL 5.1 PHP 5 Linux [Debian (sid)] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ No virus found in this message. Checked by AVG - www.avg.com Version: 10.0.1170 / Virus Database: 1435/3323 - Release Date: 12/18/10 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems w/ goto
You approved all of us, no matter the peer review, when you signed up or the list. The accumulation of knowledge, is insurmountable when delivered as a whole, but devourable if you need satiation of appetite. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems w/ goto
or maybe it's saturday morning and i'm drunk? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems w/ goto
check out my new sig. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problems w/ goto
Dear List - I am sending this again since it does not seem to have posted. Ethan +++ Dear List - Thank you with your excellent help in the past. Here is another puzzler I am trying to write a program that can have two(2) independent forms in one PHP file. When I run the code below [from PHP - A Beginner's Guide], to which I have added a second form, it freezes. Without the goto statements, it runs. When it does run, it displays both forms on one Web screen. What I desire is for the first form to be displayed, the data entered and then the second form displayed. In an actual, not test program like this one, the data in the second form would be dependent on the first form. What did I do wrong? Thanks in advance. Here is the code: !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN DTD/xhtml1-transitional.dtd html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en head titleProject 4-4: Age Calculator/title /head body h2Project 4-4: Age Calculator/h2 ?php // if form not yet submitted // display form $ender = 0; begin: if($ender == 1) exit(); if (!isset($_POST['dob'])) { start1: echo form method=\post\ action=\agecalc2.php\; echo Enter your date of birth, in mm/dd/ format: br /; echo input type=\text\ name=\dob\ /; echo p; echo input type=\submit\ name=\submit\ value=\Submit\ /; echo /form; goto begin; // if form submitted // process form input } else { starter: if (isset($_POST['cat'])) goto purr; // split date value into components $dateArr = explode('/', $_POST['dob']); // calculate timestamp corresponding to date value $dateTs = strtotime($_POST['dob']); // calculate timestamp corresponding to 'today' $now = strtotime('today'); // check that the value entered is in the correct format if (sizeof($dateArr) != 3) { die('ERROR: Please enter a valid date of birth'); } // check that the value entered is a valid date if (!checkdate($dateArr[0], $dateArr[1], $dateArr[2])) { die('ERROR: Please enter a valid date of birth'); } // check that the date entered is earlier than 'today' if ($dateTs = $now) { die('ERROR: Please enter a date of birth earlier than today'); } // calculate difference between date of birth and today in days // convert to years // convert remaining days to months // print output $ageDays = floor(($now - $dateTs) / 86400); $ageYears = floor($ageDays / 365); $ageMonths = floor(($ageDays - ($ageYears * 365)) / 30); echo You are approximately $ageYears years and $ageMonths months old.; goto meow; } meow: if (!isset($_POST['dob'])) goto begin; if (!isset($_POST['cat'])) { echo form method=\post\ action=\agecalc2.php\; echo br /br /Enter your kitten's name: br /; echo input type=\text\ name=\cat\ /; echo p; echo input type=\submit\ name=\submit\ value=\Submit Kitten\ /; echo /form; } else { purr: $name_cat = $_POST['cat']; echo Your Kitten is $name_cat; $ender = 1; } if ($ender == 0) goto begin; first_step: ? /body /html Ethan MySQL 5.1 PHP 5 Linux [Debian (sid)] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Problems w/ goto
[snip] Thank you with your excellent help in the past. Here is another puzzler I am trying to write a program that can have two(2) independent forms in one PHP file. When I run the code below [from PHP - A Beginner's Guide], to which I have added a second form, it freezes. Without the goto statements, it runs. When it does run, it displays both forms on one Web screen. What I desire is for the first form to be displayed, the data entered and then the second form displayed. In an actual, not test program like this one, the data in the second form would be dependent on the first form. What did I do wrong? [/snip] You used GOTO. In this case I would recommend using something like jQuery to 'hide' one form until the other form is complete. PHP has sent the output to the browser already, both forms are there and display when you remove the GOTO. GOTO should never be used like this. GOTO should never be used. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Problems w/ goto
On Fri, 2010-12-17 at 10:50 -0600, Jay Blanchard wrote: [snip] Thank you with your excellent help in the past. Here is another puzzler I am trying to write a program that can have two(2) independent forms in one PHP file. When I run the code below [from PHP - A Beginner's Guide], to which I have added a second form, it freezes. Without the goto statements, it runs. When it does run, it displays both forms on one Web screen. What I desire is for the first form to be displayed, the data entered and then the second form displayed. In an actual, not test program like this one, the data in the second form would be dependent on the first form. What did I do wrong? [/snip] You used GOTO. In this case I would recommend using something like jQuery to 'hide' one form until the other form is complete. PHP has sent the output to the browser already, both forms are there and display when you remove the GOTO. GOTO should never be used like this. GOTO should never be used. Wow... that brought me back to 1990... using basic and batch files... I honestly didn't even know that the GOTO was still in existence, especially within PHP. I had to show the people in my office, and we all got a chuckle from teh XKCD comic in the PHP documentation for GOTO http://ca2.php.net/goto Steve -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems w/ goto
On 17 December 2010 17:08, Steve Staples sstap...@mnsi.net wrote: On Fri, 2010-12-17 at 10:50 -0600, Jay Blanchard wrote: [snip] Thank you with your excellent help in the past. Here is another puzzler I am trying to write a program that can have two(2) independent forms in one PHP file. When I run the code below [from PHP - A Beginner's Guide], to which I have added a second form, it freezes. Without the goto statements, it runs. When it does run, it displays both forms on one Web screen. What I desire is for the first form to be displayed, the data entered and then the second form displayed. In an actual, not test program like this one, the data in the second form would be dependent on the first form. What did I do wrong? [/snip] You used GOTO. In this case I would recommend using something like jQuery to 'hide' one form until the other form is complete. PHP has sent the output to the browser already, both forms are there and display when you remove the GOTO. GOTO should never be used like this. GOTO should never be used. Wow... that brought me back to 1990... using basic and batch files... I honestly didn't even know that the GOTO was still in existence, especially within PHP. I had to show the people in my office, and we all got a chuckle from teh XKCD comic in the PHP documentation for GOTO http://ca2.php.net/goto Steve -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php And have you seen all the sad faces ... : { on http://docs.php.net/manual/en/control-structures.goto.php#92763 Can't be good for them. -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems w/ goto
On Dec 17, 2010, at 11:08 AM, Steve Staples wrote: [snip /] GOTO should never be used like this. GOTO should never be used. Wow... that brought me back to 1990... using basic and batch files... I honestly didn't even know that the GOTO was still in existence, especially within PHP. I had to show the people in my office, and we all got a chuckle from teh XKCD comic in the PHP documentation for GOTO http://ca2.php.net/goto Steve I didn't know it existed in PHP either. The cartoon is priceless. I should probably hang that up in my office somewhere.
Re: [PHP] Problems w/ goto
On Fri, 2010-12-17 at 12:22 -0500, Robert Cummings wrote: On 10-12-17 12:08 PM, Steve Staples wrote: On Fri, 2010-12-17 at 10:50 -0600, Jay Blanchard wrote: [snip] Thank you with your excellent help in the past. Here is another puzzler I am trying to write a program that can have two(2) independent forms in one PHP file. When I run the code below [from PHP - A Beginner's Guide], to which I have added a second form, it freezes. Without the goto statements, it runs. When it does run, it displays both forms on one Web screen. What I desire is for the first form to be displayed, the data entered and then the second form displayed. In an actual, not test program like this one, the data in the second form would be dependent on the first form. What did I do wrong? [/snip] You used GOTO. In this case I would recommend using something like jQuery to 'hide' one form until the other form is complete. PHP has sent the output to the browser already, both forms are there and display when you remove the GOTO. GOTO should never be used like this. GOTO should never be used. Wow... that brought me back to 1990... using basic and batch files... I honestly didn't even know that the GOTO was still in existence, especially within PHP. I had to show the people in my office, and we all got a chuckle from teh XKCD comic in the PHP documentation for GOTO http://ca2.php.net/goto Steve I was one of the people that argued in favour of GOTO on the Internals list a few years ago. GOTO has a use, and a very good one at that. It is by far the most efficient construct when creating parsers or other similar types of logic flow. The demonized GOTO of the 80s was primarily due to jumping to arbitrary points in the code, or in the case of basic to arbitrary line numbers in the code which had little meaning for future readers. When used properly within a well defined scope and with well named labels, GOTO can be a superior choice. If you think GOTO doesn't exist in many types of software, you need only grep for it in the C source code for PHP, MySQL, and Apache. Cheers, Rob. Oh, i can see where it would be useful, i just hadn't realized it was still in existence... and the cartoon, was blown up, and put in my cubical :) RAWR!! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: [PHP-DB] Re: [PHP] Problems w/ goto
On Fri, Dec 17, 2010 at 12:16, Richard Quadling rquadl...@gmail.com wrote: And have you seen all the sad faces ... : { on http://docs.php.net/manual/en/control-structures.goto.php#92763 Can't be good for them. If only people knew how many hours - literally, hours - it took me to keep that page clean and free from vandalism after GOTO was introduced. -- /Daniel P. Brown Network Infrastructure Manager Documentation, Webmaster Teams http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems w/ goto
On Fri, Dec 17, 2010 at 12:22, Robert Cummings rob...@interjinn.com wrote: I was one of the people that argued in favour of GOTO on the Internals list a few years ago. GOTO has a use, and a very good one at that. It is by far the most efficient construct when creating parsers or other similar types of logic flow. The demonized GOTO of the 80s was primarily due to jumping to arbitrary points in the code, or in the case of basic to arbitrary line numbers in the code which had little meaning for future readers. Not to mention failure to properly break, as in the OP's code example. -- /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] Problems w/ goto
On 12/17/10 11:57 AM, Steve Staples wrote: I had to show the people in my office, and we all got a chuckle from teh XKCD comic in the PHP documentation for GOTO http://ca2.php.net/goto Steve I was one of the people that argued in favour of GOTO on the Internals list a few years ago. GOTO has a use, and a very good one at that. It is by far the most efficient construct when creating parsers or other similar types of logic flow. The demonized GOTO of the 80s was primarily due to jumping to arbitrary points in the code, or in the case of basic to arbitrary line numbers in the code which had little meaning for future readers. When used properly within a well defined scope and with well named labels, GOTO can be a superior choice. If you think GOTO doesn't exist in many types of software, you need only grep for it in the C source code for PHP, MySQL, and Apache. Cheers, Rob. Oh, i can see where it would be useful, i just hadn't realized it was still in existence... and the cartoon, was blown up, and put in my cubical :) RAWR!! It's really a labeling problem. Goto usually refers to jump to arbitrary line, at least when used in the vernacular. That's horribly bad and evil. What PHP has implemented is named break statements, as I understand it. Those are not inherently evil. It doesn't break program flow any more than an exception does, but it's useful for non-error-handling cases. However, it reuses the keyword goto which is easy to confuse with the abomination above. It was a rather poor choice of name, frankly. --Larry Garfield -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems converting strings with 0 to integer
On 3 November 2010 21:42, Alexander Holodny alexander.holo...@gmail.com wrote: To exclude unexcepted behavior in case of wrongly formated input data, it would be much better to use such type-casting method: intval(ltrim(trim($inStr), '0')) 2010/11/3, Nicholas Kell n...@monkeyknight.com: On Nov 3, 2010, at 4:22 PM, robert mena wrote: Hi, I have a text file (utf-8 encoded) which contains lines with numbers and text separated by \t. I need to convert the numbers that contains 0 (at left) to integers. For some reason one line that contains 0002 is casted to 0 instead of 2. Bellow the output of the cast (int) $field[0] where I get this from explode each line. 0 0002 4 0004 My first guess is wondering how you are grabbing the strings from the file. Seems to me like it would just drop the zeros on the left by default. Are you including the \t in the string by accident? If so, that may be hosing it. Otherwise, have you tried ltrim on it? Ex: $_castableString = ltrim($_yourString, '0'); // Now cast ?php // Create test file. $s_TabbedFilename = './test.tab'; file_put_contents($s_TabbedFilename, 0\t0002 . PHP_EOL . 4\t0004 . PHP_EOL); // Open test file. $fp_TabbedFile = fopen($s_TabbedFilename, 'rt') or die(Could not open {$s_TabbedFilename}\n); // Iterate file. while(True) { if (False !== ($a_Line = fgetcsv($fp_TabbedFile, 0, \t))) { var_dump($a_Line); foreach($a_Line as $i_Index = $m_Value) { $a_Line[$i_Index] = intval($m_Value); } var_dump($a_Line); } else { break; } } // Close the file. fclose($fp_TabbedFile); // Delete the file. unlink($s_TabbedFilename); outputs ... array(2) { [0]= string(1) 0 [1]= string(8) 0002 } array(2) { [0]= int(0) [1]= int(2) } array(2) { [0]= string(1) 4 [1]= string(8) 0004 } array(2) { [0]= int(4) [1]= int(4) } intval() operates as standard on base 10, so no need to worry about leading zeros' being thought of as base8/octal. What is your code? Can you reduce it to something as small like the above to see if you can repeat the issue? -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems converting strings with 0 to integer
On 4 November 2010 10:33, Richard Quadling rquadl...@gmail.com wrote: ?php // Create test file. $s_TabbedFilename = './test.tab'; file_put_contents($s_TabbedFilename, 0\t0002 . PHP_EOL . 4\t0004 . PHP_EOL); // Open test file. $fp_TabbedFile = fopen($s_TabbedFilename, 'rt') or die(Could not open {$s_TabbedFilename}\n); // Iterate file. while(False !== ($a_Line = fgetcsv($fp_TabbedFile, 0, \t))) { var_dump($a_Line); foreach($a_Line as $i_Index = $m_Value) { $a_Line[$i_Index] = intval($m_Value); } var_dump($a_Line); } // Close the file. fclose($fp_TabbedFile); // Delete the file. unlink($s_TabbedFilename); -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems converting strings with 0 to integer
Hi, The core of the code is simply $fp = fopen('file.tab', 'rb'); while(!feof($fp)) { $line = fgets($fp); $data = explode(\t, $line); ... } So I try to manipulate the $data[X]. For example $data[0] is supposed to be numeric so I $n = (int) $data[0] One other thing if the second column should contain a string. If I check the string visually it is correct but a if( $data[1] == 'stringX') is false even if in the file I can see this (and print those two) I even did a md5 of both and they are different. I seems to be an encoding issue. Is it safe to use explode with utf8 strings? I even tried this code but no match found (jst to replace the explode) $str = abc 文字化けefg; $results = array(); preg_match_all(/\t/u, $str, $results); var_dump($results[0]); (I am sending this again without the reply because the first email was refused for some reason)
Re: [PHP] Problems converting strings with 0 to integer
On 4 November 2010 15:11, robert mena robert.m...@gmail.com wrote: Hi, The core of the code is simply $fp = fopen('file.tab', 'rb'); while(!feof($fp)) { $line = fgets($fp); $data = explode(\t, $line); ... } So I try to manipulate the $data[X]. For example $data[0] is supposed to be numeric so I $n = (int) $data[0] One other thing if the second column should contain a string. If I check the string visually it is correct but a if( $data[1] == 'stringX') is false even if in the file I can see this (and print those two) I even did a md5 of both and they are different. I seems to be an encoding issue. Is it safe to use explode with utf8 strings? I even tried this code but no match found (jst to replace the explode) $str = abc 文字化け efg; $results = array(); preg_match_all(/\t/u, $str, $results); var_dump($results[0]); On Thu, Nov 4, 2010 at 6:33 AM, Richard Quadling rquadl...@gmail.com wrote: On 3 November 2010 21:42, Alexander Holodny alexander.holo...@gmail.com wrote: To exclude unexcepted behavior in case of wrongly formated input data, it would be much better to use such type-casting method: intval(ltrim(trim($inStr), '0')) 2010/11/3, Nicholas Kell n...@monkeyknight.com: On Nov 3, 2010, at 4:22 PM, robert mena wrote: Hi, I have a text file (utf-8 encoded) which contains lines with numbers and text separated by \t. I need to convert the numbers that contains 0 (at left) to integers. For some reason one line that contains 0002 is casted to 0 instead of 2. Bellow the output of the cast (int) $field[0] where I get this from explode each line. 0 0002 4 0004 My first guess is wondering how you are grabbing the strings from the file. Seems to me like it would just drop the zeros on the left by default. Are you including the \t in the string by accident? If so, that may be hosing it. Otherwise, have you tried ltrim on it? Ex: $_castableString = ltrim($_yourString, '0'); // Now cast ?php // Create test file. $s_TabbedFilename = './test.tab'; file_put_contents($s_TabbedFilename, 0\t0002 . PHP_EOL . 4\t0004 . PHP_EOL); // Open test file. $fp_TabbedFile = fopen($s_TabbedFilename, 'rt') or die(Could not open {$s_TabbedFilename}\n); // Iterate file. while(True) { if (False !== ($a_Line = fgetcsv($fp_TabbedFile, 0, \t))) { var_dump($a_Line); foreach($a_Line as $i_Index = $m_Value) { $a_Line[$i_Index] = intval($m_Value); } var_dump($a_Line); } else { break; } } // Close the file. fclose($fp_TabbedFile); // Delete the file. unlink($s_TabbedFilename); outputs ... array(2) { [0]= string(1) 0 [1]= string(8) 0002 } array(2) { [0]= int(0) [1]= int(2) } array(2) { [0]= string(1) 4 [1]= string(8) 0004 } array(2) { [0]= int(4) [1]= int(4) } intval() operates as standard on base 10, so no need to worry about leading zeros' being thought of as base8/octal. What is your code? Can you reduce it to something as small like the above to see if you can repeat the issue? Please don't top post. With regards to utf-8 data, no, PHP is not unicode aware. If a multi-byte character is comprised of a 0x09 byte, then it will be broken. Can you supply the file you are working on? b64encode it and drop it into a pastebin. -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems converting strings with 0 to integer
On 4 November 2010 15:31, robert mena robert.m...@gmail.com wrote: Hi Richard, I am not top posting. I am just explaining other symptoms that may point to the cause since they may be the same and this is happening with the same file. I'll try to get approval to release the file. Meanwhile, In your opinion what would be the safest way to read and explode (using \t) a text file encoded in UTF-8? On Thu, Nov 4, 2010 at 11:22 AM, Richard Quadling rquadl...@gmail.com wrote: On 4 November 2010 15:11, robert mena robert.m...@gmail.com wrote: Hi, The core of the code is simply $fp = fopen('file.tab', 'rb'); while(!feof($fp)) { $line = fgets($fp); $data = explode(\t, $line); ... } So I try to manipulate the $data[X]. For example $data[0] is supposed to be numeric so I $n = (int) $data[0] One other thing if the second column should contain a string. If I check the string visually it is correct but a if( $data[1] == 'stringX') is false even if in the file I can see this (and print those two) I even did a md5 of both and they are different. I seems to be an encoding issue. Is it safe to use explode with utf8 strings? I even tried this code but no match found (jst to replace the explode) $str = abc 文字化け efg; $results = array(); preg_match_all(/\t/u, $str, $results); var_dump($results[0]); On Thu, Nov 4, 2010 at 6:33 AM, Richard Quadling rquadl...@gmail.com wrote: On 3 November 2010 21:42, Alexander Holodny alexander.holo...@gmail.com wrote: To exclude unexcepted behavior in case of wrongly formated input data, it would be much better to use such type-casting method: intval(ltrim(trim($inStr), '0')) 2010/11/3, Nicholas Kell n...@monkeyknight.com: On Nov 3, 2010, at 4:22 PM, robert mena wrote: Hi, I have a text file (utf-8 encoded) which contains lines with numbers and text separated by \t. I need to convert the numbers that contains 0 (at left) to integers. For some reason one line that contains 0002 is casted to 0 instead of 2. Bellow the output of the cast (int) $field[0] where I get this from explode each line. 0 0002 4 0004 My first guess is wondering how you are grabbing the strings from the file. Seems to me like it would just drop the zeros on the left by default. Are you including the \t in the string by accident? If so, that may be hosing it. Otherwise, have you tried ltrim on it? Ex: $_castableString = ltrim($_yourString, '0'); // Now cast ?php // Create test file. $s_TabbedFilename = './test.tab'; file_put_contents($s_TabbedFilename, 0\t0002 . PHP_EOL . 4\t0004 . PHP_EOL); // Open test file. $fp_TabbedFile = fopen($s_TabbedFilename, 'rt') or die(Could not open {$s_TabbedFilename}\n); // Iterate file. while(True) { if (False !== ($a_Line = fgetcsv($fp_TabbedFile, 0, \t))) { var_dump($a_Line); foreach($a_Line as $i_Index = $m_Value) { $a_Line[$i_Index] = intval($m_Value); } var_dump($a_Line); } else { break; } } // Close the file. fclose($fp_TabbedFile); // Delete the file. unlink($s_TabbedFilename); outputs ... array(2) { [0]= string(1) 0 [1]= string(8) 0002 } array(2) { [0]= int(0) [1]= int(2) } array(2) { [0]= string(1) 4 [1]= string(8) 0004 } array(2) { [0]= int(4) [1]= int(4) } intval() operates as standard on base 10, so no need to worry about leading zeros' being thought of as base8/octal. What is your code? Can you reduce it to something as small like the above to see if you can repeat the issue? Please don't top post. With regards to utf-8 data, no, PHP is not unicode aware. If a multi-byte character is comprised of a 0x09 byte, then it will be broken. Can you supply the file you are working on? b64encode it and drop it into a pastebin. -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY I've not used it, but the mbstring extension has mb_split() - Split multibyte string using regular expression Whilst it probably isn't as performant as explode() or fgetcsv(), it should work. But I'm not an unicode expert and having a file I can test this mechanism easily enough. I'd be interested in knowing what output the code I produced outputs when used in conjunction with your data. -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problems converting strings with 0 to integer
Hi, I have a text file (utf-8 encoded) which contains lines with numbers and text separated by \t. I need to convert the numbers that contains 0 (at left) to integers. For some reason one line that contains 0002 is casted to 0 instead of 2. Bellow the output of the cast (int) $field[0] where I get this from explode each line. 0 0002 4 0004
Re: [PHP] Problems converting strings with 0 to integer
To exclude unexcepted behavior in case of wrongly formated input data, it would be much better to use such type-casting method: intval(ltrim(trim($inStr), '0')) 2010/11/3, Nicholas Kell n...@monkeyknight.com: On Nov 3, 2010, at 4:22 PM, robert mena wrote: Hi, I have a text file (utf-8 encoded) which contains lines with numbers and text separated by \t. I need to convert the numbers that contains 0 (at left) to integers. For some reason one line that contains 0002 is casted to 0 instead of 2. Bellow the output of the cast (int) $field[0] where I get this from explode each line. 0 0002 4 0004 My first guess is wondering how you are grabbing the strings from the file. Seems to me like it would just drop the zeros on the left by default. Are you including the \t in the string by accident? If so, that may be hosing it. Otherwise, have you tried ltrim on it? Ex: $_castableString = ltrim($_yourString, '0'); // Now cast -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems converting strings with 0 to integer
On Nov 3, 2010, at 4:22 PM, robert mena wrote: Hi, I have a text file (utf-8 encoded) which contains lines with numbers and text separated by \t. I need to convert the numbers that contains 0 (at left) to integers. For some reason one line that contains 0002 is casted to 0 instead of 2. Bellow the output of the cast (int) $field[0] where I get this from explode each line. 0 0002 4 0004 My first guess is wondering how you are grabbing the strings from the file. Seems to me like it would just drop the zeros on the left by default. Are you including the \t in the string by accident? If so, that may be hosing it. Otherwise, have you tried ltrim on it? Ex: $_castableString = ltrim($_yourString, '0'); // Now cast -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] problems with feature '--with-pdo-oci' RPM (spec)
Hi, Good morning for all, I'd like to understand why when i try to install the package 'php52-pdo-oci' generated by 'rpmbuild -ba php52.spec' with feature inside of file , doesn't work and returns the follow error : # rpm -qpl /usr/src/linux/RPMS/x86_64/php52-pdo-oci-5.2.12-2.fc11.x86_64.rpm /etc/php.d/pdo_oci.ini /usr/lib64/php/modules/pdo_oci.so # rpm --test -ivh /usr/src/redhat/RPMS/x86_64/php52-pdo-oci-5.2.12-2.fc11.x86_64.rpm error: Failed dependencies: libclntsh.so.10.1()(64bit) is needed by php52-pdo-oci-5.2.12-2.fc11.x86_64 I checked this steps, its ok : 1) # ls -l /usr/lib/oracle/10.2.0.4/client64/lib/libclntsh.so lrwxrwxrwx 1 root root 17 2010-04-12 19:38 /usr/lib/oracle/ 10.2.0.4/client64/lib/libclntsh.so - libclntsh.so.10.1 2) # ldconfig -p | grep libclntsh.so libclntsh.so.10.1 (libc6,x86-64) = /usr/lib/oracle/ 10.2.0.4/client64/lib/libclntsh.so.10.1 libclntsh.so (libc6,x86-64) = /usr/lib/oracle/ 10.2.0.4/client64/lib/libclntsh.so What is wrong ? , thanks for help Att, Raul
[PHP] problems with utf-8 conversion
I have csv file with special characters, stored in default encoding(ISO-8859-1). I am convert file contents(string) to UTF-8using iconv. This doesn't convert special characters properly, shows broken on fronted. Page encoding meta tag are properly set to utf-8. Characters are shown properly on frontend if i save file encoding as utf-8(Using notepad). But iconv doesn't convert characters properly to UTF-8. $value = iconv(Latin1,utf-8, $value); having problem with below mentioned character ’ #8217; rsquo; right single quotation mark Any idea or suggestions to fix this would be helpful. Thanks in advance, Sudhir Your Mail works best with the New Yahoo Optimized IE8. Get it NOW! http://downloads.yahoo.com/in/internetexplorer/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problems with permissions or getting access to a file
On 11 February 2010 09:31, Pat patrick.j.r...@gmail.com wrote: Richard Quadling wrote: On 10 February 2010 16:31, Pat patrick.j.r...@gmail.com wrote: hi all having trouble here with a site that I am hosting on go-daddy I want to keep my php and my images apart so to do this I have the base directory which contains the php scripts. On the directory above that I have my photos stored in /photos when I run my scripts I get the following: time -4 hours1265815323 *Warning*: filemtime() [function.filemtime http://www.patrickrice.net/tomdcam/function.filemtime]: stat failed for testPanasonicCamMotion20100201022429140.jpg in */home/content/j/a/c/jackcards/html/tomdcam/MotionCamLast1Hours.php* on line *16* 1265815323 *Warning*: filemtime() [function.filemtime http://www.patrickrice.net/tomdcam/function.filemtime]: stat failed for testPanasonicCamMotion20100201022429140.jpg in */home/content/j/a/c/jackcards/html/tomdcam/MotionCamLast1Hours.php* on line *28* 0 time -4 hours1265815323 *Warning*: filemtime() [function.filemtime http://www.patrickrice.net/tomdcam/function.filemtime]: stat failed for testPanasonicCamMotion20100201022619570.jpg in */home/content/j/a/c/jackcards/html/tomdcam/MotionCamLast1Hours.php* on line *16 *_The script is the following below _from running this script, I keep getting this error, now when I copy this script in to the directory photo where the photos are stored, the script displays the images with no problems leaving me think that the issue is with the permissions, I have modified the pre-emptions to give all access as a test and still problems. Anyone got any Ideas?? Thanks in advance. Pat read() only returns the filename, not the full path. So, when the script is in the same directory, the current directory contains the required file. Try using ... filemtime(realpath($f)) instead. Thanks Richard, It was really wrecking my head. Pat No problem. -- - Richard Quadling Standing on the shoulders of some very clever giants! EE : http://www.experts-exchange.com/M_248814.html EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] problems with permissions or getting access to a file
hi all having trouble here with a site that I am hosting on go-daddy I want to keep my php and my images apart so to do this I have the base directory which contains the php scripts. On the directory above that I have my photos stored in /photos when I run my scripts I get the following: time -4 hours1265815323 *Warning*: filemtime() [function.filemtime http://www.patrickrice.net/tomdcam/function.filemtime]: stat failed for testPanasonicCamMotion20100201022429140.jpg in */home/content/j/a/c/jackcards/html/tomdcam/MotionCamLast1Hours.php* on line *16* 1265815323 *Warning*: filemtime() [function.filemtime http://www.patrickrice.net/tomdcam/function.filemtime]: stat failed for testPanasonicCamMotion20100201022429140.jpg in */home/content/j/a/c/jackcards/html/tomdcam/MotionCamLast1Hours.php* on line *28* 0 time -4 hours1265815323 *Warning*: filemtime() [function.filemtime http://www.patrickrice.net/tomdcam/function.filemtime]: stat failed for testPanasonicCamMotion20100201022619570.jpg in */home/content/j/a/c/jackcards/html/tomdcam/MotionCamLast1Hours.php* on line *16 *_The script is the following below _from running this script, I keep getting this error, now when I copy this script in to the directory photo where the photos are stored, the script displays the images with no problems leaving me think that the issue is with the permissions, I have modified the pre-emptions to give all access as a test and still problems. Anyone got any Ideas?? Thanks in advance. Pat 6 ?php 7 $debug =1; 8 $d = dir('/home/content/j/a/c/jackcards/html/tomdcam/photo/') or die($php_errormsg); 9 while (false !== ($f = $d-read())) { 10 // only match alphabetic names 11 if (preg_match('/testPanasonicCamMotion/',$f)) { 12 13 if ($debug == 1) { 14 echo time -4 hours . strtotime(- 1 hours ). ; 15 16 echo filemtime($f); 17 echo br; 18 }//end debug 19 20 $FourHoursAgo = intval(strtotime(- 1 hours )); 21 22 if ($debug == 1) { 23 echo $FourHoursAgo; 24 # 25 echo br; 26 } 27 28 $dateOfFileModify = intval(date((filemtime($f)) )); 29 30 if ($debug == 1) { 31 echo $dateOfFileModify; 32 echo br; 33 } 34 35 36 if ($FourHoursAgo $dateOfFileModify) 37 # if(intval(strtotime(- 4 hours )) intval(strtotime(filemtime($f))) ) 38 39 # if (strcmp(strtotime(- 4 hours ),strtotime(filemtime($f)) ) 0) 40 41 { 42 #echo 'br Images less than 4 hours br'; 43 44 45 46 47 print filename: $f br; 48 print IMG SRC=\$f \ br\n; 49 50 # echo Last accessed on: . date(d-m-y H:i:s, strtotime(+ 8 hours, fileatime($f)) ); 51 # echo br; 52 echo Last modified on: . date(d-m-y H:i:s, strtotime(+ 8 hours, filemtime($f)) ); 53 echo br hr; 54 }//end of if statment 55 56 57 # else { 58 # print br None Found br; 59 # } 60 } 61 } 62 $d-close(); 63 64 65 ? * * -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problems with permissions or getting access to a file
On 10 February 2010 16:31, Pat patrick.j.r...@gmail.com wrote: hi all having trouble here with a site that I am hosting on go-daddy I want to keep my php and my images apart so to do this I have the base directory which contains the php scripts. On the directory above that I have my photos stored in /photos when I run my scripts I get the following: time -4 hours1265815323 *Warning*: filemtime() [function.filemtime http://www.patrickrice.net/tomdcam/function.filemtime]: stat failed for testPanasonicCamMotion20100201022429140.jpg in */home/content/j/a/c/jackcards/html/tomdcam/MotionCamLast1Hours.php* on line *16* 1265815323 *Warning*: filemtime() [function.filemtime http://www.patrickrice.net/tomdcam/function.filemtime]: stat failed for testPanasonicCamMotion20100201022429140.jpg in */home/content/j/a/c/jackcards/html/tomdcam/MotionCamLast1Hours.php* on line *28* 0 time -4 hours1265815323 *Warning*: filemtime() [function.filemtime http://www.patrickrice.net/tomdcam/function.filemtime]: stat failed for testPanasonicCamMotion20100201022619570.jpg in */home/content/j/a/c/jackcards/html/tomdcam/MotionCamLast1Hours.php* on line *16 *_The script is the following below _from running this script, I keep getting this error, now when I copy this script in to the directory photo where the photos are stored, the script displays the images with no problems leaving me think that the issue is with the permissions, I have modified the pre-emptions to give all access as a test and still problems. Anyone got any Ideas?? Thanks in advance. Pat 6 ?php 7 $debug =1; 8 $d = dir('/home/content/j/a/c/jackcards/html/tomdcam/photo/') or die($php_errormsg); 9 while (false !== ($f = $d-read())) { 10 // only match alphabetic names 11 if (preg_match('/testPanasonicCamMotion/',$f)) { 12 13 if ($debug == 1) { 14 echo time -4 hours . strtotime(- 1 hours ). ; 15 16 echo filemtime($f); 17 echo br; 18 }//end debug 19 20 $FourHoursAgo = intval(strtotime(- 1 hours )); 21 22 if ($debug == 1) { 23 echo $FourHoursAgo; 24 # 25 echo br; 26 } 27 28 $dateOfFileModify = intval(date((filemtime($f)) )); 29 30 if ($debug == 1) { 31 echo $dateOfFileModify; 32 echo br; 33 } 34 35 36 if ($FourHoursAgo $dateOfFileModify) 37 # if(intval(strtotime(- 4 hours )) intval(strtotime(filemtime($f))) ) 38 39 # if (strcmp(strtotime(- 4 hours ),strtotime(filemtime($f)) ) 0) 40 41 { 42 #echo 'br Images less than 4 hours br'; 43 44 45 46 47 print filename: $f br; 48 print IMG SRC=\$f \ br\n; 49 50 # echo Last accessed on: . date(d-m-y H:i:s, strtotime(+ 8 hours, fileatime($f)) ); 51 # echo br; 52 echo Last modified on: . date(d-m-y H:i:s, strtotime(+ 8 hours, filemtime($f)) ); 53 echo br hr; 54 }//end of if statment 55 56 57 # else { 58 # print br None Found br; 59 # } 60 } 61 } 62 $d-close(); 63 64 65 ? * * -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php read() only returns the filename, not the full path. So, when the script is in the same directory, the current directory contains the required file. Try using ... filemtime(realpath($f)) instead. -- - Richard Quadling Standing on the shoulders of some very clever giants! EE : http://www.experts-exchange.com/M_248814.html EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problems with unit tests
I am using test-harness.php (PHP TAP Test Harness 1_0_0_BETA) and test-more.php to write some unit tests for several libraries of functions. These tests need to run from a MS-Windows CLI so they can be run on our desktops for now and can be added to the automated build process later. I have written my first tests using test-more.php to generate TAP compliant results, and they work as expected (see below - yes, both tests should fail). But when I run them with test-harness.php, the reported results are wrong (also below). The harness reports all tests passed, even if they didn't. After doing some digging, I found Bug #44908, which seems to be related. It appears the interpreter on MS-Windows is not creating the pipe file for STDOUT, so the harness never sees the results from the actual tests. I also tried using the Perl Test::Harness to run the scripts and get the same error message there. Both harnesses appear to ignore the error count returned as the process exit value as well. But I am not sure if that is true or they just never saw it. Has any workaround been identified for this problem? Is there another mailing list that might be a more appropriate forum for this issue? Thank you, Bob McConnell --9- D:\project\workspace\tver Microsoft Windows XP [Version 5.1.2600] - XP Pro 2002 w/SP2 D:\project\workspace\tphp -v PHP 5.2.10 (cli) (built: Jun 17 2009 16:16:57) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies D:\project\workspace\tphp testSessionKV.php 1..2 not ok 1 - Should fail # Failed test (D:\project\workspace\t\testSessionKV.php at line 13) not ok 2 - Old KV pair # Failed test (D:\project\workspace\t\testSessionKV.php at line 24) # Looks like you failed 2 tests of 2. D:\project\workspace\tphp test-harness.php -v testSessionKV.php.ok Could not open input file: D: All test scripts passed! All subtests passed! D:\project\workspaceren testSessionKV.php testSessionKV.t D:\project\workspacecd .. D:\MMID\workspace\tperl -v This is perl, v5.10.0 built for MSWin32-x86-multi-thread - Camelbox Copyright 1987-2007, Larry Wall D:\project\workspaceset HARNESS_PERL=php D:\project\workspaceperl -MTest::Harness -e @ARGV= map glob, @ARGV if $^O =~ /^MSWin/; runtests @ARGV; t/*.t t/testSessionKVCould not open input file: print join qq[\n], @INC FAILED before any test output arrived FAILED--1 test script could be run, alas--no output ever seen --9- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problems with an extension
So I am developing a custom extension and I am having a issue. I have a header file that I need included in the project. If I #include the header file everything compiles and makes just fine, but after restarting the web server the extension won't load. If I remove or comment out the #include of the header file everything still compiles and makes just fine, and after restarting the web server the extension is loaded just fine. Does anyone have any idea what would cause the extension to refuse to load with the header file included? -Eric -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems with an extension
On Sun, Jun 28, 2009 at 10:56, Eric A. Boneymailingli...@vanhlebarsoftware.com wrote: So I am developing a custom extension and I am having a issue. I have a header file that I need included in the project. If I #include the header file everything compiles and makes just fine, but after restarting the web server the extension won't load. Eric, Custom extensions programming is in C/C++ (as also indicated by your #include reference), which is beyond the scope of this list. Unfortunately, there is not an official dedicated list for extensions developers, but if it's not urgent, you can email me privately at danbr...@php.net and I'll see if I can help you out. -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ Ask me about our fully-managed servers and proactive management clusters starting at just $200/mo.! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems with an extension
On Sunday 28 June 2009 11:00:48 you wrote: On Sun, Jun 28, 2009 at 10:56, Eric A. Boneymailingli...@vanhlebarsoftware.com wrote: So I am developing a custom extension and I am having a issue. I have a header file that I need included in the project. If I #include the header file everything compiles and makes just fine, but after restarting the web server the extension won't load. Eric, Custom extensions programming is in C/C++ (as also indicated by your #include reference), which is beyond the scope of this list. Unfortunately, there is not an official dedicated list for extensions developers, but if it's not urgent, you can email me privately at danbr...@php.net and I'll see if I can help you out. Thanks Dan: I thought it might be beyond this list, but I figured it might be worth the shot. It is not urgent at all, so I will drop you a private message with a more detailed explanation and if you can help great, if not, I'll keep poking around at it. -Eric -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems with APC, possible cache-corruption?
On Sun, Jun 21, 2009 at 6:17 PM, James McLean james.mcl...@gmail.comwrote: On Mon, Jun 22, 2009 at 9:40 AM, Nathan Nobbequickshif...@gmail.com wrote: On Sun, Jun 21, 2009 at 5:56 PM, James McLean james.mcl...@gmail.com wrote: did you take a look at the size of the cache you created ? Yes. Tried multiple segments and single, with cache size values between 128mb and 256mb. Also tried with stat on and off. also, arent you planning to cache php opcodes, so if you load up the page, index.html, i would expect to see a bunch of php files mentioned in the apc cache.. Well, index.html wouldn't be cached because it's not parsed by the PHP engine. But yes, if it were index.php for example each compiled PHP file is then cached in the opcode cache - include files and everything. This is how it works on every other APC installation i've tried :) This installation is not doing that, even though this is the default behaviour. if apc has support for output caching, ive not yet used it so im not sure how much i could help there (sort of sounds like youre shooting for output caching the way you describe things above). No, i'm not looking for output caching. Apologies if my original email was poorly worded. maybe you could dump out your ini settings for apc and share them here? No need. they're all default as reccomended by PHP and APC. hmm, 2 other thoughts i have.. . long shot, but do you have apc.php installed on a diff domain than the moodle app (not sure but i suspect apc.php only shows cached values for the domain in which its currently running (i know this is something eaccelerator does). . as a test, perhaps setup a simple test site, w/ 2 files, apc.php and one index.php file on this rhel box. if things are working (index.php cached w/ apc.php), it would seem something goofy is going on indside the moodle app. -nathan
Re: [PHP] Problems with APC, possible cache-corruption?
On Tue, Jun 23, 2009 at 6:17 AM, Nathan Nobbequickshif...@gmail.com wrote: hmm, 2 other thoughts i have.. . long shot, but do you have apc.php installed on a diff domain than the moodle app (not sure but i suspect apc.php only shows cached values for the domain in which its currently running (i know this is something eaccelerator does). No. Same domain. . as a test, perhaps setup a simple test site, w/ 2 files, apc.php and one index.php file on this rhel box. if things are working (index.php cached w/ apc.php), it would seem something goofy is going on indside the moodle app. The RHEL box works flawlessly, as has almost every other APC install i've ever done. I simply used it as an example that Moodle likely wasn't at fault, and I have since further proved this by grepping the source - it isn't setting any of it's own apc filters as suggested before. On the APC install that is not working correctly, when I switch between my info.php and apc.php files - the counter on the cached file (apc.php) resets, and info.php is not cached. That was all outlined in the original email. I guess this is not a common issue, no one seems to have experienced it before.. Cheers -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problems with APC, possible cache-corruption?
(Resend from around 1 week ago, because of no responses) Hi All, Over the weekend I setup a test of APC intending to benchmark a Moodle installation with various APC settings to see how well I could get it to perform. I successfully installed Moodle 1.9 and 2.0 under Apache 2.2.3 (installed via apt on Ubuntu 9.04), and with PHP 5.2.9 compiled from source. I should note, that Ubuntu had an older version of PHP installed from apt with Suhosin hardened PHP built in. Moodle 2.0 required at least PHP 5.2.8, so I uninstalled the original PHP module before compiling and installing the 5.2.9. No issues there; PHP worked well and performance was (mostly) acceptable. Progressed onto installing APC, firstly by downloading the APC 3.1.2 source from PECL and following the usual 'phpize, configure, make, make install' process which worked as expected, stop and start Apache and APC was present in my phpinfo();. I started with the reccomended PHP config exept with error_display turned on and E_ALL | E_STRICT enabled, and also the reccomended APC config also. I copied the 'apc.php' from the source tree to my webroot and changed the password as suggested. The issue arose when I attempted to benchmark my Moodle install with 'ab' (I realise it only downloads the single page, but it's good enough for what I need for now though) and the result was no different to before I had installed APC. View the apc.php page, and the only page cached is apc.php itself.. Certainly not what I've witnessed in the past. Then what would happen was if I viewed my seperate info.php page containing simply the opening PHP tag and a single line with phpinfo(); in the file - the cache would appear to reset, and it would firstly not load the info.php into the cache, it would reset the counter on the apc.php file back to 0. Through all of this, there was no errors displayed on the screen and no errors listed in the Apache error log either. Increased the Apache log level up to Debug, and no related information was displayed. Moodle itself worked as expected with no errors, and on a seperate RHEL installation I have Moodle working with APC and it is caching all it's files as expected. At this point, I thought it may be an issue with the module I compiled myself. I backed up the module, and allowed PECL to install the module, it installed 3.0.19. Restarted Apache and verified the version was as PECL had built and installed. This had no effect, and yeilded the same behaviour. I'm stumped as to what the issue could be, however I did see this issue of APC not caching files on an installation of Red Hat Enterprise Linux in the past - however at the time we assumed it was an issue with the framework we were using and due to time constraints simply ran without APC and didn't investigate further. Has anyone seen this issue in the past and perhaps even rectified it? Any information would be appreciated. Cheers, James -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems with APC, possible cache-corruption?
On Sun, Jun 21, 2009 at 5:56 PM, James McLean james.mcl...@gmail.comwrote: (Resend from around 1 week ago, because of no responses) Hi All, Over the weekend I setup a test of APC intending to benchmark a Moodle installation with various APC settings to see how well I could get it to perform. I successfully installed Moodle 1.9 and 2.0 under Apache 2.2.3 (installed via apt on Ubuntu 9.04), and with PHP 5.2.9 compiled from source. I should note, that Ubuntu had an older version of PHP installed from apt with Suhosin hardened PHP built in. Moodle 2.0 required at least PHP 5.2.8, so I uninstalled the original PHP module before compiling and installing the 5.2.9. No issues there; PHP worked well and performance was (mostly) acceptable. Progressed onto installing APC, firstly by downloading the APC 3.1.2 source from PECL and following the usual 'phpize, configure, make, make install' process which worked as expected, stop and start Apache and APC was present in my phpinfo();. I started with the reccomended PHP config exept with error_display turned on and E_ALL | E_STRICT enabled, and also the reccomended APC config also. I copied the 'apc.php' from the source tree to my webroot and changed the password as suggested. The issue arose when I attempted to benchmark my Moodle install with 'ab' (I realise it only downloads the single page, but it's good enough for what I need for now though) and the result was no different to before I had installed APC. View the apc.php page, and the only page cached is apc.php itself.. Certainly not what I've witnessed in the past. Then what would happen was if I viewed my seperate info.php page containing simply the opening PHP tag and a single line with phpinfo(); in the file - the cache would appear to reset, and it would firstly not load the info.php into the cache, it would reset the counter on the apc.php file back to 0. Through all of this, there was no errors displayed on the screen and no errors listed in the Apache error log either. Increased the Apache log level up to Debug, and no related information was displayed. Moodle itself worked as expected with no errors, and on a seperate RHEL installation I have Moodle working with APC and it is caching all it's files as expected. At this point, I thought it may be an issue with the module I compiled myself. I backed up the module, and allowed PECL to install the module, it installed 3.0.19. Restarted Apache and verified the version was as PECL had built and installed. This had no effect, and yeilded the same behaviour. I'm stumped as to what the issue could be, however I did see this issue of APC not caching files on an installation of Red Hat Enterprise Linux in the past - however at the time we assumed it was an issue with the framework we were using and due to time constraints simply ran without APC and didn't investigate further. Has anyone seen this issue in the past and perhaps even rectified it? Any information would be appreciated. did you take a look at the size of the cache you created ? also, arent you planning to cache php opcodes, so if you load up the page, index.html, i would expect to see a bunch of php files mentioned in the apc cache.. if apc has support for output caching, ive not yet used it so im not sure how much i could help there (sort of sounds like youre shooting for output caching the way you describe things above). maybe you could dump out your ini settings for apc and share them here? -nathan
Re: [PHP] Problems with APC, possible cache-corruption?
On Mon, Jun 22, 2009 at 9:40 AM, Nathan Nobbequickshif...@gmail.com wrote: On Sun, Jun 21, 2009 at 5:56 PM, James McLean james.mcl...@gmail.com wrote: did you take a look at the size of the cache you created ? Yes. Tried multiple segments and single, with cache size values between 128mb and 256mb. Also tried with stat on and off. also, arent you planning to cache php opcodes, so if you load up the page, index.html, i would expect to see a bunch of php files mentioned in the apc cache.. Well, index.html wouldn't be cached because it's not parsed by the PHP engine. But yes, if it were index.php for example each compiled PHP file is then cached in the opcode cache - include files and everything. This is how it works on every other APC installation i've tried :) This installation is not doing that, even though this is the default behaviour. if apc has support for output caching, ive not yet used it so im not sure how much i could help there (sort of sounds like youre shooting for output caching the way you describe things above). No, i'm not looking for output caching. Apologies if my original email was poorly worded. maybe you could dump out your ini settings for apc and share them here? No need. they're all default as reccomended by PHP and APC. Thanks, James -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems with APC, possible cache-corruption?
Can you do a phpinfo(); and tell us the value of the setting apc.filters (or every apc.* if you can)? Just curious, but I've seen apps set that setting to avoid APC opcode caching. Jonathan On Sun, Jun 21, 2009 at 8:56 PM, James McLeanjames.mcl...@gmail.com wrote: (Resend from around 1 week ago, because of no responses) Hi All, Over the weekend I setup a test of APC intending to benchmark a Moodle installation with various APC settings to see how well I could get it to perform. I successfully installed Moodle 1.9 and 2.0 under Apache 2.2.3 (installed via apt on Ubuntu 9.04), and with PHP 5.2.9 compiled from source. I should note, that Ubuntu had an older version of PHP installed from apt with Suhosin hardened PHP built in. Moodle 2.0 required at least PHP 5.2.8, so I uninstalled the original PHP module before compiling and installing the 5.2.9. No issues there; PHP worked well and performance was (mostly) acceptable. Progressed onto installing APC, firstly by downloading the APC 3.1.2 source from PECL and following the usual 'phpize, configure, make, make install' process which worked as expected, stop and start Apache and APC was present in my phpinfo();. I started with the reccomended PHP config exept with error_display turned on and E_ALL | E_STRICT enabled, and also the reccomended APC config also. I copied the 'apc.php' from the source tree to my webroot and changed the password as suggested. The issue arose when I attempted to benchmark my Moodle install with 'ab' (I realise it only downloads the single page, but it's good enough for what I need for now though) and the result was no different to before I had installed APC. View the apc.php page, and the only page cached is apc.php itself.. Certainly not what I've witnessed in the past. Then what would happen was if I viewed my seperate info.php page containing simply the opening PHP tag and a single line with phpinfo(); in the file - the cache would appear to reset, and it would firstly not load the info.php into the cache, it would reset the counter on the apc.php file back to 0. Through all of this, there was no errors displayed on the screen and no errors listed in the Apache error log either. Increased the Apache log level up to Debug, and no related information was displayed. Moodle itself worked as expected with no errors, and on a seperate RHEL installation I have Moodle working with APC and it is caching all it's files as expected. At this point, I thought it may be an issue with the module I compiled myself. I backed up the module, and allowed PECL to install the module, it installed 3.0.19. Restarted Apache and verified the version was as PECL had built and installed. This had no effect, and yeilded the same behaviour. I'm stumped as to what the issue could be, however I did see this issue of APC not caching files on an installation of Red Hat Enterprise Linux in the past - however at the time we assumed it was an issue with the framework we were using and due to time constraints simply ran without APC and didn't investigate further. Has anyone seen this issue in the past and perhaps even rectified it? Any information would be appreciated. Cheers, James -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems with APC, possible cache-corruption?
On Mon, Jun 22, 2009 at 10:02 AM, Jonathan Tapicertapi...@gmail.com wrote: Can you do a phpinfo(); and tell us the value of the setting apc.filters (or every apc.* if you can)? Just curious, but I've seen apps set that setting to avoid APC opcode caching. Certainly, however it will have to wait until I am home and have access to that machine again. Though I'm not sure that would be the case as APC is caching all Moodle files on my development server here. That being said I'll grep the codebase anyway to see if it's setting any filters. Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems with apc extension on wamp server.
Hi. Yes, as it turned out, the extension was not loaded. While following some tutorial i added only apc.rfc1867 = 1 to php.ini. Turns out that this particular line turns on one of apc functions (file tracking), but not the apc itself. However, now when i have apc turned on i still have a problem with file upload tracking: the apc_fetch(upload_xxx) returns information only when the file download is finished. while it is in progress, the result is false(0). Any ideas? 2009/6/17 Jonathan Tapicer tapi...@gmail.com: Hi, Does the extension appear on a phpinfo()? Seems like the extension isn't loaded. Jonathan On Tue, Jun 16, 2009 at 5:20 PM, Valentinas Bakaitisv.bakai...@gmail.com wrote: Hello! I am trying to track file upload progress using APC extension. However, when trying to use, it gives Fatal error: Call to undefined function apc_fetch() in C:\wamp\www\old\getprogress.php on line 3 I am using WAMP 2.0, with php 5.2.8 APC extension appear on extensions list and is enabled. Any ideas what i am doing wrong? here is the code of getprogress.php: * * $upload = apc_fetch('upload_1'); if ($upload) { if ($upload['done']) $percent = 100; else if ($upload['total'] == 0) $percent = 0; else $percent = $upload['current'] / $upload['total'] * 100; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems with apc extension on wamp server.
Found the problem: input type=hidden name=APC_UPLOAD_PROGRESS id=progress_key value=1 / must always be before file input in the form. 2009/6/17 Valentinas Bakaitis v.bakai...@gmail.com: Hi. Yes, as it turned out, the extension was not loaded. While following some tutorial i added only apc.rfc1867 = 1 to php.ini. Turns out that this particular line turns on one of apc functions (file tracking), but not the apc itself. However, now when i have apc turned on i still have a problem with file upload tracking: the apc_fetch(upload_xxx) returns information only when the file download is finished. while it is in progress, the result is false(0). Any ideas? 2009/6/17 Jonathan Tapicer tapi...@gmail.com: Hi, Does the extension appear on a phpinfo()? Seems like the extension isn't loaded. Jonathan On Tue, Jun 16, 2009 at 5:20 PM, Valentinas Bakaitisv.bakai...@gmail.com wrote: Hello! I am trying to track file upload progress using APC extension. However, when trying to use, it gives Fatal error: Call to undefined function apc_fetch() in C:\wamp\www\old\getprogress.php on line 3 I am using WAMP 2.0, with php 5.2.8 APC extension appear on extensions list and is enabled. Any ideas what i am doing wrong? here is the code of getprogress.php: * * $upload = apc_fetch('upload_1'); if ($upload) { if ($upload['done']) $percent = 100; else if ($upload['total'] == 0) $percent = 0; else $percent = $upload['current'] / $upload['total'] * 100; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problems with apc extension on wamp server.
Hello! I am trying to track file upload progress using APC extension. However, when trying to use, it gives Fatal error: Call to undefined function apc_fetch() in C:\wamp\www\old\getprogress.php on line 3 I am using WAMP 2.0, with php 5.2.8 APC extension appear on extensions list and is enabled. Any ideas what i am doing wrong? here is the code of getprogress.php: * * $upload = apc_fetch('upload_1'); if ($upload) { if ($upload['done']) $percent = 100; else if ($upload['total'] == 0) $percent = 0; else $percent = $upload['current'] / $upload['total'] * 100;
Re: [PHP] Problems with apc extension on wamp server.
Hi, Does the extension appear on a phpinfo()? Seems like the extension isn't loaded. Jonathan On Tue, Jun 16, 2009 at 5:20 PM, Valentinas Bakaitisv.bakai...@gmail.com wrote: Hello! I am trying to track file upload progress using APC extension. However, when trying to use, it gives Fatal error: Call to undefined function apc_fetch() in C:\wamp\www\old\getprogress.php on line 3 I am using WAMP 2.0, with php 5.2.8 APC extension appear on extensions list and is enabled. Any ideas what i am doing wrong? here is the code of getprogress.php: * * $upload = apc_fetch('upload_1'); if ($upload) { if ($upload['done']) $percent = 100; else if ($upload['total'] == 0) $percent = 0; else $percent = $upload['current'] / $upload['total'] * 100; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problems working with HTML using PHP's XML tools (placing mixed text/html into xpath-specified nodes...)
Is there a straightforward way (or, heck, any way) of placing mixed html/text content into xpath-specified nodes using any of PHP's XML tools? So far, I've tried SimpleXML and the DOM and things aren't coming out well. SimpleXML: /* $filename contains path to valid XML file, $xpathxpr contains valid XPath expression matching at least one document node, $fillval contains a mixed well-formed text/xhtml string to be pre-pended within each matching node */ $sx = simplexml_load_file($filename); $nodes = $sx-xpath($xpathxpr); foreach($nodes as $node) { $children = $node-children(); $children[0] = $fillval . $children[0]; } This only sortof works. I get $fillval appended before the original contents of each matching docment node but if I've put any markup in, it's all there as literal text (ie, a href=http://php.net;php.net/a wouldn't show up as a link, you'd see the actual markup when the document is rendered). A variation on this that I tried is creating a new SimpleXMLElement object, with the mixed text/markup string as an argument passed to the constructor, since the docs seem to indicate this is blessed. Weirdly, when I do this, it seems to actually be stripping out the markup and just giving the text. For example: $s = new SimpleXMLElement('a href=#Boo/a') echo $s; yields Boo (and echo $s-a yields nothing). This would be such a huge bug I have a hard time believing it, so I have to suspect there's a dance I'm not doing to make this work correctly. DOM XML: /* again, $filename contains path to valid XML file, $xpathxpr contains valid XPath expression matching at least one document node, $fillval contains a mixed well-formed text/xhtml string to be pre-pended within each matching node */ $domDoc = new DOMDocument(); $domDoc-loadHTML(file_get_contents($filename)); $search = new DOMXPath($domDoc); $nodes = $search-query($xpathxpr); foreach($nodes as $emt) { $f = $domDoc-createDocumentFragment(); $f-appendXML($fillval . $emt-nodeValue); $emt-nodeValue = ''; $emt-appendChild($f); } This also gets mixed results. It gets cranky and issues warnings about any HTML entities (despite that it seems it should be clear this is an HTML document given the invocation of loadHTML), and while I'm seeing some markup make it through, I'm not in other cases. I haven't quite figured out the difference. I can come up with some runnable tests if it will help, but I'm hoping someone's already familiar with the general issues with using PHP's XML tools to work with HTML that they can make some good commentary on the matter. Thanks, Weston -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems working with HTML using PHP's XML tools (placing mixed text/html into xpath-specified nodes...)
Weston C wrote: Is there a straightforward way (or, heck, any way) of placing mixed html/text content into xpath-specified nodes using any of PHP's XML tools? So far, I've tried SimpleXML and the DOM and things aren't coming out well. Not sure if it is of any use to you, I don't use XPath at all, but this php class modifies existing DOMDocument objects for filtering purposes and may give you an idea of how it is done: http://www.clfsrpm.net/xss/cspfilter_class.phps For a clearer example of adding a node to an existing document - from http://www.clfsrpm.net/xss/dom_script_test.phps That page is hard to read as it was butchered from another script, so here are the demonstrative parts: $import_prepare = 'div' . $somexmlcontentinastring . '/div'; $newDom = new DOMDocument(1.0,UTF-8); $newDom-loadXML($import_prepare); $elements = $newDom-getElementsByTagName(div); $imported_div = $elements-item(0); Now - $imported_div is an object node containing all the xml in import_prepare (you don't have to put it in a div, I did there because it's a form so I don't know the structure of xml input, putting it in a div gave me a known element that would be parent of all input) - but it is a node for the $newDom DOMDocument, I need to import it into the DOMDocument I am using. $testDiv = $myxhtml-importNode($imported_div,true); Now, $testDiv an a DOM object associated with the DOMDocument I want to import the node into. $xmlBody-appendChild($testDiv); Now the node is a child of the $xmlBody node, and has been incorporated into my DOMDocument. -=-=-=- importHTML() is problematic with some characters. Better to convert your additions to well formed xml and use importXML(); -=-=-=- While I am currently using DOMDocument for everything (yes, everything), I'm still learning it - do not consider me a guru on it's use. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problems with HTTPS and maybe an .htaccess???
Hey all, A while back I asked about forms that take credit card info and https. I have always put such forms behind SSL, but a site I have been asked to do maintenance work on did not, and after responses from the list and at my recommendation they installed an SSL and I modified the code to call https when it hits that form, so that part is okay. But now I have a problem implementing this on their development site, which is just a duplicate code base inside a directory public_html/_dev and a domain name dev.sitename.com, instead of sitename.com. The problem is, and I believe it may be the .htaccess file, redirecting the https pages to the live site. In other words, I'm trying to test something on the dev site in the shopping cart, but when I click a button that takes it to the CC form, hence https, although the URL says, https://dev.sitename.com/... I can tell it is actually on the live site because the code that executes is the old code on the live site, not the new code on the development server. I suspect the .htaccess file, which looks thusly... AddHandler application/x-httpd-php5 .php Options +FollowSymLinks IndexIgnore */* # Turn on the RewriteEngine RewriteEngine On # Rules RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php Now I'm no expert at these rewrite rules, and sometimes have to take several Valium, a shot of vodka, and weep for hours after working with them (okay, that was a bit of hyperbole), but it looks like any URL it cannot identify gets routed to index.php, and that is because index.php evaluates and processes URLs like sitename.com/shirts/mens/ ... and so forth. Question is, am I on the right track suspecting the rewrite rule for redirecting the https pages to the live site, and if so, anyone see a fix for this? Again, hyperbole aside, I'm no expert at rewrite rules. Much thanks. Any help, as always, is greatly appreciated. Skip -- Skip Evans Big Sky Penguin, LLC 503 S Baldwin St, #1 Madison WI 53703 608.250.2720 http://bigskypenguin.com Those of you who believe in telekinesis, raise my hand. -- Kurt Vonnegut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems with HTTPS and maybe an .htaccess???
RewriteRule . index.php Add an asterisk after the dot: RewriteRule .* index.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems with HTTPS and maybe an .htaccess???
Hey all, No, adding * after the period had no affect at all. Still goes to the live site. Any other ideas? I'm stumped, desperate and on the verge of requiring medication. Skip Alex S Kurilo aka Kamazee wrote: RewriteRule . index.php Add an asterisk after the dot: RewriteRule .* index.php -- Skip Evans Big Sky Penguin, LLC 503 S Baldwin St, #1 Madison WI 53703 608.250.2720 http://bigskypenguin.com Those of you who believe in telekinesis, raise my hand. -- Kurt Vonnegut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems with HTTPS and maybe an .htaccess???
No, adding * after the period had no affect at all. Still goes to the live site. Sorry, I misunderstood you. I'm too lazy to read all the message :) http and https may be handled by different virtual hosts. http for http://dev.sitename.com/ seems to be configured properly (Virtual host at port 80) but not https://dev.sitename.com/ (vhost at port 443). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problems with gnupg extension.
On 20 Apr 2009 at 11:37, Ray wrote: snip Any suggestions, Anyone? Ray Hi, I adapted these scripts for my own user and have not had any problems: http://www.theoslogic.com/scripts/php-gpg/ It does not use the gnupg extension at all but popen() or proc_open(). Regards Ian -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problems with gnupg extension.
On Monday 13 April 2009 10:17:28 Ray wrote: Hello all, I'm trying to use the gnupg extension and I think everything is properly installed. I'm just using test data. I'm encrypting and then immediately decrypting. But the decryption is failing with a unhelpful error message. error message : Warning: gnupg::decrypt() [gnupg.decrypt]: decrypt failed in /path/to/test2.php on line 18 any help or suggestions would be very much appreciated. details follow. Ray full output: raw data: this is a test encoded data: -BEGIN PGP MESSAGE- Version: GnuPG v2.0.11 (FreeBSD) hQIOA9qOyyMyQ2/bEAgArxLuVw5eShkL+/g9SCGcBm5/J1G78zrh6dWFisPFqWg1 MP3zj/QnWiD9zEtLmGJazP51pV2TpySpEbILze8sz6c/imRBYLrHhbxO6W1LJqXq rALUPDIe4qKtM7mC+K9EdFdkYRzWxi45eTK1DQtQazhqelWIb1NuaVu8vUKk/pIy duE0juP2j+8OHIlx36sUcATkvBO5a7Ak9tGUT5T5lRqjMzKa6TPuCsZukmVh43BG uqpz7H83LinwOCfUnyq3R2e/vIM2cv8t7jz17acOfYslonMxNz54i8jR8COmCmLY NhGORZUSLauyWGxAIDvkDcTFD4Jd5KxaXcMPEE7zwAf9HUWmKtqOqn825AjlBxNj 7gXEOtpsRMiYiYuISzHvitpPWXQPOPsoGnPRZZBvCNJcvAgg6hMx5c4Y7tGXTsma 2hkC9f4959kBwiGAFnQxJqz2pMDW+N3X23f+kwSrU7KoNrhnxUV1ywcUGaebwYM8 emIygCm6mS7T81JtXxhMto0sSqeE/zwHc3/03/KP57V7j2tHib4dN9ZOfB6yiubF PIwog0JYagjOfyNdGh3vRzvcYdDOqyWMgtY6XpZJwPESJlOADHVt5n844oHthRD3 MJVjwqjEz5qQiPq+kOmd4AdkpkEkRcCweYNEXVXPxpmlrduuu8kc4wsA5v3YXZ/C x9JNAVKW9tdPSxDoxbEKyAhVdurQAxmYe7FaCLl74lACQaUg/Otwb86pjUBesgx6 mXhQv+epG71sKY+LSDxGi8dSgbOOmfI2L09zy9XTEQ4= =85vG -END PGP MESSAGE- [if this line is blank, the decrypt key should have been added correctly]] Warning: gnupg::decrypt() [gnupg.decrypt]: decrypt failed in /path/to/test2.php on line 18 decoded data: Code: ?php $raw_data=this is a test; $passphrase=test; $recipient=m...@example.com; putenv('GNUPGHOME=/www/ohfinder/keys'); $gpg = new gnupg(); $gpg - seterrormode(gnupg::ERROR_WARNING); echo raw data: $raw_databr; $gpg-addencryptkey($recipient); $encrypted = $gpg-encrypt($raw_data); echo brbrencoded data: pre $encrypted/prebr; $gpg-adddecryptkey($recipient, $passphrase); echo $gpg - geterror(); echo [if this line is blank, the decrypt key should have been added correctly]]; echo 'br'; $plaintext = $gpg-decrypt($encrypted); echo $gpg - geterror(); echo brbrdecoded data: pre $plaintext /pre; ? Any suggestions, Anyone? Ray -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] problems with gnupg extension.
Hello all, I'm trying to use the gnupg extension and I think everything is properly installed. I'm just using test data. I'm encrypting and then immediately decrypting. But the decryption is failing with a unhelpful error message. error message : Warning: gnupg::decrypt() [gnupg.decrypt]: decrypt failed in /path/to/test2.php on line 18 any help or suggestions would be very much appreciated. details follow. Ray full output: raw data: this is a test encoded data: -BEGIN PGP MESSAGE- Version: GnuPG v2.0.11 (FreeBSD) hQIOA9qOyyMyQ2/bEAgArxLuVw5eShkL+/g9SCGcBm5/J1G78zrh6dWFisPFqWg1 MP3zj/QnWiD9zEtLmGJazP51pV2TpySpEbILze8sz6c/imRBYLrHhbxO6W1LJqXq rALUPDIe4qKtM7mC+K9EdFdkYRzWxi45eTK1DQtQazhqelWIb1NuaVu8vUKk/pIy duE0juP2j+8OHIlx36sUcATkvBO5a7Ak9tGUT5T5lRqjMzKa6TPuCsZukmVh43BG uqpz7H83LinwOCfUnyq3R2e/vIM2cv8t7jz17acOfYslonMxNz54i8jR8COmCmLY NhGORZUSLauyWGxAIDvkDcTFD4Jd5KxaXcMPEE7zwAf9HUWmKtqOqn825AjlBxNj 7gXEOtpsRMiYiYuISzHvitpPWXQPOPsoGnPRZZBvCNJcvAgg6hMx5c4Y7tGXTsma 2hkC9f4959kBwiGAFnQxJqz2pMDW+N3X23f+kwSrU7KoNrhnxUV1ywcUGaebwYM8 emIygCm6mS7T81JtXxhMto0sSqeE/zwHc3/03/KP57V7j2tHib4dN9ZOfB6yiubF PIwog0JYagjOfyNdGh3vRzvcYdDOqyWMgtY6XpZJwPESJlOADHVt5n844oHthRD3 MJVjwqjEz5qQiPq+kOmd4AdkpkEkRcCweYNEXVXPxpmlrduuu8kc4wsA5v3YXZ/C x9JNAVKW9tdPSxDoxbEKyAhVdurQAxmYe7FaCLl74lACQaUg/Otwb86pjUBesgx6 mXhQv+epG71sKY+LSDxGi8dSgbOOmfI2L09zy9XTEQ4= =85vG -END PGP MESSAGE- [if this line is blank, the decrypt key should have been added correctly]] Warning: gnupg::decrypt() [gnupg.decrypt]: decrypt failed in /path/to/test2.php on line 18 decoded data: Code: ?php $raw_data=this is a test; $passphrase=test; $recipient=m...@example.com; putenv('GNUPGHOME=/www/ohfinder/keys'); $gpg = new gnupg(); $gpg - seterrormode(gnupg::ERROR_WARNING); echo raw data: $raw_databr; $gpg-addencryptkey($recipient); $encrypted = $gpg-encrypt($raw_data); echo brbrencoded data: pre $encrypted/prebr; $gpg-adddecryptkey($recipient, $passphrase); echo $gpg - geterror(); echo [if this line is blank, the decrypt key should have been added correctly]]; echo 'br'; $plaintext = $gpg-decrypt($encrypted); echo $gpg - geterror(); echo brbrdecoded data: pre $plaintext /pre; ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems with exec() on windows
I can confirm the presence of the same issue on my installation, 5.2.9-2 on Windows XP. Very annoying bug. -- This message was sent on behalf of henrikol...@gmail.com at openSubscriber.com http://www.opensubscriber.com/message/php-general@lists.php.net/11719414.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] problems with loaded extensions
Hi, I have got an extension loaded in all three of my php config files (in cli, in cgi, and in apache2 directories). The functions in the extension are all accessible when running test scripts from the command line, like: php init.php for example, in the init.php file I have calls to several of the functions in my loaded extension. I also can print out the functions like this: print_r(get_loaded_extensions()); print_r(get_extension_funcs(vrad)); However, when I run these thru apache, all calls to the functions in my loaded extension fail even though the extension is present. If I do print_r(get_loaded_extensions()); I see my loaded extension vrad printed out as expected indicating it is loaded. If I run: if (extension_loaded(vrad)) it comes back true which further indicates that the extension is indeed loaded. But if I call using apache any of the functions in the loaded extension, or if I call: print_r(get_extension_funcs(vrad)); all I get is a blank white page with no errors. I would think that as long as the extension is loaded in both the cli php.ini and the apache2 php.ini, I would get the same results from the loaded extension. Any idea why it work thru the cli and not apache? Thanks, -Andres -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems with implode
Tom Worster skrev: On 3/24/09 9:25 AM, Andrea Giammarchi an_...@hotmail.com wrote: Dunno why you guys started talk about utf-8 problems, he has a list of ids which should contain only unsigned integers, otherwise I do not get how that query could work with an implode(',', $whatever) rather than 'id in ('.implode(',', array_map('mysql_real_escape_string', $whatever)).')' ... so, the problem could be more about missed ids in the array obtaining ,, ... so, in this case, array_filter before, no? it's certainly possible. but the way toke described his problem did not imply that his ids were unsigned integers. SELECT FROM ... WHERE id IN ('aardvark', 'abacus', 'abbey', ..., 'zulu', 'zygote'); AS written else it is not a problem with either implode nor with string, Only when sending debug info via unformatted mail. Which really should not give this problem, but it does one day I'll have time to figure out exactly what does trigger this error. Regards, Toke -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems with implode
Dunno why you guys started talk about utf-8 problems, he has a list of ids which should contain only unsigned integers, otherwise I do not get how that query could work with an implode(',', $whatever) rather than 'id in ('.implode(',', array_map('mysql_real_escape_string', $whatever)).')' ... so, the problem could be more about missed ids in the array obtaining ,, ... so, in this case, array_filter before, no? it's certainly possible. but the way toke described his problem did not imply that his ids were unsigned integers. SELECT FROM ... WHERE id IN ('aardvark', 'abacus', 'abbey', ..., 'zulu', 'zygote'); AS written else it is not a problem with either implode nor with string, Only when sending debug info via unformatted mail. Which really should not give this problem, but it does one day I'll have time to figure out exactly what does trigger this error. Regards, Toke it is probably the way the email message was formatted. it has to cut long lines to email line length limit. so you see some numbers are broken ie on different lines. Virgil http://www.jampmark.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Problems with implode
The mail problem came out later or I missed some post about it. So yes, I would pass that implode via wordwrap then wordwrap(implode(', ', $list), 100, \n, false); please note the space after the coma, to avoid truncated id. @Tom Worster I hope on daily basis you do NOT create arrays with single or double quoted strings when you need to implode an array of strings ... as I wrote already, if those where not numbers, that implode did not make sense: 'WHERE id IN ('.implode(',', array_map('mysql_real_escape_string', $whatever)).')'Regards Date: Thu, 26 Mar 2009 21:01:03 +0800 From: virgilio.quila...@gmail.com To: t...@ezl-data.dk CC: php-general@lists.php.net Subject: Re: [PHP] Problems with implode Dunno why you guys started talk about utf-8 problems, he has a list of ids which should contain only unsigned integers, otherwise I do not get how that query could work with an implode(',', $whatever) rather than 'id in ('.implode(',', array_map('mysql_real_escape_string', $whatever)).')' ... so, the problem could be more about missed ids in the array obtaining ,, ... so, in this case, array_filter before, no? it's certainly possible. but the way toke described his problem did not imply that his ids were unsigned integers. SELECT FROM ... WHERE id IN ('aardvark', 'abacus', 'abbey', ..., 'zulu', 'zygote'); AS written else it is not a problem with either implode nor with string, Only when sending debug info via unformatted mail. Which really should not give this problem, but it does one day I'll have time to figure out exactly what does trigger this error. Regards, Toke it is probably the way the email message was formatted. it has to cut long lines to email line length limit. so you see some numbers are broken ie on different lines. Virgil http://www.jampmark.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ News, entertainment and everything you care about at Live.com. Get it now! http://www.live.com/getstarted.aspx
Re: [PHP] Problems with implode
As stated before, packet size not the problem, data is delivered perfectly from MySQL. Problem seems to be when the result string is diplayed. I'll try to do a test with a numeric array: $list = array(12300..12800); and see what happens. regards, Toke Andrea Giammarchi skrev: What about MySQL max_allowed_packet setting? is it bigger than produced string? To: php-general@lists.php.net Date: Tue, 24 Mar 2009 15:23:20 +0100 From: t...@ezl-data.dk Subject: Re: [PHP] Problems with implode Per Jessen skrev: Andrea Giammarchi wrote: Dunno why you guys started talk about utf-8 problems, he has a list of ids which should contain only unsigned integers, otherwise I do not get how that query could work with an implode(',', $whatever) Very good point - maybe the OP has not yet tested his code that far? Is there a possibility that some of the id's are _not_ just plain integers made up of 0-9? /Per And exatly the reason I tried the following: $list[] = $row['uid']; $list[] = intval($row['uid']); $list[] = mb_convert_encoding($row['uid'], 'iso-8859-1'); $list[] = mb_convert_encoding(intval($row['uid']), 'iso-8859-1'); My best bet as for now: It isn't implode there's the problem, but the length of the string -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ More than messages–check out the rest of the Windows Live™. http://www.microsoft.com/windows/windowslive/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems with implode
Okay, tested in the following manner: for ($i=12300;$i12801;$i++){ // List is filled with integers, in the correct charset from PHP $list[] = $i; } $pidList = implode(',', $list); mail('y...@email.dom, 'debug implode', var_export(array($pidList, $list),1)); And I got the same error, which indicates that perhaps implode works just as it should but the representation is off. that in it self would be okay, but how then do we control that the query is actually correct ? If we cannot trust the debug output how then can we trust that the query is doing what it is supposed to do ? Regards, Toke Toke Herkild skrev: As stated before, packet size not the problem, data is delivered perfectly from MySQL. Problem seems to be when the result string is diplayed. I'll try to do a test with a numeric array: $list = array(12300..12800); and see what happens. regards, Toke Andrea Giammarchi skrev: What about MySQL max_allowed_packet setting? is it bigger than produced string? To: php-general@lists.php.net Date: Tue, 24 Mar 2009 15:23:20 +0100 From: t...@ezl-data.dk Subject: Re: [PHP] Problems with implode Per Jessen skrev: Andrea Giammarchi wrote: Dunno why you guys started talk about utf-8 problems, he has a list of ids which should contain only unsigned integers, otherwise I do not get how that query could work with an implode(',', $whatever) Very good point - maybe the OP has not yet tested his code that far? Is there a possibility that some of the id's are _not_ just plain integers made up of 0-9? /Per And exatly the reason I tried the following: $list[] = $row['uid']; $list[] = intval($row['uid']); $list[] = mb_convert_encoding($row['uid'], 'iso-8859-1'); $list[] = mb_convert_encoding(intval($row['uid']), 'iso-8859-1'); My best bet as for now: It isn't implode there's the problem, but the length of the string -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ More than messages–check out the rest of the Windows Live™. http://www.microsoft.com/windows/windowslive/ As stated before, packet size not the problem, data is delivered perfectly from MySQL. Problem seems to be when the result string is diplayed. I'll try to do a test with a numeric array: $list = array(12300..12800); and see what happens. regards, Toke Andrea Giammarchi skrev: What about MySQL max_allowed_packet setting? is it bigger than produced string? To: php-general@lists.php.net Date: Tue, 24 Mar 2009 15:23:20 +0100 From: t...@ezl-data.dk Subject: Re: [PHP] Problems with implode Per Jessen skrev: Andrea Giammarchi wrote: Dunno why you guys started talk about utf-8 problems, he has a list of ids which should contain only unsigned integers, otherwise I do not get how that query could work with an implode(',', $whatever) Very good point - maybe the OP has not yet tested his code that far? Is there a possibility that some of the id's are _not_ just plain integers made up of 0-9? /Per And exatly the reason I tried the following: $list[] = $row['uid']; $list[] = intval($row['uid']); $list[] = mb_convert_encoding($row['uid'], 'iso-8859-1'); $list[] = mb_convert_encoding(intval($row['uid']), 'iso-8859-1'); My best bet as for now: It isn't implode there's the problem, but the length of the string -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ More than messages–check out the rest of the Windows Live™. http://www.microsoft.com/windows/windowslive/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems with implode
works fine, created a html output to browser which displayed nicely. - weird regards Toke Toke Herkild skrev: As stated before, packet size not the problem, data is delivered perfectly from MySQL. Problem seems to be when the result string is diplayed. I'll try to do a test with a numeric array: $list = array(12300..12800); and see what happens. regards, Toke Andrea Giammarchi skrev: What about MySQL max_allowed_packet setting? is it bigger than produced string? To: php-general@lists.php.net Date: Tue, 24 Mar 2009 15:23:20 +0100 From: t...@ezl-data.dk Subject: Re: [PHP] Problems with implode Per Jessen skrev: Andrea Giammarchi wrote: Dunno why you guys started talk about utf-8 problems, he has a list of ids which should contain only unsigned integers, otherwise I do not get how that query could work with an implode(',', $whatever) Very good point - maybe the OP has not yet tested his code that far? Is there a possibility that some of the id's are _not_ just plain integers made up of 0-9? /Per And exatly the reason I tried the following: $list[] = $row['uid']; $list[] = intval($row['uid']); $list[] = mb_convert_encoding($row['uid'], 'iso-8859-1'); $list[] = mb_convert_encoding(intval($row['uid']), 'iso-8859-1'); My best bet as for now: It isn't implode there's the problem, but the length of the string -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ More than messages–check out the rest of the Windows Live™. http://www.microsoft.com/windows/windowslive/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems with implode
Maybe you can reduce your code a little using the range(); ?php $list = range(12300, 12801); $pidList = implode(',', $list); mail('y...@email.dom, 'debug implode', var_export(array($pidList, $list),1)); ? it's just a sugestion... Regards, Igor Escobar systems analyst interface designer www . igorescobar . com On Wed, Mar 25, 2009 at 4:42 AM, Toke Herkild t...@ezl-data.dk wrote: Okay, tested in the following manner: for ($i=12300;$i12801;$i++){ // List is filled with integers, in the correct charset from PHP $list[] = $i; } $pidList = implode(',', $list); mail('y...@email.dom, 'debug implode', var_export(array($pidList, $list),1)); And I got the same error, which indicates that perhaps implode works just as it should but the representation is off. that in it self would be okay, but how then do we control that the query is actually correct ? If we cannot trust the debug output how then can we trust that the query is doing what it is supposed to do ? Regards, Toke Toke Herkild skrev: As stated before, packet size not the problem, data is delivered perfectly from MySQL. Problem seems to be when the result string is diplayed. I'll try to do a test with a numeric array: $list = array(12300..12800); and see what happens. regards, Toke Andrea Giammarchi skrev: What about MySQL max_allowed_packet setting? is it bigger than produced string? To: php-general@lists.php.net Date: Tue, 24 Mar 2009 15:23:20 +0100 From: t...@ezl-data.dk Subject: Re: [PHP] Problems with implode Per Jessen skrev: Andrea Giammarchi wrote: Dunno why you guys started talk about utf-8 problems, he has a list of ids which should contain only unsigned integers, otherwise I do not get how that query could work with an implode(',', $whatever) Very good point - maybe the OP has not yet tested his code that far? Is there a possibility that some of the id's are _not_ just plain integers made up of 0-9? /Per And exatly the reason I tried the following: $list[] = $row['uid']; $list[] = intval($row['uid']); $list[] = mb_convert_encoding($row['uid'], 'iso-8859-1'); $list[] = mb_convert_encoding(intval($row['uid']), 'iso-8859-1'); My best bet as for now: It isn't implode there's the problem, but the length of the string -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ More than messages–check out the rest of the Windows Live™. http://www.microsoft.com/windows/windowslive/ As stated before, packet size not the problem, data is delivered perfectly from MySQL. Problem seems to be when the result string is diplayed. I'll try to do a test with a numeric array: $list = array(12300..12800); and see what happens. regards, Toke Andrea Giammarchi skrev: What about MySQL max_allowed_packet setting? is it bigger than produced string? To: php-general@lists.php.net Date: Tue, 24 Mar 2009 15:23:20 +0100 From: t...@ezl-data.dk Subject: Re: [PHP] Problems with implode Per Jessen skrev: Andrea Giammarchi wrote: Dunno why you guys started talk about utf-8 problems, he has a list of ids which should contain only unsigned integers, otherwise I do not get how that query could work with an implode(',', $whatever) Very good point - maybe the OP has not yet tested his code that far? Is there a possibility that some of the id's are _not_ just plain integers made up of 0-9? /Per And exatly the reason I tried the following: $list[] = $row['uid']; $list[] = intval($row['uid']); $list[] = mb_convert_encoding($row['uid'], 'iso-8859-1'); $list[] = mb_convert_encoding(intval($row['uid']), 'iso-8859-1'); My best bet as for now: It isn't implode there's the problem, but the length of the string -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ More than messages–check out the rest of the Windows Live™. http://www.microsoft.com/windows/windowslive/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems with implode
On 3/24/09 9:25 AM, Andrea Giammarchi an_...@hotmail.com wrote: Dunno why you guys started talk about utf-8 problems, he has a list of ids which should contain only unsigned integers, otherwise I do not get how that query could work with an implode(',', $whatever) rather than 'id in ('.implode(',', array_map('mysql_real_escape_string', $whatever)).')' ... so, the problem could be more about missed ids in the array obtaining ,, ... so, in this case, array_filter before, no? it's certainly possible. but the way toke described his problem did not imply that his ids were unsigned integers. SELECT FROM ... WHERE id IN ('aardvark', 'abacus', 'abbey', ..., 'zulu', 'zygote'); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problems with implode
Hi All, I've an array() with approx 1200 items (list of id-mappings) that part works fine. Now I want to add this list to a query: $where = id in (.$idList.); To accomplish that i do an implode: $idList = implode(',', $TidList); My problem is that some of the values gets concenated, others ere missing 2 or 3 cifres and some just doesn't show up. Is this some kind of implode feature or a string to large problem ? Regards, Toke Herkild -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems with implode
On 3/24/09 7:14 AM, Toke Herkild t...@ezl-data.dk wrote: I've an array() with approx 1200 items (list of id-mappings) that part works fine. Now I want to add this list to a query: $where = id in (.$idList.); To accomplish that i do an implode: $idList = implode(',', $TidList); My problem is that some of the values gets concenated, others ere missing 2 or 3 cifres and some just doesn't show up. my research turned up no conclusive answer to whether implode() is mbstring-safe. hence i consider it suspect. so you could profit by investigating if the problem is associated with the size of the array or with specific data its members. if implode() is not mbstring-safe (as i suspect) and your data is not all composed of 7-bit ascii and you use utf-8 strings in the array members then you may be experiencing a feature of php. if so, then you should be able to demonstrate the same feature with a much smaller array. please let us know what you discover. c u fsb -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems with implode
Toke Herkild wrote: Hi All, I've an array() with approx 1200 items (list of id-mappings) that part works fine. Now I want to add this list to a query: $where = id in (.$idList.); To accomplish that i do an implode: $idList = implode(',', $TidList); My problem is that some of the values gets concenated, others ere missing 2 or 3 cifres and some just doesn't show up. I can't reproduce that behaviour - I tried with ascii ('klop') and utf8 ('Köhler') text. /Per -- Per Jessen, Zürich (3.4°C) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems with implode
I don't think that would be a problem, the size of the array. I've used implode at least once or twice on fairly large arrays. More likely is something weird with your data. I'd do a print_r or var_dump to check the data and make sure that's not the issue. Not saying implode isn't having a problem, but I've never seen any issues with it like you're describing. -TG - Original Message - From: Toke Herkild t...@ezl-data.dk To: php-general@lists.php.net Date: Tue, 24 Mar 2009 12:14:01 +0100 Subject: [PHP] Problems with implode Hi All, I've an array() with approx 1200 items (list of id-mappings) that part works fine. Now I want to add this list to a query: $where = id in (.$idList.); To accomplish that i do an implode: $idList = implode(',', $TidList); My problem is that some of the values gets concenated, others ere missing 2 or 3 cifres and some just doesn't show up. Is this some kind of implode feature or a string to large problem ? Regards, Toke Herkild -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems with implode
TG wrote: I don't think that would be a problem, the size of the array. I've used implode at least once or twice on fairly large arrays. More likely is something weird with your data. Yeah, like the odd backspace or carriage return perhaps. /Per -- Per Jessen, Zürich (3.0°C) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems with implode
On Tue, Mar 24, 2009 at 9:15 AM, Per Jessen p...@computer.org wrote: TG wrote: I don't think that would be a problem, the size of the array. I've used implode at least once or twice on fairly large arrays. More likely is something weird with your data. Yeah, like the odd backspace or carriage return perhaps. I can't tell you how many times I've had data that contained and got all kinds of screwed up when data disapeared when really the browser was just turning it into an HTML tag. Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems with implode
On 3/24/09 8:58 AM, Per Jessen p...@computer.org wrote: I can't reproduce that behaviour - I tried with ascii ('klop') and utf8 ('Köhler') text. neither can i. if the mail systems don't screw it up, here's my test strings: $strs = array( 'Iñtërnâtiônàlizætiøn', 'החמאס: רוצים להשלים את עסקת שליט במהירות האפשרית', 'ايران لا ترى تغييرا في الموقف الأمريكي', '独・米で死傷者を出した銃の乱射事件', '國會預算處公布驚人的赤字數據後', '이며 세계 경제 회복에 걸림돌이 되고 있다', 'В дагестанском лесном массиве южнее села Какашура', 'นายประสิทธิ์ รุ่งสะอาด ปลัดเทศบาล รักษาการแทนนายกเทศมนตรี ต.ท่าทองใหม่', 'ભારતીય ટીમનો સુવર્ણ યુગ : કિવીઝમાં પણ કમાલ', 'ཁམས་དཀར་མཛེས་ས་ཁུལ་དུ་རྒྱ་གཞུང་ལ་ཞི་བའི་ངོ་རྒོལ་', 'Χιόνια, βροχές και θυελλώδεις άνεμοι συνθέτουν το', 'Հայաստանում սկսվել է դատական համակարգի ձեւավորումը', 'რუსეთი ასევე გეგმავს სამხედრო'); i created an array with 1000 repetitions of this array and imploded and exploded it successfully. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Problems with implode
Dunno why you guys started talk about utf-8 problems, he has a list of ids which should contain only unsigned integers, otherwise I do not get how that query could work with an implode(',', $whatever) rather than 'id in ('.implode(',', array_map('mysql_real_escape_string', $whatever)).')' ... so, the problem could be more about missed ids in the array obtaining ,, ... so, in this case, array_filter before, no? Regards Date: Tue, 24 Mar 2009 09:19:53 -0400 From: m...@neimeyer.org To: php-general@lists.php.net Subject: Re: [PHP] Problems with implode On Tue, Mar 24, 2009 at 9:15 AM, Per Jessen p...@computer.org wrote: TG wrote: I don't think that would be a problem, the size of the array. I've used implode at least once or twice on fairly large arrays. More likely is something weird with your data. Yeah, like the odd backspace or carriage return perhaps. I can't tell you how many times I've had data that contained and got all kinds of screwed up when data disapeared when really the browser was just turning it into an HTML tag. Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ More than messages–check out the rest of the Windows Live™. http://www.microsoft.com/windows/windowslive/
Re: [PHP] Problems with implode
2009/3/24 Toke Herkild t...@ezl-data.dk: Hi All, I've an array() with approx 1200 items (list of id-mappings) that part works fine. Now I want to add this list to a query: $where = id in (.$idList.); To accomplish that i do an implode: $idList = implode(',', $TidList); Are all of the Ids truly numeric? You could try it that way: $sql = SELECT * from a where x IN(' . implode(', ', $array) . ') implode string = ', ' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems with implode
On 3/24/09 9:15 AM, Per Jessen p...@computer.org wrote: TG wrote: I don't think that would be a problem, the size of the array. I've used implode at least once or twice on fairly large arrays. More likely is something weird with your data. Yeah, like the odd backspace or carriage return perhaps. if using utf-8, validate the data with mb_check_encoding() or preg_match('/^.{1}/us', $s) for example, could be that the strings in the big array are mixing encodings. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Problems with implode
Andrea Giammarchi wrote: Dunno why you guys started talk about utf-8 problems, he has a list of ids which should contain only unsigned integers, otherwise I do not get how that query could work with an implode(',', $whatever) Very good point - maybe the OP has not yet tested his code that far? Is there a possibility that some of the id's are _not_ just plain integers made up of 0-9? /Per -- Per Jessen, Zürich (4.1°C) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems with implode
Per Jessen skrev: Andrea Giammarchi wrote: Dunno why you guys started talk about utf-8 problems, he has a list of ids which should contain only unsigned integers, otherwise I do not get how that query could work with an implode(',', $whatever) Very good point - maybe the OP has not yet tested his code that far? Is there a possibility that some of the id's are _not_ just plain integers made up of 0-9? /Per And exatly the reason I tried the following: $list[] = $row['uid']; $list[] = intval($row['uid']); $list[] = mb_convert_encoding($row['uid'], 'iso-8859-1'); $list[] = mb_convert_encoding(intval($row['uid']), 'iso-8859-1'); My best bet as for now: It isn't implode there's the problem, but the length of the string -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems with implode
Tom Worster skrev: On 3/24/09 9:15 AM, Per Jessen p...@computer.org wrote: TG wrote: I don't think that would be a problem, the size of the array. I've used implode at least once or twice on fairly large arrays. More likely is something weird with your data. Yeah, like the odd backspace or carriage return perhaps. if using utf-8, validate the data with mb_check_encoding() or preg_match('/^.{1}/us', $s) for example, could be that the strings in the big array are mixing encodings. As for the data, it's numbers allright: array:0 is the imploded string array:1 is the array to be imploded array ( 0 = '12498,13018,13019,13020,13027,13028,13029,13031,13032,13030,13024,13026,13021,13022,13036,13035,13034,13023,12940,12991,12992,12993,12994,12995,12996,12997,12998,12999,13000,13001,13002,13003,13004,13005,13006,13007,13008,13009,13010,13011,13012,13013,13014,13015,13016,13017,12941,12942,12943,12944,12945,12946,12947,12948,12949,12950,12951,12952,12953,12954,12955,12956,12957,12958,12959,12960,12961,12962,12963,12964,12965,12966,12967,12968,12969,12970,12971,12972,12973,12974,12975,12976,12977,12978,12979,12980,12981,12982,12983,12984,12985,12986,12987,12988,12989,12990,12906,12939,12936,12937,12938,12934,12935,12930,12931,12933,12932,12925,12926,12927,12928,12916,12917,12918,12919,12920,12921,12907,12908,12909,12910,12911,12912,12913,12914,12915,12929,12922,12923,12924,12879,12884,12885,12886,12887,12888,12889,12890,12891,12892,12893,12894,12895,12896,12897,12898,13859,12899,12900,12901,12902,12903,12904,12905,12881,12882,12859,12860,12861,12862,12863,12864,12865,12866,1385 4,12867,12868,12869,12870,12871,12872,12873,12874,12875,12876,12877,12878,12843,12856,12857,12858,12853,12854,12855,12850,12851,12852,12846,12847,12848,12849,12844,12845,12836,12837,12838,12790,13898,12833,12834,12835,12830,12831,12832,12827,12828,12806,12807,12808,12809,12810,12811,12812,12813,12815,12816,12817,12818,12819,12820,12825,12826,12821,12823,12824,12822,12791,12792,12793,12794,12795,12796,12797,12798,12799,12800,12801,12802,12803,12804,12805,12829,12750,12770,12771,12772,12773,12774,12775,12776,12777,12778,12779,12780,12781,12782,12783,12784,12785,12786,12787,12788,12789,12767,12768,12751,12752,12753,12754,12763,12764,12765,12766,12757,12758,12759,12760,12762,12769,12716,12720,12721,12722,12723,12724,12725,12726,12727,12728,12729,12730,12731,12732,13676,12733,12734,12735,12736,12737,12738,12739,12740,12741,12742,12743,12744,12745,12746,12747,12748,12749,12717,12718,12719,12499,13889,13895,13894,13893,13892,13891,13890,13873,13756,13762,13763,13768,13764,13765,1376 6,13755,13757,13758,13767,13759,13760,13761,12500,12501,138 12502,12503,12504,12505,12506,12507,12510,12511,12512,12513,12514,12515,12516,12517,12518,12519,12520,12521,12522,12523,12524,12525,12526,12527,12528,12529,12530,12531,12532,12533,12534,12535,12536,12537,12538,12539,12540,12541,12542,12543,12544,12545,13875,13874,12546,12547,12548,12549,12550,12551,12552,12553,12554,12555,12556,12557,12558,12559,12562,12563,12564,12565,12560,12561,12566,13678,12567,12705,12714,12715,12706,12707,12708,12709,12710,12711,12712,12713,12674,12675,12676,12677,12678,12679,12680,12681,12682,12683,12684,12685,12686,12687,12688,12689,12690,12691,12692,12693,12694,12695,12696,12697,12698,13856,12699,12700,12701,12702,12704,12703,12568,13872,12569,12570,12571,12573,12574,12575,12576,12577,12578,12579,12580,12581,12582,12583,12584,12585,12586,12587,12588,12589,12590,12591,13871,12592,12593,12594,12595,12596,12597,12598,12599,12600,12601,12602,12603,12604,12605,12606,13870,12607,12608,12609,12610,12611,12612,12613,12614,12615,12616,12617,12618,12619,12620 ,12621,12622,12623,12624,12625,12626,12627,12628,12629,12630,12631,12632,12633,12634,12635,12636,12637,12638,12639,12640,12641,12642,12643,12644,12645,12646,12647,12648,12649,12650,12651,12652,12653,12654,12655,12656,12657,12658,12659,12660,12661,12662,12663,12664,12665,12666,12667,12668,12669,12670,12671,12672,12673,13037,13081,13082,13083,13084,13085,13086,13087,13088,13089,13090,13091,13092,13093,13094,13070,13663,13076,13077,13078,13079,13080,13071,13072,13073,13074,13075,13052,13053,13057,13058,13059,13060,13061,13062,13063,13064,13065,13066,13067,13068,13069,13054,13055,13056,13045,13046,13047,13048,13051,13049,13050,13038,13041,13042,13043,13044,13040,13039,12839,12840,12841,12842,13095,13374,13409,13412,13411,13410,13408,13404,13407,13406,13405,13403,13402,13395,13398,13401,13400,13399,13397,13396,13393,13394,13389,13392,13391,13390,13387,13388,13386,13385,13384,13383,13381,13382,13380,13379,13378,13376,13377,13375,13356,13372,13373,13371,13370,13369,13362,13367,13366 ,13364,13365,13363,13368,13359,13361,13360,13357,13358,13354,13704
RE: [PHP] Problems with implode
What about MySQL max_allowed_packet setting? is it bigger than produced string? To: php-general@lists.php.net Date: Tue, 24 Mar 2009 15:23:20 +0100 From: t...@ezl-data.dk Subject: Re: [PHP] Problems with implode Per Jessen skrev: Andrea Giammarchi wrote: Dunno why you guys started talk about utf-8 problems, he has a list of ids which should contain only unsigned integers, otherwise I do not get how that query could work with an implode(',', $whatever) Very good point - maybe the OP has not yet tested his code that far? Is there a possibility that some of the id's are _not_ just plain integers made up of 0-9? /Per And exatly the reason I tried the following: $list[] = $row['uid']; $list[] = intval($row['uid']); $list[] = mb_convert_encoding($row['uid'], 'iso-8859-1'); $list[] = mb_convert_encoding(intval($row['uid']), 'iso-8859-1'); My best bet as for now: It isn't implode there's the problem, but the length of the string -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ More than messages–check out the rest of the Windows Live™. http://www.microsoft.com/windows/windowslive/
[PHP] Problems with exec() on windows
Hi, I'm trying to use exec to call gammu.exe and send sms on windows XP. This works from commandline: C:\path\to\gammu.exe 1 --sendsms EMS 200 -text test1 test2 But if I run it through php like this: $command = \C:\path\to\gammu.exe\ --sendsms EMS 200 -text \test1 test2\.; @exec($command, $response, $retval); This always fails, returns 1 and the response is empty. If the last argument is a string with no spaces, and the double quotes were omitted, it works perfectly. If the double quotes are added around the string with no spaces, it fails again, which makes me believe that the problem is with the double quotes. I've used procmon and it shows that when the double quotes are added around the last argument, gammu.exe is not even called at all. Problem is that the double quotes are required by gammu to send an sms with spaces in it. Any ideas? :-( Luke
Re: [PHP] Problems with exec() on windows
On Thu, Mar 19, 2009 at 9:19 AM, Kyohere Luke pr0...@gmail.com wrote: Hi, I'm trying to use exec to call gammu.exe and send sms on windows XP. This works from commandline: C:\path\to\gammu.exe 1 --sendsms EMS 200 -text test1 test2 But if I run it through php like this: $command = \C:\path\to\gammu.exe\ --sendsms EMS 200 -text \test1 test2\.; @exec($command, $response, $retval); This always fails, returns 1 and the response is empty. If the last argument is a string with no spaces, and the double quotes were omitted, it works perfectly. If the double quotes are added around the string with no spaces, it fails again, which makes me believe that the problem is with the double quotes. I've used procmon and it shows that when the double quotes are added around the last argument, gammu.exe is not even called at all. Problem is that the double quotes are required by gammu to send an sms with spaces in it. I'm not sure if it will help, but the escapeshellarg() function looks like it might handle all that tricky slash-and-quote-adding for you: http://php.net/escapeshellarg Other than that, perhaps proc_open() would do what you need it to by completely separating the command's arguments from itself. http://php.net/proc_open HTH, -- // Todd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems with exec() on windows
On Thu, Mar 19, 2009 at 9:25 AM, haliphax halip...@gmail.com wrote: On Thu, Mar 19, 2009 at 9:19 AM, Kyohere Luke pr0...@gmail.com wrote: Hi, I'm trying to use exec to call gammu.exe and send sms on windows XP. This works from commandline: C:\path\to\gammu.exe 1 --sendsms EMS 200 -text test1 test2 But if I run it through php like this: $command = \C:\path\to\gammu.exe\ --sendsms EMS 200 -text \test1 test2\.; @exec($command, $response, $retval); This always fails, returns 1 and the response is empty. If the last argument is a string with no spaces, and the double quotes were omitted, it works perfectly. If the double quotes are added around the string with no spaces, it fails again, which makes me believe that the problem is with the double quotes. I've used procmon and it shows that when the double quotes are added around the last argument, gammu.exe is not even called at all. Problem is that the double quotes are required by gammu to send an sms with spaces in it. I'm not sure if it will help, but the escapeshellarg() function looks like it might handle all that tricky slash-and-quote-adding for you: http://php.net/escapeshellarg Other than that, perhaps proc_open() would do what you need it to by completely separating the command's arguments from itself. http://php.net/proc_open Also--if you're only concerned with a one-way process tunnel (read or write, but not both) then maybe popen() instead of proc_open() would be preferable for overhead/speed. Of course, that's if either of them do what you're looking for. -- // Todd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problems with displaying results
I have two queries one pulls out which users to use and the second pulls those users orders Looks something like this but is only pulling the first record: $query = SELECT `UserName`, `AdminID` FROM admin WHERE Key1 = 'YES' ; $result = mysql_query ($query) ; $row = mysql_fetch_assoc($result); //Reveal Variables for Debugging // include(VariableReveal2.php); echo (Hello br); //echo $row['AdminID']; echo ($row['UserName']); if ($row['Key1'] == NO) { header (Location: Welcome.php?AdminID=$AdminIDmsg=Sorry, you do not have access to that page.); } if (isset($_GET['SortBy'])) {$SortBy = $_GET['SortBy'];} else {$SortBy = 'WorkOrderID DESC';} if (isset($_GET['Page'])) {$Page = $_GET['Page'];} else {$Page = 1;} $PerPage = 30; $StartPage = ($Page - 1) * $PerPage; second query here is using the $row from the first (and yes I know not to use *, just did so here to keep post shorter) $sql= SELECT * FROM workorders WHERE AdminID = '.$row['AdminID'].' ; // $sql .= ORDER BY $SortBy LIMIT $StartPage, $PerPage; $result = mysql_query ($sql); $row2 = mysql_fetch_assoc($result); $Total = ceil(mysql_num_rows($result)/$PerPage); So this works but only half way as it only displays the first record in the table. Thanks Terion Happy Freecycling Free the List !! www.freecycle.org Over Moderation of Freecycle List Prevents Post Timeliness. Twitter? http://twitter.com/terionmiller Facebook: a href=http://www.facebook.com/people/Terion-Miller/1542024891; title=Terion Miller's Facebook profile target=_TOPimg src= http://badge.facebook.com/badge/1542024891.237.919247960.png; border=0 alt=Terion Miller's Facebook profile/a Groucho Marx - I have had a perfectly wonderful evening, but this wasn't it.
Re: SV: [PHP] Problems with images..
On Mon, Nov 3, 2008 at 2:46 PM, Ashley Sheridan [EMAIL PROTECTED]wrote: On Mon, 2008-11-03 at 15:56 +0100, Anders Norrbring wrote: Anders Norrbring wrote: I've been staring myself blind, so now I don't get anywhere, please do advice.. I have a web page printed with PHP, in a table I need to display images that are stored in a SQL DB. Getting the images into variables isn't an issue at all, but how do I output it? This is what I want to accomplish: trtdCurrent image:/tdtd - THE IMAGE HERE - /td/tr Starting to pull my hair.. Anders. img src=fetchimg?id=n/ fetchimg.php: header('Content-Type: image/jpeg'); $img=fetch from db; print $img; True Per, but I would prefer one single file in this case.. Anders. You can have the image script as part of the same PHP file, by checking to see if it is being called for an image rather than a normal page, but it just makes things more convoluted. Also, the base64 method will not work in IE. I had a similar problem at work that could only be solved by using a separate script to output the image. It can't be streamed inline in a consistent manner. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I too prefer to have the image called from a separate page. img src='getimage.php?id=12345'/ That way if the images are of differeing types (tiff/png/jpg/etc) I can locate all the handling code in the getimage.php file and its becomes the one place to handle this kind of stuff -- Bastien Cat, the other other white meat
[PHP] Problems with images..
I've been staring myself blind, so now I don't get anywhere, please do advice.. I have a web page printed with PHP, in a table I need to display images that are stored in a SQL DB. Getting the images into variables isn't an issue at all, but how do I output it? This is what I want to accomplish: trtdCurrent image:/tdtd - THE IMAGE HERE - /td/tr Starting to pull my hair.. Anders. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Problems with images..
-Original Message- From: Anders Norrbring [mailto:[EMAIL PROTECTED] Sent: Monday, November 03, 2008 7:44 AM To: php-general@lists.php.net Subject: [PHP] Problems with images.. I've been staring myself blind, so now I don't get anywhere, please do advice.. I have a web page printed with PHP, in a table I need to display images that are stored in a SQL DB. Getting the images into variables isn't an issue at all, but how do I output it? This is what I want to accomplish: trtdCurrent image:/tdtd - THE IMAGE HERE - /td/tr Starting to pull my hair.. trtdCurrent image:/tdtdimg src=?= $variableName ? //td/tr If you don't have the proper INI setting to allow for the short-hand ?= ?, you can replace it with: ?php echo $variableName; ? If this made you pull your hair out, then perhaps you should go back and get a fundamental understanding of HTML and PHP basics before trying to combine the two. Just sayin'. HTH, Todd Boyd Web Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php