Jump to content

mikebyrne

Members
  • Posts

    780
  • Joined

  • Last visited

Posts 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. 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

  4. 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...
    ?>
    

     

     

  5. 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

  6. 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)

     

  7. 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??

  8. 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();
    ?>
    

     

  9. 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();
    ?>
    

     

  10. 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();
    ?>
    

  11. 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.