Match Input Value With Values In A Delimited File
I'm very very new to php. I need your help. I have a text file which is ~ delimited. Each line has a name and link. I want to check if the link is similar to my input and if it is then return the name.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Comma Delimited File
I am trying to read comma delimited rows of text. The problem is that some fields may be encapsulated in "" - particularly the text fields but not numeric fields. Is there a simple efficient way to parse the fields with comma but also strip off the "" encapsulating some of the fields with php? The problem is the "" encapsulation is optional. Some fields will have it, some won't.
Delimiting A Non-delimited File
I have a text file, with addresses of business' that I would like to convert to a more useable format ie CSV. Currently there is no delimiting of the various address components. "A 1 AUTO SALES 1224 S BROADWAY ST WICHITA, KS 67211-3124 316-263-8748" "ABERLE FORD INC 1025 MAIN ST SABETHA, KS 66534-1893 913-284-3122" "ACTION AUTO RENTAL & SALES 1101 W 4TH AVE HUTCHINSON, KS 67501 316-662-3699" As you can see from the examples above the only consistent items are the state and the phone number, and the city is always followed by a comma. I am new to regex and the whole range of string handling functions and I am not sure where to start.
Tab Delimited Txt File To Php Html Table
Wouldn't you know that when I finally find a tutorial using Google that does exactly what I want, the code doesn't run when I use it ... However, when it gets to this line, for ($i=0; $i<td>$line[0]</td>, it chokes on one of the '>'. Since my php skills are very basic, and in no way include arrays, can someone assist me with this? If it's easier to do it differently, what I'd like to do is create a table in Excel/Access, export it to the server (to a tab-delimted text file, since I'll be using commas in my table cells), and have it display in an HTML table. If I can't figure this out, I'm tempted to just export to HTML from one or the other program (not sure quite yet which I would use), so ...
Reading Tab Delimited File Into Database
I have a .tab file that I need to write to the database. I've read it in, but for some reason it's not reading correctly. I'm truncating the complete database and then reloading it with whatever is in the tab file. I keep getting an error when trying to run my current code which is: Code:
Importing To DB From Pipe Delimited Text File
I am trying to make a PHP script that will import data from a pipe delimited text file in to a database. The problem I am having is that the fields have long descriptions in them and there are multiple line breaks for paragraphs. They contain HTML codes as well (<B>). The multiple line breaks are causing it to import the data strange, putting data in the wrong fields and totally missing some data as well. Here is what the text file Code:
Stripping Quotes Out Of A Comma Delimited File?
I have a flat file that I'm trying to stick into a MySQL database. One record per line, multiple fields per record, and many of them are null fields which are just double quotes without a space between. It's probably nothing really major for people who have done this before, but I'm a bit stumped. The file is comma delimited. Every field is surrounded by double quotes. I've done quite a bit of searching, on the php site and elsewhere, but I can't seem to get it to strip the quotes out so I can explode the file line by line to grab the fields.
Multiple Table Insert From Tab Delimited File
I have a page I'm coding for batch updates from a tab delimited file. Each row has data that has to be checked against and inserted/updated on different tables in my mySQL database. How would I go about parsing through the tab delimited file and then storing data between the tabs in order to insert individually into separate tables?? Here's what I have so far... $contents = file('/myfile.txt'); for ($i=0; $i<sizeof($contents); $i++) { $line = trim($contents[$i]); $arr = explode(" ", $line); $line[$i] = array('ID' => $arr[0], 'Record_Type' => $arr[1], 'First_Name' => $arr[2], 'MI' => $arr[3], 'Last_Name' => $arr[4], 'Firm' => $arr[5], 'Address' => $arr[6], 'type' => rtrim($arr[13])); I need to take the different columns.. ID, Record_Type, etc. and update different tables with each value where the IDs match.
Importing A Flat Pipe Delimited File Into A MySQL Data Table
I have done this in perl but eeew I don't want to use perl anymore. I want to be able to take a flat file that looks like this: mbriones@...|Marian|Briones bobsmith@...|Bob|Smith janedoe@...|Jane|Doe (etc) The table has more than 3 fields, so I'd want to process the flat file and then do an INSERT into mailinglist SET field=$value for each line. Does someone have a nice way for me to do this? The flat file will be uploaded to the server via a form (copy) and then be processed.
Storing Input Values As Variables?
I wondered if anyone could advise? I am trying to write a basic script, which allows user's to enter there username, password in text fields. Then we take these values and pass them to the method login_user($userid, $password); I was unsure how to take the text fields values, and store them in variables, when the submit button is clicked? Is this code correct? <?php function login_form(){ global $PHP_SELF, $userid, $password; ?> <html> <head> <title></title> </head> <body> <div align="center"> <form method="post" enctype="multipart/form-data" action="<?php echo $PHP_SELF ?>"> <table border="1"> <tr> <th align="right">E-mail</th> <td nowrap> <input name="userid" size="25"> </td> </tr> <tr> <th align="right">Password</th> <td nowrap> <input name="password" size="25"> </td> </tr> <tr> <td align="center"> <input type="submit" name="submit" value="Login"> </td> </tr> </table> </form> <div> </body> </html> <?php } login_form(); $user_info = login_user($userid, $password); ?>
Preparing Mutiple Values For Hidden Input To Form
I have a requirement to enter values in a form in the following format. <input type="hidden" name="item_name_1" value="Item_name_1"> <input type="hidden" name="amount_1" value="1.00"> <input type="hidden" name="item_name_2" value="Item_name_2"> <input type="hidden" name="amount_2" value="2.00"> In my application the item name = $title and amount=$price I have code which extracts the title and price but I cant figure out how increment the item_name_x and amount_x by 1, starting from 1, for each item purchased. Code:
Displaying File Path In File Input Field
i have file input field in a form like this: <input name="isbn" type="text" size="25" value="<?php echo $_POST['isbn'] ?>" /> <input name="image" type="file" size="25" value="<?php echo $_FILES['image']['name'] ?>" /> when i press "submit" button, the same page gets loaded... if my $_POST['isbn'] is empty, i want to have the file path on "file input field" to redisplay on that same field... it's possible in text input field but i don't know of a way to do it in file input fields...
Multiple File Upload From Client Pc To Server Without Using <input Type="file"> Cont
I am working on a application which requires me to upload the contents of all the files from a particular folder in clent pc to the server. In my code i just want to mention the folder name which may contain any number of files.Folder name will always be fixed. I dont want to use <input type=file > control. Is there any way i can achieve this using FTP or any other way in PHP.Any help will be greatly appreciated.
No Input File Specified Error
My server is Win2003 with php 5.2. Basic webroot is pointed to c:inetpubwwwroot. When I execute php scripts in this dir, it is working fine. I configured a virtual directory in IIS onto different drive, D:WebsitesNewDir, and copied some php scripts. When I run those php scripts, in virtual directory, it is showing "No Input file specified" error. How to get the scripts in vir dir running?
Input Type = File
If an input field of type 'file' is left blank, what is returned as the varible? I'm having a problem, I have two file fields and want to be able to do the following: 1. Put in the $file1_name and $file2_name (if there was a file uploaded) into a database so I can reference it later. 2. Copy the uploaded file (if, in fact, there was a new one uploaded) to a directory. 3. Later on, if someone wants to edit that entry and wants to upload a new file for the 2nd slot, or 1st for that matter or delete a file, it should do that with no difficulty. I'm running into problems when it reaches the 'if' clause. I've tried: if ($var){ and if($var != ''){ and no matter what, for some reason these blank file fields alwasy evaluate true to my if statements, so I get an error like 'can't open file 'none' for blah blah'.
No Input File Specified Error.
I have PHP 5 installed with IIS 6. Currently there is only one website that's using PHP at the moment, so I went ahead and enabled PHP for another website, but whenever I try to access this new website that's using PHP, I get a message saying "No input file specified." I don't know what could be causing this error, I tried doing a Google search and I found that there are a lot of people getting this same error message but I could not find any solution for it. Does anyone know how to solve this error?
A Varabile Input In To A File Add Too Many Spaces
I am getting users to enter in some information in to a form and when the user submits the information, I have just noticed that I am having a problem with one of variables that get entered in the file. Here is a example of some information getting entered in to the file:- capbiker|testing||What will happen now? |21:55:22|14/12/2001||000.00.00.00 But as u can see after the What will happen now? text there is a lot of spaces get entered in. And I am not too sure why it is doing it. And the what will happen now? text gets entered in to a text area form.
How To Parse A File From Checkbox Input?
I've to develop a html page where when i click one or two checkboxes and click submit, it has to take the values from the checkboxes and search a file for these values and take the whole line where the value is obtained, and store that line in another file.
Php4, Enterprise Server 3.5, No Input File Specified
I need to upgrade my php version to 4.3 on a Netscape Enterprise 3.5 server. I used the installation instructions that can be found on php.net but all I get is a 'no input file specified'. Does anyone has an idea how to solve this?
Updating Text File With Textarea Input
i am creating an admin page for a person to update a page of their website through a web browser. the problem that i am having is the formatting of the inputted data into the textarea box. when it is displayed, all the returns and breaks are removed and the data is all in one line. i have been experimenting with nl2br() but i am not sure where to put it.
Getting The File Path From A Html Form Input
I want to get the file path from a file input field, not just the filename. I don't have to necesarily use the input of type 'file', but that is the only way i know how to have a browse button.I tried using javascript to fetch the content of the file with this function: function GetDirectory(){ strFile = document.FileForm.filename.value; intPos = strFile.lastIndexOf(""); strDirectory = strFile.substring(0, intPos); alert(strDirectory);} but i don't know how to pass the javascript variable to the php.
Getting The Remote File Path From <input Type="file">
I'm using a form to upload a file to save in a mySQL database, however I need to store the original file path on the clients (the user uploading the file) computer. The file path is shown in the field that selects the file, I just need to post it or save it in a session somehow.
$_POST Behavior From Input=submit Vs Input-type=button
I have been trying to solve an annoying behavior with PHP (I think). Maybe some of you have encountered the same and have some ideas. I have an html form and I use an <input type="button"> element with the onClick event that calls a javascript funtion. Once the script's content has been processed, I execute the form.submit() directive. I would like to combine the html form and the PHP script into one, and use action="<?php echo($PHP_SELF) ?>". When the html form has <input type="button" name="theButton" value="thisisthetrigger" onclick="doThis(this.form)">but PHP cannot 'read' the value of $_POST["theButton"] after form.submit(). If I substitute the <input type="button"> for <input type="submit"> then PHP reads the value just fine. Some may argue to just use the latter option, but that will cost me a trip back to the server to basically do a lot of validation that can be very easily accomplished on the client side.
Exploding Tab Delimited Line
I'm trying to create an array from a tab delimited line of text. I've tried explode('/t',$line); but doesn't seem to work. What am I doing wrong?
Preg_match And Delimited Strings
I have a string I'd like to have broken into parts using preg_match. I used a regular expression from the Perl FAQ (http://perlfaq.cpan.org/): push(@new, $+) while $text =~ m{ "([^"]*(?:.[^"]*)*)",? # groups the phrase inside the quotes | ([^,]+),? | , }gx; The idea is that it splits delimited strings respecting the quotes, for example... foo, bar, "foo, bar", bar would end up as -foo -bar -"foo, bar" -bar So obviously an explode wont work. I cant figure out how to convert that piece of perl above into preg_match. I've copied the string and escaped all the appropriate charecters however it still wont divide the string show above properly... $str = "foo, bar, "foo, bar", bar"; $re = ""([^"\]*(?:\.[^"\]*)*)",?| ([^,]+),?| ,"; if (preg_match($re, $str, $res)) { print_r($res); } I have other strings that need parsing too (including ones with a double encapsulator inside the string - eg. 'don''t touch that!'). But I'm saving those for later.
Getting Values From A File
I have a file with content like: John|10|5|7 Alec|22|9|31 Mike|23|42|1 And I can retrieve all the values using explode and a loop. But for what I'm wanting to do is be able to get the values for one particular line rather than the entire. So how can I retrieve the values for one particular line?
Create A Delimited Text Array
How can I create a delimited text file to work with this script. I would like to put this first part in a text file and load it into an array so the php script can parse it. Code:
How To Display Values For File
what is the right way to do this. so i can display the value so i can update this echo"<input name="Picture1" type="file" value="{$row['Picture1']}" >";
Comma Delimited Csv Has Commas Inside Fields
I need to import a CSV file into a database daily. That operation in itself is simple enough but the trouble is that some fields are quoted because they have commas inside them. How do I handle this with my import script? It would be much better if the CSV was created with all fields quoted or used a different delimited but sadly that is not an option.
Regular Expression For Comma-delimited Pairs
I have a textarea form field for inputting (or pasting) pairs of data. I need a regular expression pattern to validate each line for the following double quote number double quote comma double quote alpha string double quote carriage return The following comes close, but doesn't check for a carriage return at the end of each line: ^"([0-9]?)+"([,]s?"([A-Za-z0-9]+)")*$ For example the following would return true: "1","John" "2","Paul" "3","George" "4","Ringo"
Easy Comma-delimited List To Dropdown Box Converter
I was working on a simple converter when I realized that by not setting the id param of the option tag, it wasn't going to send the value of the dropdown box to my php script. I had this to start with: Code:
Storing Numeric Values Efficiently In A Text File
I need an efficient method for storing numeric values in text files. I want to minimize storage space and also need to have a method that supports fast writing and reading of such values to/from the file, while also making them available for PHP to use numerically. E.g. if I have a number like "173522", I _could_ write it out in the file as a string: 1, 7, 3, 5, 2 and 2. This would take 6 bytes. If I would need to access the number again, I would have to read the 6 bytes as a string with PHP and then PHP would automatically be able to treat it as a numeric (with some slight loss of time/performance for the conversion I guess). However, a method that I assume might be more efficient - but which I currently don't know how to implement - would be to convert the format of the number into a... I don't know what to call it. But I think you know what I mean. It would then take only 3 bytes of space when stored in the text file: 1 byte for numerals 1-255, 2 bytes for numerals 256-65536, etc. I wonder if there is a way to implement this latter method with PHP and if it would give better performance than the previous method. Right now, I have no idea of how to do it and would be grateful for any suggestions.
PDF Mix & Match
I was wondering if anyone had any experience of splitting & appending PDF's? A client has a huge pdf, and he wants to give the user the ability to mix and match the chapters that they want to download. The final final will be 1 pdf, but may consist of various different chapters chosen from a list. The chapters will be ripped from 1 master pdf. Oh, and the PDF is not just text it contains all manner of images,links & the like! And that is what is required. I was wondering if anyone had any pointers regarding this? I'm thinking PDFLib, but I haven't fully looked into it yet.
PHP Pattern Match
I need to convert the following pattern which I found in a php program into a perl regex... but I have NO CLUE WHAT IT DOES! &[^;]; <[^>]*> Actually, for the second one, I have an idea as to what it does, but I'm not sure... they are both used in this context:
Run SQL With Value Match To $array
I wonder if it is possible to do "select" in mySQL database with value matching to an $array. For example, $array = array("shanghai", "beijing"); I want to select cities whose names match the values in $array. Instead of using foreach(), is it possible to do the select with the array itself. I know some languages support this function. For example: SELECT fieldname FROM cities WHERE city_name in '$array' Is it possible in PHP with MySQL?
How To Get The Match Score
I own a sms site and wants to update the users with the cricket match score. I think i need some sort of xml feeds.
Regex: How Do I Match A Dot?
I am trying to match the dot, so that it actually matches "a dot" and not "everything". How do I write that? Example: the word "st." I have tried '/st./i' '/st./i' Sorry if this question is noobish. I have not been able to find the answer searching the net.
While Query Only Does First Match
I'm generating letters based on the date a lead was entered into the database. I've tried moving the } into several places. If I move it before the 2nd query I get all the letters but no dealers. If I move it to the bottom (as it now) I get 1 letter with the dealers. I can't figure out what to do to make the query generate all the letters with their associated dealers. PHP Code:
Trying To Match Date..
I am trying to make an Order History Lookup page for an E-commerce site. Now.. when an order is submitted the dateinserted is formated as date("U") and stored in the Db table. Now.. when I create the lookup date formfields I have them as such: Month (02) Day (25) Year (02) How would I go about getting these values so that I can compare exactly against the date("U") string that is stored in the DB?
Preg Match Help
I have a site the produces results like this: <a href="/file/564547">Text here</a></td> I need to be able to extract the number and text. Have tried this: preg_match_all("/<a href="/file/([^0-9])">(.*)</a></td>/", $data, $m); and this: preg_match_all("/<a href="/file/([0-9])">(.*)</a></td>/", $data, $m); but $m is always empty!
Regex - How To Match Until Something
How do you replace an occurence until a certain point: You can see my example code below and the output: $string1 = 'Hello world today' $string2 = 'Hello blahblah' $string1 = preg_replace ( '/Hello.*(?!today)/', 'Hello ***' , $string1 ); $string2 = preg_replace ( '/Hello.*(?!today)/', 'Hello ***' , $string2 ); echo "$string1 - This should be Hello *** today "; echo "$string2 - This is correct "; Outputs: ====== Hello *** - This should be Hello *** today Hello *** - This is correct
Match Any Character But
Can I use any reg exp(mainly for mod rewrite) where I can match any character but a fixed list? I need to match a string that does not contain any /'s but I don't want to have to use a character search string. (I don't see any need to have to hardcode it) that is, .. matches any single charactr and (.*) matches any string what I want to do is use something like % that means ..%/ which means match any character but /. Of course it would need to be valid and I know I can't make up semantics for the reg ex. My point is is that, is that I don't want to have to use [a-z0-9-%&^$#@!etc...] to mean . but not /. Surely there is a way to exclude a few characters from . without having to increase the complexity of the expression 1000 fold? If you don't get that, then a simple example would be that I have an arbitrary string and I want to match only if that string does not contain an a. Sure I can so something like [bcdefghijklmnopqrstuv1234567890!@#$%^&*()_+]['/.,<>?:"{}+-=~`..........................] but surely reg exp has an easier way??? (again, this is specifically for mod rewrite)
Regex: Before And After The Match
I want to match a table and also capture the parts before and after the table: preg_match_all("|(.*)(<table.*table>)(.*)|",$text, $parts); But of course it doesn't work, presumably because the first .* is greedy. I tried adding an ? but that doesn't work either. How do I do this ?
Php Emails Do Not Match ??
i have created a registration script for my website and i have added a new featurer that makes you enter your email address twice and then it is supposed to check if they are the same and then if they are submit the form but if not show an error but even if the email addresses are the same it still shows the error below is the code for the email checking Code:
Data Mis-match In DBF Files
I'm still working on reading dbf files: The following works well: Code: <?php $gdb = dbase_open('Contact1a.dbf', 0); $rn = dbase_numrecords($gdb); echo "Number of record is: $rn <br> <br>"; if ($gdb) { $record_numbers = dbase_numrecords($gdb); for ($i = 1; $i <= $record_numbers; $i++) { $row = dbase_get_record_with_names($gdb, $i); $company = $row['COMPANY']; $contact = $row['CONTACT']; $source = $row['SOURCE']; if($source == "sean"){ echo " Company = $company, $contact, $source <br>"; } } } ?> But, the "IF" conditional for the echo statement never evaluates to TRUE even though there are records in the "source" field which are exactly "sean". If I comment out the "if" statement and the corresponding "}" the echo statement returns all records and, sure enough, some of them show "sean" as the source. I don't know whether the dbf data includes non-printing characters which are corrupting the conditional or what..
Search Database - MATCH() AGAINST() Or LIKE
I have a fairly basic database that holds articles that visitors of my web site can search based on content of the articles and the author. Simplified the tables look like this... articles +-----------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------------+--------------+------+-----+---------+-------+ | doc_id | varchar(8) | | PRI | | | | title | varchar(255) | YES | MUL | NULL | | | date | date | YES | | NULL | | | source | text | YES | | NULL | | | abstract | text | YES | MUL | NULL | | | body | mediumtext | YES | | NULL | | +-----------------+--------------+------+-----+---------+-------+ authors +---------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +---------------+--------------+------+-----+---------+----------------+ | author_id | int(11) | | PRI | NULL | auto_increment | | doc_id | varchar(8) | YES | | NULL | | | author | varchar(100) | YES | MUL | NULL | | +---------------+--------------+------+-----+---------+----------------+ The Authors name is kept in the form of first initial, middle initial (if known) and last name (ie J. Bloggs). Basically users have two fields they can complete for searching. One is the keywords (ie words in the body of the article) and the other is for the author of the article. Currently I perform a full text search to find authors that match the author they enter but I'm not sure this is the best method as authors with short last names (ie. Li or Cho) can't be found. This is the code I am using to generate a query to search the database. PHP Code:
PCRE And Match Words
The project I'm currently working on requires a lot of pattern matching and I'm currently having troubles matching more an amount of words. I'm trying to find strings in an array which have less than three words in them, I'm using the below but it is not working: (preg_match("'(S*s+){0,3}'isx" ,$qualified[$i][1]))
|