php-general Digest 5 May 2004 12:35:36 -0000 Issue 2745 Topics (messages 185382 through 185416):
Re: WHERE clause...getting closer 185382 by: Richard Davey 185384 by: Curt Zirzow 185393 by: Ray Hunter 185401 by: Tom 185413 by: msa Re: SCP a file from my server to another using PHP 185383 by: Vail, Warren 185385 by: Kelly Hallman Re: cleaning word HTML code 185386 by: David Robley Re: re-keying an array 185387 by: Jason Barnett Re: word to pdf via web server ?? 185388 by: Jason Barnett 185391 by: Travis Low Re: Asking for data during a script 185389 by: Jason Barnett Re: PHP & Apache Version 185390 by: Jason Barnett 185392 by: Ray Hunter Regular Expression 185394 by: Tumurbaatar S. 185395 by: Tumurbaatar S. 185396 by: Paul Chvostek Re: PHP5 and PEAR 185397 by: php-list.xenonsolutions.com Re: paging methodology 185398 by: Paul Chvostek 185404 by: Brian Muldown parse error on fgets 185399 by: dburch.oz.net 185403 by: Brian Muldown complex array 185400 by: Chhai T 185402 by: roehr.zilleon.com Walk though array applying my highlighting routine? 185405 by: Dave Carrera 185407 by: Burhan Khalid 185410 by: Dave Carrera 185415 by: Dave Carrera protecting web page 185406 by: mserra.gdwd.com 185408 by: Brent Clark 185409 by: PHP Email List Re: Hi 185411 by: Phplist GD problems with opacity on translucent background 185412 by: Raymond den Ouden Importing data from one mysql server to an other 185414 by: Seth Bembeneck 185416 by: Seth Bembeneck Administrivia: To subscribe to the digest, e-mail: [EMAIL PROTECTED] To unsubscribe from the digest, e-mail: [EMAIL PROTECTED] To post to the list, e-mail: [EMAIL PROTECTED] ----------------------------------------------------------------------
--- Begin Message ---Hello msa, Wednesday, May 5, 2004, 2:18:57 AM, you wrote: m> $query_rsENews = 'SELECT * FROM NewsArchive WHERE YEAR(datePublished) = ' . m> YEAR('NOW'()) . ' AND MONTH(datePublished) = ' . MONTH('NOW'()) . ' ORDER BY m> sortBy DESC'; m> the above code got a parse error m> any ideas, anyone? Your quotes are wrong and you shouldn't use NOW like that: $query_rsENews = "SELECT * FROM NewsArchive WHERE YEAR(datePublished) = YEAR(NOW()) AND MONTH(datePublished) = MONTH(NOW()) ORDER BY sortBy DESC"; Should be a lot closer to what you want. -- Best regards, Richard Davey http://www.phpcommunity.org/wiki/296.html
--- End Message ---
--- Begin Message ---* Thus wrote msa ([EMAIL PROTECTED]): > > $query_rsENews = 'SELECT * FROM NewsArchive WHERE YEAR(datePublished) = ' . > YEAR(NOW()) . ' AND MONTH(datePublished) = ' . MONTH(NOW()) . ' ORDER BY > sortBy DESC'; > > got this error: > Fatal error: Call to undefined function: year() > > any ideas, anyone? You're mixing php and mysql, you've changed from using php's date() function to mysql's functions. Not to through a whole new twist into all your problems but your query probably should be written differently: $query_rsENews = 'SELECT * FROM NewsArchive WHERE datePublished >= DATE_FORMAT(NOW(), "%Y-%m-01") ORDER BY sortBy DESC'; And add an index on the datePublished column. You'll notice a considerable speed difference. Curt -- "I used to think I was indecisive, but now I'm not so sure."
--- End Message ---
--- Begin Message ---On Tue, 2004-05-04 at 19:18, msa wrote: > $query_rsENews = 'SELECT * FROM NewsArchive WHERE YEAR(datePublished) = ' . > YEAR('NOW'()) . ' AND MONTH(datePublished) = ' . MONTH('NOW'()) . ' ORDER BY > sortBy DESC'; > > > this is supposed to return only the records that have the current month and > year in the datePublished record. > > got this error: > Fatal error: Call to undefined function: year() > You sure you did not mean $dataPublished? -- ray
--- End Message ---
--- Begin Message --- Ray Hunter wrote:On Tue, 2004-05-04 at 19:18, msa wrote:
$query_rsENews = 'SELECT * FROM NewsArchive WHERE YEAR(datePublished) = ' . YEAR('NOW'()) . ' AND MONTH(datePublished) = ' . MONTH('NOW'()) . ' ORDER BY sortBy DESC';
this is supposed to return only the records that have the current month and year in the datePublished record.
got this error: Fatal error: Call to undefined function: year()
You sure you did not mean $dataPublished?
I think datePublished is his columnName?
But also:
Assuming mySQL (I can't find your original post?):
+++This is all wrong:
mysql> SELECT YEAR('NOW'());
ERROR 1064: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '())' at line 1
+++This is even worse, really: mysql> SELECT YEAR('NOW()'); +---------------+ | YEAR('NOW()') | +---------------+ | NULL | +---------------+ 1 row in set (0.00 sec)
+++This is what you want: mysql> SELECT YEAR(NOW()); +-------------+ | YEAR(NOW()) | +-------------+ | 2004 | +-------------+ 1 row in set (0.00 sec)
So I'd guess at your syntax being: $query_rsENews = <<<_SQL SELECT * FROM NewsArchive WHERE YEAR(datePublished) = YEAR(NOW()) AND MONTH(datePublished) = MONTH(NOW()) ORDER BY sortBy DESC _SQL;
HTH
--- End Message ---
--- Begin Message ---Curt, thanks, your code works perfectly. Can I ask you two questions? 1. I am not sure what you mean by adding an index. I looked in the mySQL help files and from what I can figure, I have already done that... 2. Now that the code actually works, we have come up with an issue. When the current e-news newsletter (the table holds the current AND the archive enews newsletters) doesn't get updated until a few days into the month, then the page will be blank until she puts articles in for that month......is there a way to just say "show me the articles with the most current dates" ? thanks "Curt Zirzow" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > * Thus wrote msa ([EMAIL PROTECTED]): > > > $query_rsENews = 'SELECT * FROM NewsArchive > WHERE datePublished >= DATE_FORMAT(NOW(), "%Y-%m-01") > ORDER BY sortBy DESC'; > > And add an index on the datePublished column. You'll notice a > considerable speed difference. > > Curt > -- > "I used to think I was indecisive, but now I'm not so sure."
--- End Message ---
--- Begin Message ---Matt, Question: when you run it and it fails, are you running it with php from the command line under your own userid or are you running it under a web server by invoking the php file using a URL as userid (nobody)? Warren Vail -----Original Message----- From: Matt Babineau [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 04, 2004 4:26 PM To: [EMAIL PROTECTED] Subject: [PHP] SCP a file from my server to another using PHP Hey All: Interesting problem that I haven't been able to solve using google. I want to move a file from my system using php, and I want to SCP it to another system. I setup the 2 keys and I can SCP files w/o using a password from the command line with no problem. When I take the same string that I jsut used to scp the file and run it using exec, system, passthru it doesn't work!! I'm baffled and was hoping someone had successfully done this before. Here is a chunk of code: $address = www.url.com; $value = "foldername"; if ($urlStatus == "Stopped") { $cmd = "scp /home/dev.site.com/mail_admin/commands/remove ".$gs['address'].":/home/www/$value/command"; echo " ".$cmd."<br>"; exec($cmd, $tmp, $rtmp); print_r($tmp); echo $rtmp; echo "<br><br>"; } TIA for anyone who has done this and knows the answer!!! -Matt
--- End Message ---
--- Begin Message ---May 4 at 4:25pm, Matt Babineau wrote: > When I take the same string that I jsut used to scp the file and run it > using exec, system, passthru it doesn't work!! I'm baffled and was > hoping someone had successfully done this before. > > $address = www.url.com; > $value = "foldername"; I assume this is not your actual code, but you'll need quotes: $address = "www.url.com"; > if ($urlStatus == "Stopped") { > $cmd = "scp /home/dev.site.com/mail_admin/commands/remove > ".$gs['address'].":/home/www/$value/command"; > echo " ".$cmd."<br>"; > exec($cmd, $tmp, $rtmp); > print_r($tmp); echo $rtmp; > echo "<br><br>"; > } Looks like you're trying to execute the command: scp /src/file www.url.com:/dest/file I think you'll need to use: scp /src/file [EMAIL PROTECTED]:/dest/file However, it's highly likely (as Warren Vail alluded) that the web server is running as a different userid, therefore it would be as if another user executed the scp command, thereby not accessing your keys. If that is the case, you may be able to set up a key for the webserver user to access the remote account. An alternative would be to use the -i option to scp to specify the key file (man ssh). In that case, it's likely that the webserver user would need permissions to be able to read that key file. Either solution could be a security issue, if you are on a shared server, as it might allow other users to use that same key to access the remote server as well. Proceed with caution! > TIA for anyone who has done this and knows the answer!!! Haven't done this, but I think it should work. Hope it helps at least. -- Kelly Hallman // Ultrafancy
--- End Message ---
--- Begin Message ---[EMAIL PROTECTED] (Kim Steinhaug) wrote in news:[EMAIL PROTECTED]: > Hello, > > Has anyone seen any resources on the net on OS independent sollutions. > Im aware of the Tidy software, but its not up for the job. Doesn't need > to be open source, but it needs to be OS independent. > > All tips are appretiated. > Demoroniser might be an option - its a PERL script so you need PERL for win. http://www.fourmilab.ch/webtools/demoroniser/ Cheers
--- End Message ---
--- Begin Message ---Justin Patrin wrote:
Richard Harb wrote:
Uh, I was wrong...
Foreach evaluates only once at initialisation... You can even unset the array once into the loop and it still works perfectly well (not that I recommend this as good practice or whatever, just did some checking to be sure :)
Richard
That will work because foreach iterates over a copy of the array. I often do things like:
foreach($arr as $key => $val) { if(some condition) { unset($arr[$key]); } }
Just one other thought. For those of you using PHP5, you can change the actual values in an array by using a reference.
foreach ($arr as $key => &$val) { if ($condition) { $val = $newval; } }
Putting the & in front of the $val tells PHP to use references, which would change the values of the original array. Just another way to skin a cat :)
--- End Message ---
--- Begin Message ---John Doe wrote:
hello, does any know how to conver microsoft word document to pdf via on the server using php language?? i try to implementing the feature that allow user to upload microsoft word document to the web server, after the upload, it automatic covert to pdf file ??? any one done that ?
thanks
john
I haven't done it, but if you have Windows + Word on the server then you can take advantage of the native Word API using COM. Pseudocode would be something like this:
1. Handle uploading the file to a temporary directory 2. Create a COM object for Word 3. Use this COM object load the temporary file 4. Use the adobe/pdf distiller to convert the file to a pdf file.
Please, if you do this let us know how it went so others can benefit.
Jason
--- End Message ---
--- Begin Message --- Jason Barnett wrote:John Doe wrote:
hello, does any know how to conver microsoft word document to pdf via on the server using php language?? i try to implementing the feature that allow user to upload microsoft word document to the web server, after the upload, it automatic covert to pdf file ??? any one done that ?
I haven't done it, but if you have Windows + Word on the server then you can take advantage of the native Word API using COM. Pseudocode would be something like this:
1. Handle uploading the file to a temporary directory 2. Create a COM object for Word 3. Use this COM object load the temporary file 4. Use the adobe/pdf distiller to convert the file to a pdf file.
I don't think you need steps 2 and 3. Just upload the file, then have a cron job (or Windows "at" job) distill the file. However, there might be some licensing issues -- you should probably look at the Adobe Distiller license.
Adobe sells a Distiller server for 100 users for $5000, unlimited users for (cough) $15,000. See their website for details.
cheers,
Travis
-- Travis Low <mailto:[EMAIL PROTECTED]> <http://www.dawnstar.com>
--- End Message ---
--- Begin Message ---germán m. rivera wrote:
Hi all!
Let's say I have a PHP script that needs the user to input some data during its execution. At the point the data is needed the browser could be redirected to a new page with a form where the user could enter the data. But thus is necessary to save the script state in order to continue its execution once it gets the data.
It would be preferable to mantein the execution of the script waiting for the data (in a while loop or sth similar). But, how can then the
Why keep the script running in the background? You'd just waste server time waiting for a response. What if you never received the response?
user introduce such data? With frames? One frame could execute the script, maybe outputting some information about execution and the other frame could ask for the data when needed. I think this could be done
That's reasonable You could seperate the "data" form into a seperate form and pass information if you really wanted to. Using a login for users and then passing information via $_SESSION variables would be a good way to do this. Or if you really really refuse to use sessions you could use serialize() and unserialize().
http://www.php.net/serialize http://www.php.net/unserialize
inserting JavaScript tags in the output of the script and flushing them to the browser in order to redirect the other frame to a form page. Is this valid? Do all browsers execute JavaScript commands before the page is completely charged?
No. PHP runs server side and can't wait on client side JavaScript execution. Besides, some people don't use JavaScript at all so if this is something that is required input then some people just won't see it.
Please, tell me if anyone has solved this problem in any other (maybe better) way.
Use a login mechanism, go to the data form, save the data into the session, and then retreive the session data on the other page.
Thanks, Regards, Germán
--- End Message ---
--- Begin Message ---Mike R wrote:
Is there a version of Apache 2+ that now works with PHP? Last I checked, the were incompatible, but recently someone I ran into claimed that the bugs have been for such a setup.
:)
Thanks,
-MIke
I've been using PHP + Apache 2 for a long time now.
http://www.php.net/install.apache2
--- End Message ---
--- Begin Message ---> Is there a version of Apache 2+ that now works with PHP? Last I checked, > the were incompatible, but recently someone I ran into claimed that the bugs > have been for such a setup. There is the warning not to use apache 2.0 and php in production. I am sure that there are many that are using it in production; however, it is not 100%. There are some issues with the multi-thread (not 100%). -- ray
--- End Message ---
--- Begin Message ---There's an input string like "{str1,str2,...,strN}". I want to capture all these strings and due to complexity of them I use a preg_match_all() instead of simple split. A pattern for the matching strings is ready but I cannot imagine how to specify that strings are separated by commas and the last one is not followed by comma. For example, I'm afraid that this pattern "/^{(?:(pattern),)*|(pattern)?}$/" can match and capture properly constructed input string, but, in addition, this matches if the string end is ",}". Any ideas?
--- End Message ---
--- Begin Message ---Forgot about curly brackets. The above example is: /^\{(?:(pattern),)*|(pattern)?\}$/
--- End Message ---
--- Begin Message ---On Wed, May 05, 2004 at 02:26:25PM +0900, Tumurbaatar S. wrote: > > There's an input string like "{str1,str2,...,strN}". I want to capture > all these strings and due to complexity of them I use a preg_match_all() > instead of simple split. A pattern for the matching strings is ready but > I cannot imagine how to specify that strings are separated by commas > and the last one is not followed by comma. For example, I'm afraid that > this pattern "/^{(?:(pattern),)*|(pattern)?}$/" can match and capture > properly constructed input string, but, in addition, this matches if > the string end is ",}". Any ideas? Why not just strip out the braces and explode on commas? That'll be lighter than regexps any day. If the input is guaranteed to be formatted the way you describe, you could do something like: $out = explode(",", substr($in, 1, strlen($in)-2)); -- Paul Chvostek <[EMAIL PROTECTED]> it.canada http://www.it.ca/ Free PHP web hosting! http://www.it.ca/web/
--- End Message ---
--- Begin Message ---So other than Config (for now), most other packages are compatible with PHP 5 already? What about the answers to my other questions? How will PEAR be organized in PHP 5? What do I need to look out for when making the transition, etc?? Thanks. -----Original Message----- From: Oliver Kuhl [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 04, 2004 3:48 AM To: [EMAIL PROTECTED] Subject: Re: [PHP] PHP5 and PEAR Hi, > How will PHP5 affect the current PEAR libraries? Will some of the PEAR > libraries be unusable? Will PEAR be distributed a different way with a > different type of file structure than the default PHP uses for PEAR? How > will it be organized and what do I need to watch out for? I haven't used > PEAR in the past and I'm just now starting to use some of the very useful > libraries. But the problem is that we're so close to PHP5 that I don't want > to get STUCK with a project in the near future that I need to write in PHP5 > and not have the same PEAR libraries that I enjoyed in PHP4. I want to know > if it would be better if I waited for PHP5 to come out before I start using > PEAR. Any suggestions, comments, etc? If you know of any websites with > articles that talk about this issue then that would be great. Anything would > be helpful at this point. I feel very lost. as I experienced some minutes ago, the package "config" has some problems with xml-parsing. I don't know where is the problem exactly, but it is not compatible. But if I am informed correctly, some of the packages are already compatible. Gruss, Ollie. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---On Tue, May 04, 2004 at 02:37:50PM -0700, Chris W. Parker wrote: > > > I don't follow what "$_GET record count from initial query performed > > above;" is for, but that's the basic methodology. > > well that just meant that after the initial count of records is found it > will be retrieved from the querystring instead of through a select > statement (because it had already been performed once before). I never bother with getting the initial record count. Unless you want to display the total number of available pages, of course (in the vein of Google search result set). If all you need is to include "Previous" and "Next" buttons in the right places, you could simply go with: $length=40; // or whatever if ($_GET['offset']) $offset=$_GET['offset']); else $offset=0; // do the query $q="SELECT colums FROM table WHERE yadda LIMIT $offset," . 1+$length; $r=mysql_query($q); // make Prev/Next links as required if ($offset > 0) $prev="<a href='?offset=" . $offset-$length . "'>"; else $prev=""; if (mysql_num_rows($r) > $length) $next="<a href='?offset=" . $offset+$length . "'>"; else $next=""; // show the head print " <td align=left>$prev</td>\n"; print " <td align=left>$next</td>\n"; print "</tr><tr>\n"; // show the page for ($i=0; $i<$length; $i++) { $row=mysql_fetch_array($r); print $row['blah']; // wrapped in stuff, of course } The idea here is that we always try to SELECT one more entry than we can display on the page. If mysql_num_rows() sees that many rows, then there's a page after the current one. And of course, if $offset is > 0 then there's a page before the current one. I find that this method simplifies my code. I don't need to store the result of a COUNT() in a session variable, so the "count" remains valid even if the number of records changes while someone's browsing. Note that this is not safe code as is. :) At the very least, you should format-check $_GET['offset'] before using it for anything. p -- Paul Chvostek <[EMAIL PROTECTED]> it.canada http://www.it.ca/ Free PHP web hosting! http://www.it.ca/web/
--- End Message ---
--- Begin Message ---Chris W. Parker wrote:
ok. this is what i was already doing in my previous app but i was just looking to see if it could be streamlined some how.
You could perform the full (without LIMIT) query once, Cache the results array (using PEAR Cache) and move back-and-forth through this Cached array. Depending on the size of your resultset and the srength of your MySQL Server, this may or may not provide a mild performance boost.
-brian
--- End Message ---
--- Begin Message ---Using PHP 4 with this code:
if ($csvfile = fopen($csvpath, "r")) { while (!feof ($csvfile)) { $filestring = fgets( $csvfile , 255); } } I get a parse error on the line : $filestring = fgets( $csvfile , 255);
Any ideas why this is happening? replacing it with fread also returns a parse error.
Please reply to me directly as the digest takes awhile to get to me.
-- Without deviation from the norm, progress is not possible. - Frank Zappa
--- End Message ---
--- Begin Message --- [EMAIL PROTECTED] wrote:Using PHP 4 with this code:
if ($csvfile = fopen($csvpath, "r")) { while (!feof ($csvfile)) { $filestring = fgets( $csvfile , 255); } } I get a parse error on the line : $filestring = fgets( $csvfile , 255);
Any ideas why this is happening? replacing it with fread also returns a parse error.
Please reply to me directly as the digest takes awhile to get to me.
I don't get a parse error making a new document just with your code (I did get an "Undefined variable $cvspath" - but that's only a NOTICE, and obviously not the problem you describe).
Are you certain you don't have an error above/below this code snip (maybe missing a trailing curly bracket somewhere)?
-brian
--- End Message ---
--- Begin Message ---Is there an easier, quicker way to access the values in this array returned from a SOAP request? This is the result of my print_r() :Array ( [0] => Array ( [name] => xxxx [description] => yyyyy [members] => Array ( [0] => Array ( [group] => abc ) [1] => Array ( [group] => cdf ) ) ) [1] => Array ( [name] => kkkkkk [description] => bbbbbbb [members] => Array ( [0] => Array ( [group] => jkl ) [1] => Array ( [group] => lmn ) [2] => Array ( [group] => Mnop ) ) ) )Currently, I to access the members array, I have to do this: foreach($result as $rows) { foreach ($rows as $key=>$val) { #print "$key = $val } foreach ($rows[members] as $row2) { foreach ($row2 as $key2=>$val2) { print "$key2 = $val2 } }}Thanks,Chhai
--- End Message ---
--- Begin Message ---Chhai T <[EMAIL PROTECTED]> schrieb am 05.05.2004, 09:55:25: > Is there an easier, quicker way to access the values in this array returned > from a SOAP request? This is the result of my print_r() :Array > ( > [0] => Array > ( > [name] => xxxx [description] => yyyyy > [members] => Array > ( > [0] => Array > ( > [group] => abc ) > > [1] => Array > ( > [group] => cdf > ) > > ) > > ) > > [1] => Array > ( > [name] => kkkkkk [description] => bbbbbbb > [members] => Array > ( > [0] => Array > ( > [group] => jkl > ) > > [1] => Array > ( > [group] => lmn > ) > > [2] => Array > ( > [group] => Mnop > ) > > ) > > ) > > )Currently, I to access the members array, I have to do this: > foreach($result as $rows) > { > foreach ($rows as $key=>$val) > { > #print "$key = $val > } foreach ($rows[members] as $row2) > { > foreach ($row2 as $key2=>$val2) { print "$key2 = > $val2 > } }}Thanks,Chhai What about this: $count = count($result); for ($i = 0; $i < $count; $i++) { $tempCount = count($result[$i]['members']); for ($k = 0; $k < $tempCount; $k++) { echo $result[$i]['members'][$k]['group']; } } This should output the groups. Heven't tested it, though. Regards, Torsten
--- End Message ---
--- Begin Message ---Hi List, I have worked out how to highlight all search words in a string. I hope its useful to some one. Please make it better if you can so we can all share it. But what I want to know is how can I treat each string with this highlighting routine individually so that my output is each string highlighted where necessary like the single string code dose below. So I turn $string into an array by $string[] for each three lines and tackle each one separately and when all search words are highlighted for that string do the next then the next and end up with 3 strings with each word in the string highlighted. Sorry for such a big post but I am trying to be as clear as possible to help others who may find this useful Thank you for any help or code adjustments Dave Carrera --- Current code below --- <?php $string = "Hello hello server site search me and highlight my words in search array words"; //$string = "Hello hello this is the second array elemaent to test server"; //$string = "this IS the third element of an array for words testing"; $string2 = "Hello hello server site search me and highlight my words in search array words"; $search = "hello array words"; //$string = trim($string); $search = trim($search); $words = explode(' ',$search); $words = array_unique($words); //$mysearchstring = strchr ($string,$far[0]); //$bold_find = substr($mysearchstring,0,$chars); for($i=0; $i<=count($words); $i++){ $word = preg_replace("/#/","\#",$words[$i]); $pregmatch = "#($word)(?![^<]*>)#i"; $pregreplace = "<b>$1</b>"; $h_string = preg_replace($pregmatch,$pregreplace,$string); $string = $h_string; } echo "Clean: $string2<br />"; echo "Criteria: $search<br />"; echo "HighLighted: $h_string<br />"; ?> --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.676 / Virus Database: 438 - Release Date: 03/05/2004
--- End Message ---
--- Begin Message ---Dave Carrera wrote:
Hi List,
I have worked out how to highlight all search words in a string. I hope its useful to some one. Please make it better if you can so we can all share it.
But what I want to know is how can I treat each string with this highlighting routine individually so that my output is each string highlighted where necessary like the single string code dose below.
So I turn $string into an array by $string[] for each three lines and tackle each one separately and when all search words are highlighted for that string do the next then the next and end up with 3 strings with each word in the string highlighted.
http://www.php.net/array_walk
array_walk -- Apply a user function to every member of an array
--- End Message ---
--- Begin Message ---Hi Burhan, Tried that but I think I did not use it in the correct place, tried many. Could I be very cheeky and ask for an example using my code listed in the previous post ? Thank you for your reply and any help you may give. Dave Carrera -----Original Message----- From: Burhan Khalid [mailto:[EMAIL PROTECTED] Sent: 05 May 2004 11:00 To: Dave Carrera; [EMAIL PROTECTED] Subject: Re: [PHP] Walk though array applying my highlighting routine? Dave Carrera wrote: > Hi List, > > I have worked out how to highlight all search words in a string. I > hope its useful to some one. Please make it better if you can so we > can all share it. > > But what I want to know is how can I treat each string with this > highlighting routine individually so that my output is each string > highlighted where necessary like the single string code dose below. > > So I turn $string into an array by $string[] for each three lines and > tackle each one separately and when all search words are highlighted > for that string do the next then the next and end up with 3 strings > with each word in the string highlighted. > http://www.php.net/array_walk array_walk -- Apply a user function to every member of an array --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.676 / Virus Database: 438 - Release Date: 03/05/2004 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.676 / Virus Database: 438 - Release Date: 03/05/2004
--- End Message ---
--- Begin Message ---Why am I getting three arrays ? --- code --- <?php $string[] = "Hello hello server site search me and highlight my words in search array words"; $string[] = "Hello hello this is the second array elemaent to test server"; $string[] = "this IS the third element of an array for words testing"; $string2 = "Hello hello server site search me and highlight my words in search array words"; $search = "hello search"; //$string = trim($string); $search = trim($search); function searchlines(){ global $search; global $string; $words = explode(' ',$search); $words = array_unique($words); for($i=0; $i<=count($string); $i++){ $word = preg_replace("/#/","\#",$words[$i]); $pregmatch = "#($word)(?![^<]*>)#i"; $pregreplace = "<b>$1</b>"; $h_string = preg_replace($pregmatch,$pregreplace,$string); $string = $h_string; } echo $string; } array_walk($string, 'searchlines'); //echo "Clean: $string2<br />"; //echo "Criteria: $search<br />"; //echo "HighLighted: $h_string<br />"; ?> My output is 3 x the expected output. Why ? Any help is appreciated Dave Carrera -----Original Message----- From: Burhan Khalid [mailto:[EMAIL PROTECTED] Sent: 05 May 2004 11:00 To: Dave Carrera; [EMAIL PROTECTED] Subject: Re: [PHP] Walk though array applying my highlighting routine? Dave Carrera wrote: > Hi List, > > I have worked out how to highlight all search words in a string. I > hope its useful to some one. Please make it better if you can so we > can all share it. > > But what I want to know is how can I treat each string with this > highlighting routine individually so that my output is each string > highlighted where necessary like the single string code dose below. > > So I turn $string into an array by $string[] for each three lines and > tackle each one separately and when all search words are highlighted > for that string do the next then the next and end up with 3 strings > with each word in the string highlighted. > http://www.php.net/array_walk array_walk -- Apply a user function to every member of an array --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.676 / Virus Database: 438 - Release Date: 03/05/2004 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.676 / Virus Database: 438 - Release Date: 03/05/2004
--- End Message ---
--- Begin Message ---Hi, i'm designing a web application and i want to protect my web page from printing and if possible want to protect source code too. Do you know any solution that can help me. I've find an application named HTML guard but it only work for static html pages. I need more a class or function to prevent for printing. Thanks for your help, Marc
--- End Message ---
--- Begin Message ---> i'm designing a web application and i want to protect my web page from > printing and if possible want to protect source code too. > > Do you know any solution that can help me. I've find an application named > HTML guard but it only work for static html pages. I need more a class or > function to prevent for printing. Hi No disrespect Whats wrong in sharing your code believe in open source hmmm! Just something I was wondering Kind Regards Brent Clark
--- End Message ---
--- Begin Message ---> Do you know any solution that can help me. I've find an application named > HTML guard but it only work for static html pages. I need more a class or > function to prevent for printing. Disclaimer:: To my knowledge! :) The only thing off hand that I can think of that would prevent printing is a PDF file during setup. Your comparing apples to oranges here. PHP is server side, printing takes place on the client's machine. So they do have control over printing. You could check with Javascript folks, not sure if there is anything there that would allow for printing to be disabled as your normal browser's hotkeys such as CTRL+P will allow for printing even if you took away all other menus and drop downs. One thing you can do to limit the viewablilty of the source code is to place your website in Frames (This is optionally the last resort, as frames [in my own opinion] suck). And then using a "no right click" javascript application. Otherwise aftermarket encryption tools could help you here. But again, PHP isn't the answer for either of these. HTH, Wolf :)
--- End Message ---
--- Begin Message ---<<attachment: zqyshdiypg.bmp>>
--- End Message ---
--- Begin Message ---Hi,
I have a little problem with a script I am trying to make.
The main problem is that when I draw something on a translucent png created with gd, it will still take the color which was set as transparent color.
For a demo look at
http://www.cranberries-fan.com/images/transparent/test.php
The backgroundcolor is set to black so in the black box it seems to be ok, but in the yellow box you can see that the transparentcolor is blended over black :-( while the empty spaces around the circle is actually translucent.
Am I doing something wrong? I read something on the net about the bundled gd having a bug compared to this issue, so I installed php 4.3.6 this morning so that the GD lib would have version 2.0.22
GD Support enabled GD Version bundled (2.0.22 compatible) FreeType Support enabled FreeType Linkage with freetype T1Lib Support enabled GIF Read Support enabled JPG Support enabled PNG Support enabled WBMP Support enabled XBM Support enabled
look for the script at http://www.cranberries-fan.com/images/transparent/genimage.phps
What am I doing wrong or what is the GD lib doing wrong?
--- End Message ---
--- Begin Message ---I'm working on a project that collects data from different mysql servers, combines the data and then displays it. My problem right now is the collection part. I have two ideas: 1st, write a php script that is placed on the webserver where the database is. Every time my webpage is opened, it contacts each webserver and retrieves the info from the script. --> for this I thought if I could do a db query and export the data to a file then just upload the file to my server. Then I would have a script import the data Or, have the script get the info, then contact my mysql database and import the data that way, but how does it get from one connection to an other? 2nd, write a script that connects to the database each time my webpage is called. which one is best? How would I get the data so that it can be imported into my database? How would I transmit the data efficiently after I get it?(there can be hundreds of records on any given server). For those of you who are interested, what I'm trying to do is provide a centeral location for stats to be displayed for an online game called Delta Force. Any ideas? Thanks, Seth
--- End Message ---
--- Begin Message ---I'm working on a project that collects data from different mysql servers, combines the data and then displays it. My problem right now is the collection part. I have two ideas: 1st, write a php script that is placed on the webserver where the database is. Every time my webpage is opened, it contacts each webserver and retrieves the info from the script. --> for this I thought if I could do a db query and export the data to a file then just upload the file to my server. Then I would have a script import the data Or, have the script get the info, then contact my mysql database and import the data that way, but how does it get from one connection to an other? 2nd, write a script that connects to the database each time my webpage is called. which one is best? How would I get the data so that it can be imported into my database? How would I transmit the data efficiently after I get it?(there can be hundreds of records on any given server). For those of you who are interested, what I'm trying to do is provide a centeral location for stats to be displayed for an online game called Delta Force. Any ideas? Thanks, Seth
--- End Message ---