Jump to content

mikebyrne

Members
  • Posts

    780
  • Joined

  • Last visited

Everything posted by mikebyrne

  1. there's no real delimiter set just the spaces between the words hence me manually placing in the commas. Any ideas? I used a program to rip the data from a pdf and it is now displayed 2981 Rxxxe, Vixxxnt 1 Flixxxxs Clxxxe Axxxy Co.Kildare 2982 Bxxxxe, Anxxxxe 2 Flxxxrs Cxxxxe Axxxy Co.Kildare L 2983 Vxxxie, Alxxxxra 4 Flixxxxs Cxxxxe Axxxxy Co.Kildare my db has the 8 fields
  2. Im tring to create a comma seperate file to insert into a database but at present im manually putting the commas in. My test file looks like: 2981 Rxxxe, Vixxxnt 1 Flixxxxs Clxxxe Axxxy Co.Kildare 2982 Bxxxxe, Anxxxxe 2 Flxxxrs Cxxxxe Axxxy Co.Kildare L 2983 Vxxxie, Alxxxxra 4 Flixxxxs Cxxxxe Axxxxy Co.Kildare But I want the spacing to look like this: ,2981, Rxxxe, Vixxxnt, 1 Flixxxxs Clxxxe, Axxxy, Co.Kildare ,2982, Bxxxxe, Anxxxxe, 2 Flxxxrs Cxxxxe, Axxxy, Co.Kildare L ,2983, Vxxxie, Alxxxxra, 4 Flixxxxs Cxxxxe, Axxxxy, Co.Kildare Is there a way of coding this in PHP?
  3. Thats done the trick! Thanks for all your help
  4. Any help further help on this would be great!
  5. No that just puts an extra line inbetween them. Here's what the last three lines look like L ,2811, Axxxxx, Dxxxxx, 22 Dun Bxxn, Blexxx Roxxxd, Axxxhy, Co.Kildare L ,2812, Axxxxi, Lxxxcia, 22 Dun Brxxn, Blexxxxh Roxxxd, Axxy, Co.Kildare L,2813,Achxxxxxritei,Mxxx,22 Dun Brxxxn,Blxxxxch Rd,Axxxy,Co.Kildare The last line is in the correct format im looking for
  6. That works but only for the last line?? There's 3,000 or so lines and it ignores them all except the last one
  7. I currently have code thats trimming spaces after commas. Is it possible to modify this code to have a new line after the words "Co.Kildare" as this will be the last word in every line. The code is <?php $txt = file('/path to filename/filename'); // choose correct path location and file foreach ($txt as $i=>$l) $txt[$i] = implode(',',array_map('trim',explode(',',$l))) . "\n"; file_put_contents('/path to filename/filename', implode('',$txt)); // this will overwrite the filename content with the newer version with spaces removed... ?>
  8. Im running the php via an apachi server (xampp). I run the file using Firefox and I create the php page using dreamweaver
  9. That produces the same result I think the problem is that the first field can be blank i.e the first line ,2823, Fxxxxx, Caroxxx, 1 Dun Bxxxx, Forxxxxxton Drive, Axxxy, Co.Kildare L ,2824, Oxxxxx, Axxtutu, 2 Dun Brxxx, Forxxxxxxxxton Drive, Axxxy, Co.Kildare
  10. Im using the code $txt = file_get_contents('/path to filename/filename'); // choose correct path location and file $txt = implode(',',array_map('trim',explode(',',$txt))); file_put_contents('/path to filename/filename', $txt); // this will overwrite the filename content with the newer version with spaces removed... And the output file is not on separate lines, just one after the other ie ,1,Caxxn,Cxxxy,Wayside,Ardxxxgh,Axxxy,Co.Kildare,2,Caxxxn,Lxxxxm,Wayside,Ardxxxxigh,Axxy,Co.Kildare Co.Kildare will always be at the end of the line if thats any help with separating lines
  11. I was just used to coding buttons etc. The code works but it gets rid of the single line format and groups everything together. Is there anything I can do to fix this?
  12. I am indeed, So therefore I just load the page from the browser?
  13. Stupid question Number 2: How will I execute the code?
  14. At present I've 3,000 lines in my file, will this matter in terms of the code? Will I need to pass the contents into a db first and run the php?
  15. I currently have a text file in the below format: L ,2486, Sam, Smith,, xx Castle Park, Atby, Co.Kildare Is there any code out the that will help me remove the spaces after the commas so the line will look like: L,2486,Sam,Smith,,xx Castle Park,Atby,Co.Kildare
  16. My SQL is CREATE TABLE `test` ( `Vote` varchar(10) CHARACTER SET latin1 DEFAULT NULL, `ID` decimal(10,0) NOT NULL DEFAULT '0', `Sname` char(255) CHARACTER SET latin1 DEFAULT NULL, `Fname` char(255) CHARACTER SET latin1 DEFAULT NULL, `Address1` char(255) CHARACTER SET latin1 DEFAULT NULL, `Address2` varchar(50) CHARACTER SET latin1 DEFAULT NULL, `Address3` varchar(50) CHARACTER SET latin1 DEFAULT NULL, `Address4` varchar(50) CHARACTER SET latin1 DEFAULT NULL, PRIMARY KEY (`ID`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci; I've found that the below supports my language but how do I apply it? ISO 8859-1 Western European (Albanian, Basque, Breton, Catalan, Danish, Dutch, English, Faeroese, Finnish, French, German, Greenlandic, Icelandic, Irish Gaelic, Italian, Latin, Luxemburgish, Norwegian, Portuguese, Rhaeto-Romanic, Scottish Gaelic, Spanish, Swedish)
  17. I have a column names Fname which is set as Varchar but some data isn't going through. Im haveing problems with Tómas, Cnocán Glas and Mac Cóarailt. What should I change the type to?
  18. At present my code looks like this if(!empty($_POST['Fname'] )) { $Address2 = $_POST['Address2']; $Fname=$_POST['Fname']; $Sname=$_POST['Sname']; $Address1=$_POST['Address1']; $Address2=$_POST['Address2']; $Address3=$_POST['Address3']; $Address4=$_POST['Address4']; $Station=$_POST['Station']; $Vote=$_POST['Vote']; But I would like to change the first line and put an OR statemet in it ie if(!empty($_POST['Fname'] ) OR if(!empty($_POST['Sname'] )) How would I code this??
  19. I've removed the line but now I'm not getting any values returned, just a blank screen <? include("connect.php"); // now you are connected and can query the database if(!empty($_POST['Fname'])) { $Address2 = $_POST['Address2']; $Fname=$_POST['Fname']; $Sname=$_POST['Sname']; $Address1=$_POST['Address1']; $Address2=$_POST['Address2']; $Address3=$_POST['Address3']; $Address4=$_POST['Address4']; $Station=$_POST['Station']; $Vote=$_POST['Vote']; $sql = 'Select `Fname`,`Sname`, `Address1`, `Address2`, `Address3`, `Address4` FROM `Athy` WHERE '; if ($Fname && !$Sname) { $sql .= "`Fname` = '" . mysql_real_escape_string($Fname) . "'"; } else if (!$Fname && $Sname) { $sql .= "`Sname` = '" . mysql_real_escape_string($Sname) . "'"; } else if ($Fname && $Sname) { $sql .= "`Fname` = '" . mysql_real_escape_string($Fname) . "' OR `Sname` = '" . mysql_real_escape_string($Sname) . "'"; } } else{ ?> <html> <style type="text/css"> label { width:150px; margin-right:5px; text-align:right; display:block; float:left; } .style1 {font-weight: bold} </style> <body> <form name="test.php" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <p><img src="untitled.jpg" alt="" width="994" height="176" /></p> <p align="left"><label for "Firstname"><strong>Firstname</strong></label> <input type="text" name="Fname" value="<?php echo $Fname; ?>"> </p> <p align="left"><label for "Lastname"><strong>Lastname</strong></label> <input type="text" name="Sname" value="<?php echo $Sname; ?>"> </p> <p align="left"> <input name="submit" value="Submit" type="submit" /> </p> </form> </body> </html> <? } // don't forget to close the mysql connection mysql_close(); ?>
  20. Im now getting the error Fatal error: Call to undefined function exception() in C:\xampp\htdocs\Name.php on line 37 Line 37 = throw Exception('Both first name and last name are empty.'); My code looks like <? include("connect.php"); // now you are connected and can query the database if(!empty($_POST['Fname'])) { $Address2 = $_POST['Address2']; $Fname=$_POST['Fname']; $Sname=$_POST['Sname']; $Address1=$_POST['Address1']; $Address2=$_POST['Address2']; $Address3=$_POST['Address3']; $Address4=$_POST['Address4']; $Station=$_POST['Station']; $Vote=$_POST['Vote']; $sql = 'Select `Fname`,`Sname`, `Address1`, `Address2`, `Address3`, `Address4` FROM `Athy` WHERE '; if ($Fname && !$Sname) { $sql .= "`Fname` = '" . mysql_real_escape_string($Fname) . "'"; } else if (!$Fname && $Sname) { $sql .= "`Sname` = '" . mysql_real_escape_string($Sname) . "'"; } else if ($Fname && $Sname) { $sql .= "`Fname` = '" . mysql_real_escape_string($Fname) . "' OR `Sname` = '" . mysql_real_escape_string($Sname) . "'"; } throw Exception('Both first name and last name are empty.'); } else{ ?> <html> <style type="text/css"> label { width:150px; margin-right:5px; text-align:right; display:block; float:left; } .style1 {font-weight: bold} </style> <body> <form name="test.php" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <p><img src="untitled.jpg" alt="" width="994" height="176" /></p> <p align="left"><label for "Firstname"><strong>Firstname</strong></label> <input type="text" name="Fname" value="<?php echo $Fname; ?>"> </p> <p align="left"><label for "Lastname"><strong>Lastname</strong></label> <input type="text" name="Sname" value="<?php echo $Sname; ?>"> </p> <p align="left"> <input name="submit" value="Submit" type="submit" /> </p> </form> </body> </html> <? } // don't forget to close the mysql connection mysql_close(); ?>
  21. Im now getting the following error: Parse error: parse error in C:\xampp\htdocs\Name.php on line 42 Line 42 is else{ My complete code is: <? include("connect.php"); // now you are connected and can query the database if(!empty($_POST['Fname'])) { $Address2 = $_POST['Address2']; $Fname=$_POST['Fname']; $Sname=$_POST['Sname']; $Address1=$_POST['Address1']; $Address2=$_POST['Address2']; $Address3=$_POST['Address3']; $Address4=$_POST['Address4']; $Station=$_POST['Station']; $Vote=$_POST['Vote']; $sql = 'Select `Fname`,`Sname`, `Address1`, `Address2`, `Address3`, `Address4` FROM `Athy` WHERE '; if ($Fname && !$Sname) { $sql .= "`Fname` = '" . mysql_real_escape_string($Fname) . "'"; } else if (!$Fname && $Sname) { $sql .= "`Sname` = '" . mysql_real_escape_string($Sname) . "'"; } else if ($Fname && $Sname) { $sql .= "`Fname` = '" . mysql_real_escape_string($Fname) . "' OR `Sname` = '" . mysql_real_escape_string($Sname) . "'"; } else { throw Exception('Both first name and last name are empty.'); } else{ ?> <html> <style type="text/css"> label { width:150px; margin-right:5px; text-align:right; display:block; float:left; } .style1 {font-weight: bold} </style> <body> <form name="test.php" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <p><img src="untitled.jpg" alt="" width="994" height="176" /></p> <p align="left"><label for "Firstname"><strong>Firstname</strong></label> <input type="text" name="Fname" value="<?php echo $Fname; ?>"> </p> <p align="left"><label for "Lastname"><strong>Lastname</strong></label> <input type="text" name="Sname" value="<?php echo $Sname; ?>"> </p> <p align="left"> <input name="submit" value="Submit" type="submit" /> </p> </form> </body> </html> <? } // don't forget to close the mysql connection mysql_close(); ?>
  22. Is it possible to use the results from a form and connect to word's mail merge? At present my results look something like this cdsfdfd dfgfgd 23 Ardreigh, (ED Athy Rural) Athy Co Kildare The vairables used are $Fname, $Sname, $Address1, $Address2, $Address3, $Address4
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.