[PHP] Problem with the passthru function
Hello All, I have a small php file (test.php) whose code is shown below: ?php $retval=1; $command='/bin/ls'; passthru($command, $retval); print(Exit status: . $retval); ? This test.php works fine when I execute from command prompt as php test.php, but when I access it through web browser, it seems not to be working fine, I get an exit status of 127 (which means command not found). I checked for permissions of ls, gave full path, but still it is failing. Can anybody help me in indentifying what is the potential problem? Thank you, Venkatesh ps: Sorry if this is the wrong mailing list. I have subscribed to this list, so posting here. __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with the passthru function
Hi, Thanks for your response safe_mode is Off but still I'm getting this problem. Thank you, Venkatesh --- Rabin Vincent [EMAIL PROTECTED] wrote: On 6/14/06, Venkatesh Babu [EMAIL PROTECTED] wrote: I have a small php file (test.php) whose code is shown below: ?php $retval=1; $command='/bin/ls'; passthru($command, $retval); print(Exit status: . $retval); ? This test.php works fine when I execute from command prompt as php test.php, but when I access it through web browser, it seems not to be working fine, I get an exit status of 127 (which means command not found). I checked for permissions of ls, gave full path, but still it is failing. Can anybody help me in indentifying what is the potential problem? Check if safe_mode is on in your php.ini. Turn it off if it is enabled. Rabin __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mysql table row updation based on user input.
Hi, i have a form for the user input with checkboxes and table rows for the user. The user can select the checkboxes which correspond to table rows in database. Depending on the selection of checkboxes i want to update the fields. For example: checkboxessubstrate_typesubstrate_numpixelprocess_classprocess_logoperatorcdatectimelocationdurationtemperaturepressureultrasonicsolventpedotsolutionsolution_tempsubstrate_tempmaskcomment [input] S4350absorber annealingMM2017-09-0514:18:15LF02124000fdsg [input] M2340pedot annealingMM-00-0014:22:03LF01223000saddDate*: [input] (DD.MM.YY) Time*: [input] (HH:MM:SS) [input] if the user selects some checkboxes and submits, then i want to take the cdate,ctime in table and calculate the difference from the current date and time,and enter the difference in duration. The code for the above form is echo 'link rel=stylesheet type=text/css href=sql-query.css'; $link = mysql_connect('localhost', 'root', ''); if (!$link) { die('Could not connect: ' . mysql_error()); } $db_selected = mysql_select_db('fmfgui', $link); if (!$db_selected) { die ('Can\'t use fmfgui : ' . mysql_error()); } $res = mysql_query(select * from running_processes); if (!$res) { print p style=\color:red;\mysql error: .mysql_error()./p\n;} $ncols = mysql_num_fields($res); print TABLE style='border: 1pt solid blue; border-collapse: collapse; cell-spacing: 0px'; print TR; print TD style='border-bottom-style: double; border-left: 1pt solid black; font-weight:bold; text-align:center'checkboxes/TD; for ( $i = 0; $i $ncols; $i++ ) { $column_name = mysql_field_name($res,$i); print TD style='border-bottom-style: double; border-left: 1pt solid black; font-weight:bold; text-align:center'$column_name/TD; } print /TR; print TR; while ($row = mysql_fetch_array($res)) { $ncols = mysql_num_fields($res); print TD style='border: 1pt solid black cell-padding: 3px'input type='checkbox' name=\id[]\ value=\.$row[id].\ /TD; for ( $i = 0; $i $ncols; $i++ ) { print TD style='border: 1pt solid black cell-padding: 3px'$row[$i]/TD; } print /TR; } print /TABLE\n; $tdate=date(d.m.y); echo h4Date*:input type='text' name='edate' value='$tdate';echo (DD.MM.YY); echo br /; $ttime=$ttime = date(H:i:s); echo h4Time*:input type='text' name='etime' value='$ttime'; echo (HH:MM:SS); echo br /; echo br /; echo input type='submit' name='submit' value='submit'; echo /form; The problem is if the user selects more than one checkbox then how can i write the update command. thanks babu. - How much free photo storage do you get? Store your holiday snaps for FREE with Yahoo! Photos. Get Yahoo! Photos
Re: [PHP] whats wrong in this program.
Hi, I tried to use the final array values in a insert statement, but the values are not inserted. the code is foreach ($final as $subnum){ $res = $db-query(INSERT INTO substrate_protocoll(substrate_type,substrate_num,operator,location,solvent,ultrasonic,duration,cdate,ctime,comment) VALUES('$substrate_type1',$subnum,'$operator','$location','$solvent',$uv,$duration,'$cdate','$sctime','$comment')); if(!$res){ echo insert failed; } } the values of array ($subnum)are not inserted , can you tell me where the problem is. Jordan Miller [EMAIL PROTECTED] wrote: I think I finally understand what you are trying to do. I don't see any reason why you need to use the token functions, and I would recommend using array functions instead (also, it is exceedingly easy to sort the elements of an array... see the end). I believe this will do what you are trying to do: //Tokenizer for Babu $str = '10,12,14-18'; $commas = explode(',', $str); // $commas will be an array of three items in this case // Final Values will go into the $final array $final = array(); foreach ($commas as $value) { // If one of the $commas elements contains a dash, we need to get the range between them! if (strstr($value, '-')) { // Explode based on the dash. This code assumes there will only be a single dash $rangeValues = explode('-', $value); foreach (range($rangeValues[0], $rangeValues[1]) as $number) { $final[] = $number; } } else { // If $value does not contain a dash, add it directly to the $final array $final[] = $value; } } echo All your values in the range $str are .implode(' ', $final); // Prints All your values in the range 10,12,14-18 are 10 12 14 15 16 17 18 In your last email, you had some of the values given out of order: 1. 20,21-24 2. 21-24,20 3. 10,20,21-24,25,26,30 To make sure the $final values are always ascending, just do this at the end: sort($final); Done!! Jordan On Sep 13, 2005, at 7:16 PM, babu wrote: $str=10,12,14-18; $tok = strtok($str, ','); while ($tok !== false) { $toks[] = $tok; $tok = strtok(','); } foreach ($toks as $token){ if (strpos($token,'-')){ stringtokenize($token); }else{ $finaltokens[]= $token; } } function stringtokenize($nstr){ $ntok1= strtok($nstr,'-'); $ntok2=strtok('-'); for($i=$ntok1;$i=$ntok2;$i++){ $finaltokens[]= $i; } } foreach ($finaltokens as $ftoken){ echo $ftoken; echo ; } the ouput prints only 10,12 but not 14,15,16,17,18. where is the problem. - To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php - How much free photo storage do you get? Store your holiday snaps for FREE with Yahoo! Photos. Get Yahoo! Photos
[PHP] string tokenization
Hi, I have different types of main strings seperated by commas(,). I want to tokenize the main string using php's string token function. I have substrings in the main string which are seperated by -. examples: 1. 20,21-24 2. 21-24,20 3. 10,20,21-24,25,26,30 so on the whole the main string is seperated by comma and some of the substrings(tokes) are seperated by hypen. can some one give me an idea how to implement in php. Thanks babu. - To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre.
[PHP] whats wrong in this program.
$str=10,12,14-18; $tok = strtok($str, ','); while ($tok !== false) { $toks[] = $tok; $tok = strtok(','); } foreach ($toks as $token){ if (strpos($token,'-')){ stringtokenize($token); }else{ $finaltokens[]= $token; } } function stringtokenize($nstr){ $ntok1= strtok($nstr,'-'); $ntok2=strtok('-'); for($i=$ntok1;$i=$ntok2;$i++){ $finaltokens[]= $i; } } foreach ($finaltokens as $ftoken){ echo $ftoken; echo br /; } the ouput prints only 10,12 but not 14,15,16,17,18. where is the problem. - To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre.
[PHP] date and time conversion
Hi, how to convert DD.MM.YYand HH:MM:SS into mysql date( '-MM-DD' ) and time format. I think the time is same as HH:MM:SS. Are there any php built in functions , or need to convert them using regular expressions. thanks babu - How much free photo storage do you get? Store your holiday snaps for FREE with Yahoo! Photos. Get Yahoo! Photos
[PHP] regular expression for integer range
Hi all, I want to write regular expression for checking the string format entered by user. the allowed formats are examples: 10 10, 10,12-10 12-10 that is the valid strings are: 1. only integer 2. an integer, range of integers example 3 and no other characters must be allowed. thanks babu. - How much free photo storage do you get? Store your holiday snaps for FREE with Yahoo! Photos. Get Yahoo! Photos
[PHP] regular expression for time
HI, how can i write regular expression for time in 24-hour format i:e, HH:MM:SS. using preg_match. thanks babu - How much free photo storage do you get? Store your holiday snaps for FREE with Yahoo! Photos. Get Yahoo! Photos
[PHP] sorry for asking here,a small apache query
Hi all, I am sorry for asking in php forum.i am subscribed to php and not to apache.but i hope many people in this group also the solution to this query. how can i configure apache so that users are forbidden to see my docroot file structure. for example i have a file at http://localhost/dir1/xyz.html , if the user try to access http://localhost, or http://localhost/dir1 he shud get a message forbidden. Thanks babu. - To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre.
[PHP] which is the correct method for select statement for oci8 functions
Hi all, which is the correct method to get a value from the database table into a php variable using the select statement for both oracle and mssql databases. for example if i have a query like SELECT email_address FROM users_activation WHERE username='$username';. how to get the email address into a simple string variable from above select statement using oci8 functions and mssql functions. Thanks babu - How much free photo storage do you get? Store your holiday snaps for FREE with Yahoo! Photos. Get Yahoo! Photos
[PHP] Cannot modify header information error........usage of header method.
Hi all, I am using header method to redirect to a certain page.my first question is 1.Is there any other alternative to this method. 2.I am getting the error by using this method. the error is Cannot modify header information - headers already sent by. i have seen the php documentation for header method. where there is one user comment about this. i have followed his steps like removing blank lines, using exit method. But the 3rd point that is HTML goes before any PHP code , i could not follow it , can some one please explain it. Thanks babu - Yahoo! Messenger NEW - crystal clear PC to PCcalling worldwide with voicemail
RE: [PHP] Cannot modify header information error........usage of header method.
Hi parker, can you please tell me how to use java script or html redirect, i mean a sample. thanks Chris W. Parker [EMAIL PROTECTED] wrote: babu on Wednesday, July 20, 2005 10:15 AM said: 1.Is there any other alternative to this method. Javascript or an html redirect. 2.I am getting the error by using this method. the error is Cannot modify header information - headers already sent by. i have seen the php documentation for header method. where there is one user comment about this. i have followed his steps like removing blank lines, using exit method. You have not removed everything. Output is still being sent to the browser. The error message tells you which file and line is causing the problem. I suggest you go back to it and look closely. But the 3rd point that is HTML goes before any PHP code , i could not follow it , can some one please explain it. I don't follow it either. Seinfeld anyone? Chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php - Yahoo! Messenger NEW - crystal clear PC to PCcalling worldwide with voicemail
Re: [PHP] Cannot modify header information error........usage of header method.
Thanks for the help mike and parker, I have used ob_start and ob_end_flush methods, and its working fine. i got good idea of redirecting now. Mikey [EMAIL PROTECTED] wrote: babu wrote: Hi parker, can you please tell me how to use java script or html redirect, i mean a sample. thanks Chris W. Parker wrote: babu on Wednesday, July 20, 2005 10:15 AM said: 1.Is there any other alternative to this method. Javascript or an html redirect. 2.I am getting the error by using this method. the error is Cannot modify header information - headers already sent by. i have seen the php documentation for header method. where there is one user comment about this. i have followed his steps like removing blank lines, using exit method. You have not removed everything. Output is still being sent to the browser. The error message tells you which file and line is causing the problem. I suggest you go back to it and look closely. But the 3rd point that is HTML goes before any PHP code , i could not follow it , can some one please explain it. I don't follow it either. Seinfeld anyone? Chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php - Yahoo! Messenger NEW - crystal clear PC to PCcalling worldwide with voicemail Javascript: document.location = new_url.html; HTML: HTH, Mikey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php - Yahoo! Messenger NEW - crystal clear PC to PCcalling worldwide with voicemail
[PHP] redirecting some values from one page to other in php
I am using header method for redirecting to another php file.I also want to pass some variables to the redirected file. for example: file1.html where i have a dropdown menu. the user selects the options... this form has a action to file2.php file2.php--- i get the values of the form by using $_POST. In this file i will do some processing on data and redirect to file3.php file3.php here i need the user select menu items. i think i can use require_once(file2.php) in file3.php and get the values.But i want to get the values selected by user from html form. Thanks for the help. babu - Yahoo! Messenger NEW - crystal clear PC to PCcalling worldwide with voicemail
Re: [PHP] redirecting some values from one page to other in php
It will become a big mess up for me if i combine all the files as they are large files. Matt Darby [EMAIL PROTECTED] wrote: babu wrote: I am using header method for redirecting to another php file.I also want to pass some variables to the redirected file. for example: file1.html where i have a dropdown menu. the user selects the options... this form has a action to file2.php file2.php--- i get the values of the form by using $_POST. In this file i will do some processing on data and redirect to file3.php file3.php here i need the user select menu items. i think i can use require_once(file2.php) in file3.php and get the values.But i want to get the values selected by user from html form. Thanks for the help. babu - Why not just combine all three files into one? So long as you place the form processing code over the actual HTML PHP code that generates your webpage, all will be fine.. To do this all you need to do is set your form action= Matt Darby Yahoo! Messenger NEW - crystal clear PC to PCcalling worldwide with voicemail - Yahoo! Messenger NEW - crystal clear PC to PCcalling worldwide with voicemail
Re: [PHP] redirecting some values from one page to other in php
does session.auto_start should be set to 1 for sessions to work. Mikey [EMAIL PROTECTED] wrote:babu wrote: I am using header method for redirecting to another php file.I also want to pass some variables to the redirected file. for example: file1.html where i have a dropdown menu. the user selects the options... this form has a action to file2.php file2.php--- i get the values of the form by using $_POST. In this file i will do some processing on data and redirect to file3.php file3.php here i need the user select menu items. i think i can use require_once(file2.php) in file3.php and get the values.But i want to get the values selected by user from html form. Thanks for the help. babu - Yahoo! Messenger NEW - crystal clear PC to PCcalling worldwide with voicemail You could put them in session vars - http://uk.php.net/manual/en/ref.session.php Mikey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php - How much free photo storage do you get? Store your holiday snaps for FREE with Yahoo! Photos. Get Yahoo! Photos
Re: [PHP] sytax errors
Hi, Its giving the line number. But actually i want to know the correct syntax for concatenation. I think all there is some mistake in all the three concatination statements. so could some one check and give some idea. thanks John Nichel [EMAIL PROTECTED] wrote: babu wrote: Hi, could someone please check where the sytax error is in these statements. $sqlstmt= EXEC sp_addlogin .$adduser. , .$addpass; $sqlstmt1= EXEC sp_adduser @loginame= .$adduser. , @name_in_db= .$adduser; $sqlstmt2= GRANT CREATE TABLE TO .$adduser; $sql=mssql_query($sqlstmt); $sql1=mssql_query($sqlstmt1); $sql2=mssql_query($sqlstmt2); Didn't php give you a line number? -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php - Yahoo! Messenger NEW - crystal clear PC to PCcalling worldwide with voicemail
[PHP] sytax errors
Hi, could someone please check where the sytax error is in these statements. $sqlstmt= EXEC sp_addlogin .$adduser. , .$addpass; $sqlstmt1= EXEC sp_adduser @loginame= .$adduser. , @name_in_db= .$adduser; $sqlstmt2= GRANT CREATE TABLE TO .$adduser; $sql=mssql_query($sqlstmt); $sql1=mssql_query($sqlstmt1); $sql2=mssql_query($sqlstmt2); thanks babu - Yahoo! Messenger NEW - crystal clear PC to PCcalling worldwide with voicemail
[PHP] How to run .sql files using php
Hi , i have a set of queries which i have placed them in one .sql file.i want to run this file using php's mssql and oracle(oci) functions. any idea pls. thanks. babu - How much free photo storage do you get? Store your holiday snaps for FREE with Yahoo! Photos. Get Yahoo! Photos
RE: [PHP] how to delete lines in a txt file using php.
Thanks george, But i want to read for multiple such files and i have many other keywords match which should be deleted.The array of keywords are ([,TYP,P_MPP,I_MPP,V_MPP,T=,FIT,INTENSITAET); and i aslo want to write back the reamaining lines after deleting into the same file but not in a different file. George Pitcher [EMAIL PROTECTED] wrote: Hi, Do you just want to delete the lines containing '[' or 'TYP', or '[' AND 'TYP'? So your block would read: SUBSTRATNAME=S112 PIXEL=5 OPERATOR=Zi KOMMENTAR=dunkel INTENSITAET=1000.00 DATUM=03.01.2005 UHRZEIT=11:22 MESSUNG=SWEEP_UI correct??? I would do the following: $filename=myfile.txt; $target=myfile2.txt; $handle = fopen ($filename, r); while (!feof ($handle)) { $buffer = fgets($handle, 8192); if (substr($buffer,0,1)!=='[' substr($buffer,0,3)!=='TYP'){ $hf = fopen($target, 'a'); fwrite($hf, $buffer); fclose($hf); } } fclose ($handle); That should do the trick. George -Original Message- From: babu [mailto:[EMAIL PROTECTED] Sent: 12 July 2005 12:13 am To: php-general@lists.php.net Subject: [PHP] how to delete lines in a txt file using php. Hi i have a txt file like [SUBSTRAT] TYP=25x25_10 SUBSTRATNAME=S112 PIXEL=5 OPERATOR=Zi KOMMENTAR=dunkel INTENSITAET=1000.00 [MESSUNG] DATUM=03.01.2005 UHRZEIT=11:22 MESSUNG=SWEEP_UI i want to delete lines which start with '[' and 'TYP'. i have multiple such files.i have used strstr method. i have written code for it, but it results in deletion of complete data from files. Can anyone check where the logic goes wrong. here is my file. $del_lines=array([,TYP,P_MPP,I_MPP,V_MPP,T=,FIT,INT ENSITAET); $dir=getcwd(); $handle = opendir($dir); while (false !== ($file = readdir($handle))) { if ((preg_match('/^2005\d{4}_\d{4}\.txt$/', $file))||(preg_match('/^2005\d{4}_\d{4}\_01_01\.txt$/',$file))){ $fc=file($file); $f=fopen($file,w); foreach($fc as $line){ $bool=TRUE; for($i=0;$i if(!strstr($line,$del_lines[$i])){ $bool=FALSE;} break; //fputs($f,$line); } //if($bool){fputs($f,$line);} } if($bool){fputs($f,$line);} fclose($f); } } closedir($handle); ? - Yahoo! Messenger NEW - crystal clear PC to PCcalling worldwide with voicemail - How much free photo storage do you get? Store your holiday snaps for FREE with Yahoo! Photos. Get Yahoo! Photos
[PHP] Re: how to delete lines in a txt file using php.
hi sokolewicz, i get this error, wehn i try to run the file Parse error: syntax error, unexpected ')', expecting T_PAAMAYIM_NEKUDOTAYIM in C:\apachefriends\xampp\htdocs\fmf\IV-test-files\200501t\dirread2.php on line 21 M. Sokolewicz [EMAIL PROTECTED] wrote: babu wrote: Hi i have a txt file like [SUBSTRAT] TYP=25x25_10 SUBSTRATNAME=S112 PIXEL=5 OPERATOR=Zi KOMMENTAR=dunkel INTENSITAET=1000.00 [MESSUNG] DATUM=03.01.2005 UHRZEIT=11:22 MESSUNG=SWEEP_UI i want to delete lines which start with '[' and 'TYP'. i have multiple such files.i have used strstr method. i have written code for it, but it results in deletion of complete data from files. Can anyone check where the logic goes wrong. here is my file. $del_lines=array([,TYP,P_MPP,I_MPP,V_MPP,T=,FIT,INTENSITAET); $dir=getcwd(); $handle = opendir($dir); while (false !== ($file = readdir($handle))) { if ((preg_match('/^2005\d{4}_\d{4}\.txt$/', $file))||(preg_match('/^2005\d{4}_\d{4}\_01_01\.txt$/',$file))){ $fc=file($file); $f=fopen($file,w); foreach($fc as $line){ $bool=TRUE; for($i=0;$i if(!strstr($line,$del_lines[$i])){ $bool=FALSE;} break; //fputs($f,$line); } //if($bool){fputs($f,$line);} } if($bool){fputs($f,$line);} fclose($f); } } closedir($handle); ? - Yahoo! Messenger NEW - crystal clear PC to PCcalling worldwide with voicemail wouldn't something like this work (faster): $deleteLines = array([,TYP,P_MPP,I_MPP,V_MPP,T=,FIT,INTENSITAET); if($handle = opendir('.')) { while(($file = readdir($handle)) !== false) { // init vars $contents = ''; if (!(preg_match('/^2005\d{4}_\d{4}\.txt$/', $file) || preg_match('/^2005\d{4}_\d{4}\_01_01\.txt$/',$file))){ // the filename has been rejected; move on to the next one continue; } // right, we need to open the file now so we can delete the lines $contents = file($file); $stream = fopen($file, 'w'); // loop trough the file, examining each line foreach($contents as $line=data) { foreach($deleteLines as $delete) { if(0 !== strpos($data, $delete)) { // string does not start with one of the ToBeDeleted parts // this (combines strpos() !== false || strpos() 0) // // so, let's write it back to the file fwrite($stream, $data, strlen($data)); } } } fclose($stream); } } closedir($handle); ? I'm assuming here you want to only delete lines STARTING with the part given in the array. - tul - Yahoo! Messenger NEW - crystal clear PC to PCcalling worldwide with voicemail
[PHP] parsing a text file into columns and rows
Hi all, i have a text file as shown below, which contains records like varaiable, value pairs seperated by '=' .there are many such records, each record is starts with first variable 'SUBSTRATNAME'. SUBSTRATNAME=S112 -- PIXEL=5 OPERATOR=Zi KOMMENTAR=dunkel DATUM=03.01.2005 UHRZEIT=11:22 MESSUNG=SWEEP_UI I_SC=-57.3496E-12 V_OC=1.0103E+0 FF=-1.3303E+0 WIRKUNGSGRAD=14.4220E-9 SUBSTRATNAME=E07 -- PIXEL=1 OPERATOR=MN KOMMENTAR=Au/PEDOTCPP105D/Au DATUM=03.01.2005 UHRZEIT=11:52 MESSUNG=SWEEP_UI I_SC=-50.4506E-12 V_OC=1.0103E+0 FF=-1.5353E+0 WIRKUNGSGRAD=14.6421E-9 SUBSTRATNAME=E07 -- PIXEL=1 OPERATOR=Zi KOMMENTAR=Au/PEDOTCPP105D/Au DATUM=03.01.2005 UHRZEIT=11:54 MESSUNG=SWEEP_UI I_SC=NaN V_OC=0.E+0 FF=NaN WIRKUNGSGRAD=NaN i want to parse this file as shown below each column shud be seperated by tab space or comma. SUBSTRATNAME PIXEL OPERATOR KOMMENTAR...WIRKUNGSGRAD s112 5 zidunkel 14.4220E-9 likes this i want all the values. thanks for help - Yahoo! Messenger NEW - crystal clear PC to PCcalling worldwide with voicemail
[PHP] searching for files in a directory.
Hi, I have a directory which has thousands of files based on date. for example mmdd-number(auto increment).txt 20050101-0001.txt,20050101-0002.txt20050101-0210.txt 20050102-0001.txt,20050102-0002.txt..20050102-0141.txt and many other files, but i want to extract data from the files with the above format. I have seen in the php documentation for reading a directory,but not files with a specific structure. can some one give an idea. thanks babu. - Yahoo! Messenger NEW - crystal clear PC to PCcalling worldwide with voicemail
[PHP] searching for files in a directory with a specific structure.
Hi, I have a directory which has thousands of files based on date. for example mmdd-number(auto increment).txt 20050101-0001.txt,20050101-0002.txt20050101-0210.txt 20050102-0001.txt,20050102-0002.txt..20050102-0141.txt and many other files, but i want to extract data from the files with the above format. I have seen in the php documentation for reading a directory,but not files with a specific structure.i could not able to write the correct regular expression for the filename match. can some one give an idea. thanks babu. - Yahoo! Messenger NEW - crystal clear PC to PCcalling worldwide with voicemail
Re: [PHP] searching for files in a directory with a specific structure.
thanks the format works, i have written some code for deleting some lines from the above obtained files,i have used like keyword match for deleting lines from the above files.the keywords are in the array. can u pls look at the code and check where goes wrong. ? $del_lines=array([,TYP,P_MPP,I_MPP,V_MPP,T=,FIT,INTENSITAET); $dir=getcwd(); $handle = opendir($dir); while (false !== ($file = readdir($handle))) { if ((preg_match('/^2005\d{4}_\d{4}\.txt$/', $file))||(preg_match('/^2005\d{4}_\d{4}\_01_01\.txt$/',$file))){ $fc=file($file); // for reading $f=fopen($file,w); // for writing. foreach($fc as $line){ for($i=0;$isizeof($del_lines);$i++){ if(!strstr($line,$del_lines[$i])) fputs($f,$line); } } fclose($f); } } closedir($handle); ? Stut [EMAIL PROTECTED] wrote: babu wrote: I have a directory which has thousands of files based on date. for example mmdd-number(auto increment).txt 20050101-0001.txt,20050101-0002.txt20050101-0210.txt 20050102-0001.txt,20050102-0002.txt..20050102-0141.txt and many other files, but i want to extract data from the files with the above format. I have seen in the php documentation for reading a directory,but not files with a specific structure.i could not able to write the correct regular expression for the filename match. can some one give an idea. Check out http://php.net/glob. This might not be the best way to do it if you have *lots* of files since it returns all matches in an array. A regex to match might look something like \d\d\d\d\d\d\-\d\d\d\d\.txt but I'm no regex expert. -Stut - How much free photo storage do you get? Store your holiday snaps for FREE with Yahoo! Photos. Get Yahoo! Photos
[PHP] how to delete lines in a txt file using php.
Hi i have a txt file like [SUBSTRAT] TYP=25x25_10 SUBSTRATNAME=S112 PIXEL=5 OPERATOR=Zi KOMMENTAR=dunkel INTENSITAET=1000.00 [MESSUNG] DATUM=03.01.2005 UHRZEIT=11:22 MESSUNG=SWEEP_UI i want to delete lines which start with '[' and 'TYP'. i have multiple such files.i have used strstr method. i have written code for it, but it results in deletion of complete data from files. Can anyone check where the logic goes wrong. here is my file. ? $del_lines=array([,TYP,P_MPP,I_MPP,V_MPP,T=,FIT,INTENSITAET); $dir=getcwd(); $handle = opendir($dir); while (false !== ($file = readdir($handle))) { if ((preg_match('/^2005\d{4}_\d{4}\.txt$/', $file))||(preg_match('/^2005\d{4}_\d{4}\_01_01\.txt$/',$file))){ $fc=file($file); $f=fopen($file,w); foreach($fc as $line){ $bool=TRUE; for($i=0;$isizeof($del_lines);$i++){ if(!strstr($line,$del_lines[$i])){ $bool=FALSE;} break; //fputs($f,$line); } //if($bool){fputs($f,$line);} } if($bool){fputs($f,$line);} fclose($f); } } closedir($handle); ? - Yahoo! Messenger NEW - crystal clear PC to PCcalling worldwide with voicemail
[PHP] database querying form in php
HI, I ilke to create user interface for a group of people for entering the queries and to see the results in a browser. The users have the knowledge of database. for example: the users will have a login check, and if successful they will see a window where they can enter the sql queries and can see the results.I also want to implement a history of queries where the user can use it when ever needed. i have done the user authentication part. But i do not get an idea how the User interface can be? I have seen PhpMyadmin.its nice , but lillte bit complex for me as i also need some code to know how it implemented. can some one please point to some examples or so. Thanks babu Send instant messages to your online friends http://uk.messenger.yahoo.com
[PHP] change the font color of a string variable in PHP
Hi all i am newbie, I have a php code like this ?php foreach($_SESSION['history'] as $item) { $item = str_replace(;,,$item); echo option $item/option; //echo option$item/option; }//foreach ? I want to set the color of the srting in $item. Are there any PHP functions available. Thanks babu. Send instant messages to your online friends http://uk.messenger.yahoo.com
Re: [PHP] change the font color of a string variable in PHP
Chris Ramsay [EMAIL PROTECTED] wrote:On Fri, 18 Mar 2005 09:42:13 + (GMT), babu wrote: Hi all i am newbie, I have a php code like this foreach($_SESSION['history'] as $item) { $item = str_replace(;,,$item); echo $item; //echo $item; If I understand your question, you are wanting to change the text colour of an option item... Do this with css classes... Cheers }//foreach ? I want to set the color of the srting in $item. Are there any PHP functions available. Thanks babu. Send instant messages to your online friends http://uk.messenger.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Send instant messages to your online friends http://uk.messenger.yahoo.com
Re: [PHP] change the font color of a string variable in PHP
Hi chris, i am using mssql and php, so i trying to get the query result when the user enters the query and submits the execute button. i want to differentiate the syntactically correct query and the incorrect query with differ colors. here i am posting my code if (-1 == $connection) $result = mssql_query($query);// or die(Fehler beim Schreiben in die Datenbank); else $result = mssql_query($query, $connection);// or die(Fehler beim Schreiben in die Datenbank); if (!$result) { print p style=\color:red;\MS-SQL-Fehler: .mssql_get_last_message()./p\n; $error=1; //my changes} what i am trying to do is intialising a global variable $error=0 and changing it to 1 if error occurs. when displaying i am writing like this foreach($_SESSION['history'] as $item) { $item = str_replace(;,,$item); if(error==0) echo option $item/option; else echo option style=\color: red;\$item/option; but it doe not work can you pls tell me. Chris Ramsay [EMAIL PROTECTED] wrote:Babu, Check out: http://www.trans4mind.com/personal_development/StyleSheets/formElements.htm or google http://www.google.com/search?hl=enq=option+text+colourmeta= HTH Chris Send instant messages to your online friends http://uk.messenger.yahoo.com
[PHP] PHP any Mysql connection- new b
Hi all, I am using php 3.0 and mysql and win xp. i want to add users to database through php page. adduser.php html FORM METHOD=post ACTION=add.php Real Name: INPUT TYPE=text MAXLENGTH=70 NAME=real_name SIZE=20Br Username: INPUT TYPE=text MAXLENGTH=70 NAME=username SIZE=20Br Password: Input Type=text Maxlength=70 Name=userpass Size=10Br INPUT TYPE=submit VALUE=Add INPUT type=reset VALUE=Reset Form/form /tr/td/table/tr/td/table /body /html when i enter the fileds and submit ,the action is not performed, instead add.php file is opened. add.php ? $ID = uniqid(userID); $db = mysql_connect(localhost,root,halfdinner); mysql_select_db (userpass); $result = mysql_query (INSERT INTO users (id, real_name, username, password ) VALUES ('$ID', '$real_name', '$username', '$userpass') ); if(!$result) { echo bUser not added:/b , mysql_error(); exit; } if($result) { mysql_close($db); print User b$username/b added sucessfully!; } else { print (Wrong Password); } ? is the problem due to mysql and php connection.i am using windows xp with apache2. i followed the steps said by someone in the previous thread.that is adding libmysql.dll to system32 and so on. I cannot find php_mysql.dll in php.ini. can some one help Thanks babu - ALL-NEW Yahoo! Messenger - all new features - even more fun!