Re: [PHP] reading txt file - certain lines
Everything is possible :) And in this case, it seems, that lines are delimited by br ... i'm not quite sure, whether br can be used in explode as a delimiter, if so, you have no problem and you just read all the file into variable, $lines = explode('br', $variable) and you have lines in $lines... if br can not be explode's parameter, i would use str_replace to replace it with ie. #13 and then explode it... or use some regular expressions... it depends on how fast you need it... :) hope this was what you needed... :) regards, m. Dustin Krysak wrote: Hi there.. .I am displaying info (on music) from a text file with the following code... ?php //open the file handler $fp02=fopen(assets/lib/php/itunes/recent.txt,r); //Read the track info $recent=fgets($fp02); //close the file. echo $recent; fclose($fp02); ? Now the contents of said text file would read something like the following: bLiar/bbrby ibSex Pistols/bibriNever Mind The Bollocks/ibrPlayed: 2004/07/28, 1:48:29 PMbr--brbLet's Rave On/bbrby ibThe Raveonettes/bibriChain Gang Of Love/ibrPlayed: 2004/07/28, 1:46:37 PMbr--brbNo Remorse/bbrby ibMetallica/bibriKill 'Em All/ibrPlayed: 2004/07/28, 1:40:17 PMbr--brbThis Is Our Emergency/bbrby ibPretty Girls Make Graves/bibriThe New Romance/ibrPlayed: 2004/07/28, 1:36:37 PMbr--brbFreestylin'/bbrby ibGreyboy/bibriFreestylin'/ibrPlayed: 2004/07/28, 1:30:25 PMbr--brbIn My Head/bbrby ibNaked Raygun/bibriRaygun...Naked Raygun (Reissue)/ibrPlayed: 2004/07/28, 1:26:37 PMbr--brbLust To Love/bbrby ibThe Go-Go's/bibriReturn To The Valley Of The Go-Go's/ibrPlayed: 2004/07/28, 1:23:13 PMbr--brbKim You Bore Me To Death/bbrby ibGrandaddy/bibriConcrete Dunes/ibrPlayed: 2004/07/28, 1:18:37 PMbr--brbSonderkommando/bbrby ibGwar/bibriThis Toilet Earth/ibrPlayed: 2004/07/28, 1:13:49 PMbr--br Now what I want to do is read this file, but only say read 5 songs worth, then I would place the PHP code in (another table) and display the next 5 songs and so on This just allows for a more flexible layout in the final presentation. the way I am having the text files written, there is no way to get it to produce seperate text files - otherwise this would be easy to do Is this possible? Thanks in advance! Dustin -- Miroslav Hudak developer designer http://hudak.info -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URGENT: Space char in rewriterule
I think, the point, Curt wanted to point out was, that URI CAN NOT contain SPACE character and all SPACE characters (ord 32) are converted to %20 ... thus, space character in rewrite rule will lead to bogus URI... thus, browser will send %20 instead and... dunno if apache will convert it to before applying the regexp, but if not, this will lead into your problem. Couldn't you just avoid that space by encoding? m. Robert Winter wrote: It didn't work. Still the same problem. Thanks Marek Kilimajer [EMAIL PROTECTED] escribió en el mensaje news:[EMAIL PROTECTED] Robert Winter wrote: I have the following rewriterule: RewriteRule ^(([0-9]|[A-Z]|[a-z]|_)+)$ redirect.php?$1 [L] that transforms http://mysite.com/XXX to http://mysite.com/redirect.php?XXX and I need to also include to space char, for example that transforms http://mysite.com/AB XX to http://mysite.com/redirect.php?AB XX I didn't find a way to write the characters. I tested with RewriteRule ^(([0-9]|[A-Z]|[a-z]|_| )+)$ redirect.php?$1 [L] but didn't work. Thanks! Rob Did you try RewriteRule ^([0-9A-Za-z_%]+)$ redirect.php?$1 ? -- Miroslav Hudak developer designer http://hudak.info -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about for
?php for ($x = 0; $x 10; $x += 2) echo $x.','; ? m. Henri Marc wrote: Hello, I woudlike to use a loop: for ($i=1;$i11;$i++) But instead of incrementing with 1, I would like to increment by 2. So $i would be 1,3,5,7,9. I tried to find the answer may be with step but couldn't find anything. Thank you for your help. Dave Vous manquez despace pour stocker vos mails ? Yahoo! Mail vous offre GRATUITEMENT 100 Mo ! Crez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/ Le nouveau Yahoo! Messenger est arriv ! Dcouvrez toutes les nouveauts pour dialoguer instantanment avec vos amis. A tlcharger gratuitement sur http://fr.messenger.yahoo.com -- Miroslav Hudak developer designer http://hudak.info -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] editor for remote files using ssh
Vi or ViM :) m. Peter Risdon wrote: I have been using emacs/tramp for editing files on remote machines, but I find it can be flaky - no doubt I am doing something wrong. Can anyone suggest a good programmers' text editor that at least has syntax highlighting and can use ssh for accessing files directly on remote machines? I need a Unix program, preferably a FreeBSD port, but am happy to compile something myself if it will work consistently or at least give some kind of error message if it has difficulty, and not just hang. TIA. Peter. -- Miroslav Hudak developer designer http://hudak.info -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php and images
I have a certain difficulties in case of processing large images thru GD2 library. GD2 has some problems with image processing and it results in some exception and GD just crashes. I have to mention, that the crash causes whole php interpreter to crash and execution of the script is terminated without any warning or handlable event :(... I don't know for certain now, which command causes it, but it seems that imagecopyresampled is the origin of the problems. So if you are using GD2 with large images, this may be the issue. regards, m. Roman Duriancik wrote: I have problem with jpg pictures in php pages. Path and picture is correct but when i want see picture in php script picture don't show. I use PHP4.3.4 on apache server 2.0.44 on Windopws 2000 Server. Thanks for help. -- Miroslav Hudak developer designer http://hudak.info -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can't install PHP on Windows/Apache
Have you added the line with the hash mark (#) ??? if so, then it's commented out... that's the first point. The second one is, that when using Apache 2.0.50, you should use php4apache2 module instead (I'm not ABSOLUTELLY sure of it, while for a longer time using PHP5, but I hope, that somewhat like this was there,... check it :) Regards, m. abrea wrote: Dear list, I am trying to install PHP 4.3.8 as a module of Apache 2.0.50 on a Windows 98 computer. Apache alone runs ok. After I installed PHP with the installer package, I added the following line at the end of the Apache httpd.conf together with the AddType statements: # LoadModule php4_module c:/php/php4apache.dll When I uncomment this line there is an error message saying that a resource is missing (or something like that, the DOS window disappears very quickly so I can't copy it). This line has worked ok on other computers I have installed with PHP 4.3.4 on Apache 1.3.29 and PHP 4.3.3 on Apache 1.3.27. I tried to install these programs but PHP does not run either, although Apache does. I have tried with both php4apache.dll and php4apache2.dll, but I still get the error message. The paths in the c:\windows\php.ini file point to the .dll file correctly. Could anybody please tell me what the problem could be? Thank you in advance Alberto Brea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink(), is it suppose to delete file???
This could happpen when the file is open by another process,... then file is deleted, but filename is still there until the file is not free of any open filedescriptors... I don't know exactly what processes happens in kernel when deleting the file, but it's something like that... and it could result in your problem... m. Scott Fletcher wrote: I have a file that was 25 KB and I use the unlink() to remove the file. When I rechecked it, I found that the file is still there but it's filesize is 0 KB. Is unlink() suppose to remove the file or what?? FletchSOD -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] OT but need guidance in timing page views
I would do it this way: - open the page and create hidden iframe (or frame with 0% width/height) which will be refreshing itself every ... let's say ... 2 minutes... then you'll get up to 2 minutes accurate numbers... the refreshed page would write timestamp to database every refresh... when the user crashes or leaves the page without logging off, you know, that his next refresh (and last one) would be LASTREFRESH + 2mins ... that gives you quite accurate numbers when implemented correctly. On the other hand, it will be a bit load producing, while that subsequent writes to database... Hope it helped a bit, regards, m. Robb Kerr wrote: I know that this is somewhat off topic, but I just need a starting place to do the research and thought someone here might be able to help. I am developing an application in which I need to time how long a visitor remains within a module and how long they view each page. I can create the appropriate fields in MySQL and can use PHP to do the appropriate calcualtions. What I don't know is how I communicate this information to the server. I can use POST or GET statements to pass info with page turns but what do I do if the visitor leaves the site without logging out or experiences a machine crash? Also, if anyone knows of a good javascript newsgroup, please pass along the info. Thanx, Robb -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] OT but need guidance in timing page views
Hi! This is what you need :) You have hidden frame (FRAME not layer!!!) (it means FRAME src=check.php height=0 [noborders etc])... then in check.php would be something like this: $id = $myid; //myid will be stored in session after user logs in Connect to database, pair ID with a row in table and update mytable set endtime = UNIX_TIMESTAMP() where id = myid; do this every 2 minutes (ie with META refresh tag set to 120 secs) ... if user changes page, then do following: check, if last refresh (endtime) is less then 2 minutes ago... if so, write the new value as an endtime and set some flag to consider this session closed and then you can count the time... (if some open sessions for this user open) Set new start time for this user and generate new frameset with frame mentioned above... In case, that the difference between current timestamp and last endtime is 2+ minutes, time endtime + 2 minutes will be written as endtime and flags properly set to finished session ... and then start the new one... and so on... i hope i've explained it right :) regards, m. Robb Kerr wrote: On Mon, 19 Jul 2004 15:54:14 +0200, Miroslav Hudak wrote: I would do it this way: - open the page and create hidden iframe (or frame with 0% width/height) which will be refreshing itself every ... let's say ... 2 minutes... then you'll get up to 2 minutes accurate numbers... the refreshed page would write timestamp to database every refresh... when the user crashes or leaves the page without logging off, you know, that his next refresh (and last one) would be LASTREFRESH + 2mins ... that gives you quite accurate numbers when implemented correctly. On the other hand, it will be a bit load producing, while that subsequent writes to database... Hope it helped a bit, regards, m. Robb Kerr wrote: I know that this is somewhat off topic, but I just need a starting place to do the research and thought someone here might be able to help. I am developing an application in which I need to time how long a visitor remains within a module and how long they view each page. I can create the appropriate fields in MySQL and can use PHP to do the appropriate calcualtions. What I don't know is how I communicate this information to the server. I can use POST or GET statements to pass info with page turns but what do I do if the visitor leaves the site without logging out or experiences a machine crash? Also, if anyone knows of a good javascript newsgroup, please pass along the info. Thanx, Robb Thanx for the suggestion. Now to ask for more help... I know how to create the layer which you mentioned. But, how do I make it auto update every few minutes and send data to the database? Thanx again, Robb -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTML and PHP output to PHP variable
hello! use output buffering... ?php ob_start(); //... your code here $_contents = ob_get_contents(); ob_end_clean(); ? regards, m. Maris wrote: Hi! Let's say my index.php consists of the following: ? include(header.inc); echo pPHP says Hello World/p; ? pHTML says Hello World/p ? //.. some other php code that generates output... ? ..some other HMTL output.. My question is: how can I make the whole index.php generated output put in one PHP variable? It is also important that it is done from the same index.php file. Thanks, Maris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: [Q] Why does my php file gets displayed instead of executed
this all seems just fine to me, aren't you sending some Header: Content-type -s? could you post that init.php script source? and is that apache server working well for other scripts that are called from the forms? AND ... just to be sure,... are you calling that html which contains the form thru server? (like http://localhost/myform.html) ... ? because, when calling it directly from dreamweaver, it could be called like direct html file (eg. file://c:/myhtmls/myform.html) and then the script will be called as file://c:/myhtmls/my_authentication_script.php instead of http://localhost/my_authentication_script.php that's all what comes to my mind, regards, m. Michael T. Peterson wrote: Here is some additional info: My other PHP scripts execute just fine, including the php script init.php which uses header(...) to dispatch to the member_login.htm page. Recall that the problem arises when validate_member_login.php is invoked from member_login.htm. When validate_member_login.php is invoked directly, it executes properly. I'm running the most recent production release of the Apache server on winxp. My ISP is running the same version. I've configured PHP identically with my ISP's Apache config. I use Dreamweaver MX for development and testing. I've not tested for this problem on my ISP's system, yet Once again, note that the php script, validate_member_login.php is executed properly in one case, yet is displayed in the browser in the other. Here is the code for validate_member_login.php: ?php include_once('../init.php'); /** * Variables set by member_login.htm are: * username -- contains the username of the member. * password -- contains the member's password. */ $username = trim($HTTP_POST_VARS['username']); $password = trim($HTTP_POST_VARS['password']); $result = authenticate_member_login( $username, $password ); if( $result == 0 ) { $HTTP_SESSION_VARS['session_id'] = crypt_password( $password ); $HTTP_SESSION_VARS['username'] = $username; header( 'Location: '.MEMBER_HOME_PAGE ); } else { header( 'Location: '.MEMBER_LOGIN_PAGE ); } ? 'init.php' executes session_start(), sets a bunch of constants (e.g., MEMBER_HOME_PAGE, etc.), sets an error handler, and includes a bunch of libraries. All standard stuff. Again, any help would be appreciated. Cheers, Michael Michael T. Peterson [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] When a user first comes to my site, the user's session id is checked and validated. If no session id is present or the validation fails, the user is vectored to a second page containing a login form. When the user enters the username and password and then clicks the submit button the info is forwarded to a third page, a php script, validate_member_login.php, that checks the username and password against a database. Just for completeness, note that the php script, validate_member_login.php, is invoked via login form's action parameter, i.e., form action=validate_member_login.php ... / The problem is that the php script, validate_member_login.php, is displayed in the browser rather than being executed. This is my first attempt at designing a dynamic web site so I'm sure I've missed something really basic, but I have hardly any hair left to pull out. Thanks, in advance, Michael -- 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] parse error: [PHP] usort e é together
Dunno the original question, but this obviously should be escaped... So the correct code follows... usort($authors, create_function('$a,$b',' $a = str_replace(array(\'é\', \'a\'), array(\'e\', \'a\'), $a); $b = str_replace(array(\'é\', \'a\'), array(\'e\', \'a\'), $b); return strcasecmp($a,$b);')); Regards, m. John Taylor-Johnston wrote: Sorry. Still getting a parse error on line 40: 39 usort($authors, create_function('$a,$b',' 40 $a = str_replace(array('é', 'à'), array('e', 'a'), $a); 41 $b = str_replace(array('é', 'à'), array('e', 'a'), $b); 42 return strcasecmp($a,$b);')); Can you have two arrays there? http://ca2.php.net/manual/en/function.str-replace.php All the brackets are in the right place. Hmmm ...? Thanks, John -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] usort e é together
this is slightly changed function of yours, written for better readability... ?php $authors = array('élen', 'Élen', 'Elison', 'ámadeus', 'albert', 'alfred', 'amadeus', 'elen'); function usort_callback($a, $b) { $a = strtolower($a); $b = strtolower($b); $a = str_replace(array('á', 'é'), array('a', 'e'), strtolower($a)); $b = str_replace(array('á', 'é'), array('a', 'e'), strtolower($b)); return (strcmp($a, $b)); } usort($authors, 'usort_callback'); var_dump($authors); ? it does diacritics safe and case-insensitive sort of authors... at least on my workstation... is it what you need? while i don't have your original problem, i just can guess... hope it helps. m. John Taylor-Johnston wrote: http://compcanlit.usherbrooke.ca/new1/db/index.php?ausenquiry=e http://compcanlit.usherbrooke.ca/new1/db/index.php?ausenquiry=é It still sorts é and e separately, but without a parse error: $first = array('à', 'é'); $second = array('a', 'e'); usort($authors, create_function('$a,$b',' $a = str_replace($first, $second, $a); $b = str_replace($first, $second, $b); return strcasecmp($a,$b);')); Back to the drawing board? I tried this too: $first = array('à', 'é', 'À', 'É'); $second = array('a', 'e', 'A', 'É'); Ideas? Thanks, John Parse error on line 40: 39 usort($authors, create_function('$a,$b',' 40 $a = str_replace(array('é', 'à'), array('e', 'a'), $a); 41 $b = str_replace(array('é', 'à'), array('e', 'a'), $b); 42 return strcasecmp($a,$b);')); ?php if(!$ausenquiry) $ausenquiry =a; echo trtd Note: A star, \*\, indicates that the author uses a pseudonym.brNoter : Une étoile, \*\, indique que cet auteur est connu par un nom de plume. table border=\0\ cellspacing=\0\ cellpadding=\5\\n; ## $myconnection = mysql_connect($server,$user,$pass); mysql_select_db($db,$myconnection); $news = mysql_query(select id,AUS from $table); ## $authors = array(); $author_list = array(); while ($mydata = mysql_fetch_object($news)) { $mydata-AUS = str_replace( ;, ;, $mydata-AUS); $mydata-AUS = str_replace(; , ;, $mydata-AUS); $tempauthors = explode(;, $mydata-AUS); foreach ($tempauthors as $singleauthor) { if ($singleauthor ) { array_push($authors, $singleauthor); $author_list[$singleauthor][] = $mydata-id; // use an associative array... } } } #sort($authors); #usort($authors, create_function('$a,$b','return strcasecmp($a,$b);')); #usort($authors, create_function('$a,$b',' # $a = str_replace(array('é', 'à'), array('e', 'a'), $a); # $b = str_replace(array('é', 'à'), array('e', 'a'), $b); # return strcasecmp($a,$b);')); $first = array('à', 'é', 'À', 'É'); $second = array('a', 'e', 'A', 'É'); usort($authors, create_function('$a,$b',' $a = str_replace($first, $second, $a); $b = str_replace($first, $second, $b); return strcasecmp($a,$b);')); foreach (array_count_values ($authors) as $author=$count) { if((strtolower(substr($author, 0, 1)) == $ausenquiry)) { echo tr bgcolor=\#D3DCE3\; echo th align=\left\ colspan=\2\a href=\.$SCRIPT_NAME.?searchenquiry=.urlencode($author).\.$author./a small[lt;--Search Entire Database]/small/th; echo th align=\right\ width=\5%\ nowrap(.$count. ; if($count 1) {echo records found/trouvés);} else{echo record found/trouvé);} echo/th/tr\n; echo tr bgcolor=\#F5F5F5\tdnbsp;/td; echo td align=\left\; $temp = ; foreach ($author_list[$author] as $ausid) { $temp .= a target=\printwindow\ href=\print.php?id=.urlencode($ausid).\.$ausid./a, ; } $temp = substr($temp, 0, -2); echo $temp/td; echo tdnbsp;/td; echo /tr\n; } } mysql_close($myconnection); ## echo /table /td /tr\n; ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] usort e é together
Pardon me for the strtolower line, i've just forgot there... it's 4:30AM here in Slovakia... :/ correct listing follows... ?php $authors = array('élen', 'Élen', 'Elison', 'ámadeus', 'albert', 'alfred', 'amadeus', 'elen'); function usort_callback($a, $b) { $a = str_replace(array('á', 'é'), array('a', 'e'), strtolower($a)); $b = str_replace(array('á', 'é'), array('a', 'e'), strtolower($b)); return (strcmp($a, $b)); } usort($authors, 'usort_callback'); var_dump($authors); ? regards, m. John Taylor-Johnston wrote: http://compcanlit.usherbrooke.ca/new1/db/index.php?ausenquiry=e http://compcanlit.usherbrooke.ca/new1/db/index.php?ausenquiry=é It still sorts é and e separately, but without a parse error: $first = array('à', 'é'); $second = array('a', 'e'); usort($authors, create_function('$a,$b',' $a = str_replace($first, $second, $a); $b = str_replace($first, $second, $b); return strcasecmp($a,$b);')); Back to the drawing board? I tried this too: $first = array('à', 'é', 'À', 'É'); $second = array('a', 'e', 'A', 'É'); Ideas? Thanks, John Parse error on line 40: 39 usort($authors, create_function('$a,$b',' 40 $a = str_replace(array('é', 'à'), array('e', 'a'), $a); 41 $b = str_replace(array('é', 'à'), array('e', 'a'), $b); 42 return strcasecmp($a,$b);')); ?php if(!$ausenquiry) $ausenquiry =a; echo trtd Note: A star, \*\, indicates that the author uses a pseudonym.brNoter : Une étoile, \*\, indique que cet auteur est connu par un nom de plume. table border=\0\ cellspacing=\0\ cellpadding=\5\\n; ## $myconnection = mysql_connect($server,$user,$pass); mysql_select_db($db,$myconnection); $news = mysql_query(select id,AUS from $table); ## $authors = array(); $author_list = array(); while ($mydata = mysql_fetch_object($news)) { $mydata-AUS = str_replace( ;, ;, $mydata-AUS); $mydata-AUS = str_replace(; , ;, $mydata-AUS); $tempauthors = explode(;, $mydata-AUS); foreach ($tempauthors as $singleauthor) { if ($singleauthor ) { array_push($authors, $singleauthor); $author_list[$singleauthor][] = $mydata-id; // use an associative array... } } } #sort($authors); #usort($authors, create_function('$a,$b','return strcasecmp($a,$b);')); #usort($authors, create_function('$a,$b',' # $a = str_replace(array('é', 'à'), array('e', 'a'), $a); # $b = str_replace(array('é', 'à'), array('e', 'a'), $b); # return strcasecmp($a,$b);')); $first = array('à', 'é', 'À', 'É'); $second = array('a', 'e', 'A', 'É'); usort($authors, create_function('$a,$b',' $a = str_replace($first, $second, $a); $b = str_replace($first, $second, $b); return strcasecmp($a,$b);')); foreach (array_count_values ($authors) as $author=$count) { if((strtolower(substr($author, 0, 1)) == $ausenquiry)) { echo tr bgcolor=\#D3DCE3\; echo th align=\left\ colspan=\2\a href=\.$SCRIPT_NAME.?searchenquiry=.urlencode($author).\.$author./a small[lt;--Search Entire Database]/small/th; echo th align=\right\ width=\5%\ nowrap(.$count. ; if($count 1) {echo records found/trouvés);} else{echo record found/trouvé);} echo/th/tr\n; echo tr bgcolor=\#F5F5F5\tdnbsp;/td; echo td align=\left\; $temp = ; foreach ($author_list[$author] as $ausid) { $temp .= a target=\printwindow\ href=\print.php?id=.urlencode($ausid).\.$ausid./a, ; } $temp = substr($temp, 0, -2); echo $temp/td; echo tdnbsp;/td; echo /tr\n; } } mysql_close($myconnection); ## echo /table /td /tr\n; ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php