Apostrophes causing problems

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kdidymus
Forum Contributor
Posts: 196
Joined: Tue May 13, 2008 3:37 am

Apostrophes causing problems

Post by kdidymus »

I asked this question in another thread but wanted to put it out there and make the problem a little clearer.

I am designing a family tree site. Amongst the details I'm publishing about my ancestors are places of birth and christenings. The example I'll use is the one I'm having trouble with:
St. Stephen's Church, Nanstallon, Cornwall, UK
Okay. So I have a PHP page which allows me to add a new record to the database. And that works fine. It uploads all of the details. If you click the following hyperlink you'll see what I mean:

http://www.didymus.org.uk/display.php?urn=11164 or just go to http://www.didymus.org.uk and enter the "URN" (11164) in the Quick Jump box to see it as it's meant to be displayed.

The problem is this:

I have a PHP page which allows me to edit entries in my dB. It downloads all of the data from my database for a specific individual and uses it to populate a form. I can then make changes and submit them easily.

When the PHP page populates the form it ignores everything after the apostrophe in St. Stephen's Church, Nanstallon, Cornwall, UK.

So what I get in the form is:

St. Stephen
Hmm. Hugely helpful.

I either have to manually edit any boxes with an apostrophe in OR (I'm hoping) get some help with how to get PHP to download apostrophes and everything that follows.

So here is my code:

Code: Select all

<?php
 
/* Program: editrecord.php
 
 * Desc:    Displays existing data and allows changes.
 
 */
 
  // CONNECT TO MYSQL AND CHECK FOR ROW
 
  include_once("../*******.inc.php");
 
  $cxn = mysql_connect($host,$user,$password)
 
         or die ("couldn't connect to server");
 
  mysql_select_db($database);
 
  $urn = mysql_real_escape_string($_GET['urn']); 
 
  //urn passed by hyperlink
 
  $query = "SELECT * FROM tree WHERE urn='$urn'";
  
  $result = mysql_query($query)
 
            or die ("Couldn't execute query.");
 
  // IF THE SPECIFIED ROW DOESN'T EXIST LOAD ERROR PAGE
 
  if(mysql_num_rows($result)==0)
 
  { 
 
  header("Location: ../urn404.php");
 
  exit;
 
  }
 
  //IF THE ROW SPECIFIED EXISTS THEN
 
  else {
 
while($row = mysql_fetch_assoc($result))
 
extract($row);
 
echo "<html>
 
<head>
 
<title>Amend Existing Record</title>
 
</head>
 
 
 
<body>
 
<p align='center'><img src='../tree/graphics/did_logo.gif'></p>
 
<form action='amend.php' method='POST'>
 
<table border='0' width='100%' cellspacing='0' cellpadding='0' id='table1'>
 
    <tr>
 
        <td colspan='4' align='center'>
 
        <font face='Arial' size='4' color='#FF0000'>AMEND GENEALOGICAL RECORD 
 
        IN FAMILY TREE DATABASE</font></td>
 
    </tr>
 
    <tr>
 
        <td colspan='4' align='center'>
 
        <hr></td>
 
    </tr>
 
    <tr>
 
        <td colspan='4'><b><font face='Arial' size='2'>INDIVIDUAL:</font></b></td>
 
    </tr>
 
    <tr>
 
        <td><font face='Arial' size='1'>RELATIVE CLASS:</font></td>
 
        <td><input type='text' value='$relative' name='relative'>
 
</td>
 
        <td>&nbsp;</td>
 
        <td>
 
&nbsp;</td>
 
    </tr>
 
    <tr>
 
        <td><font face='Arial' size='1'>URN:</font></td>
 
        <td>
 
<font size='2' face='Arial' color='#000000'>
 
        $urn</font></td>
 
        <td><font face='Arial' size='1'>SURNAME:</font></td>
 
        <td>
 
<font size='1' face='Arial' color='#000000'>
 
        <input type='text' name='surname' value='$surname'></font></td>
 
    </tr>
 
    <tr>
 
        <td><font face='Arial' size='1'>FORENAME:</font></td>
 
        <td>
 
<font size='1' face='Arial' color='#000000'>
 
        <input type='text' name='forename' value='$forename'></font></td>
 
        <td><font face='Arial' size='1'>MIDDLE NAME(S):</font></td>
 
        <td>
 
<font size='1' face='Arial' color='#000000'>
 
        <input type='text' name='middlenames' value='$middlenames'></font></td>
 
    </tr>
 
    <tr>
 
        <td><font face='Arial' size='1'>DATE OF BIRTH:</font></td>
 
        <td>
 
<font size='1' face='Arial' color='#000000'>
 
        <input type='text' name='dateofbirth' value='$dateofbirth'></font></td>
 
        <td><font face='Arial' size='1'>YEAR OF BIRTH:</font></td>
 
        <td>
 
<font size='1' face='Arial' color='#000000'>
 
        <input type='text' name='yearofbirth' value='$yearofbirth'></font></td>
 
    </tr>
 
    <tr>
 
        <td><font face='Arial' size='1'>PLACE OF BIRTH:</font></td>
 
        <td>
 
<font size='1' face='Arial' color='#000000'>
 
        <input type='text' name='placeofbirth' value='$placeofbirth'></font></td>
 
        <td>&nbsp;</td>
 
        <td>&nbsp;</td>
 
    </tr>
 
    <tr>
 
        <td colspan='4'><hr></td>
 
    </tr>
 
    <tr>
 
        <td><b><font face='Arial' size='2'>PARENTS:</font></b></td>
 
        <td>&nbsp;</td>
 
        <td>&nbsp;</td>
 
        <td>&nbsp;</td>
 
    </tr>
 
    <tr>
 
        <td><font face='Arial' size='1'>MOTHER:</font></td>
 
        <td><font size='1' face='Arial' color='#000000'>
 
        <input type='text' name='mother' value='$mother'></font></td>
 
        <td><font face='Arial' size='1'>MOTHER URN:</font></td>
 
        <td><font size='1' face='Arial' color='#000000'>
 
        <input type='text' name='motherurn' value='$motherurn'></font></td>
 
    </tr>
 
    <tr>
 
        <td><font face='Arial' size='1'>FATHER:</font></td>
 
        <td><font size='1' face='Arial' color='#000000'>
 
        <input type='text' name='father' value='$father'></font></td>
 
        <td><font face='Arial' size='1'>FATHER URN:</font></td>
 
        <td><font size='1' face='Arial' color='#000000'>
 
        <input type='text' name='fatherurn' value='$fatherurn'></font></td>
 
    </tr>
 
    <tr>
 
        <td colspan='4'><hr></td>
 
    </tr>
 
    <tr>
 
        <td><b><font face='Arial' size='2'>SIBLINGS:</font></b></td>
 
        <td>&nbsp;</td>
 
        <td>&nbsp;</td>
 
        <td>&nbsp;</td>
 
    </tr>
 
    <tr>
 
        <td></td>
 
        <td colspan='3'>
 
                <font face='Arial' size='1'>Sibling 1:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='sibling1' value='$sibling1'>URN:<input type='text' name='sibling1urn' value='$sibling1urn'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>Sibling 2:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='sibling2' value='$sibling2'>URN:<input type='text' name='sibling2urn' value='$sibling2urn'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>Sibling 3:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='sibling3' value='$sibling3'>URN:<input type='text' name='sibling3urn' value='$sibling3urn'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>Sibling 4:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='sibling4' value='$sibling4'>URN:<input type='text' name='sibling4urn' value='$sibling4urn'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>Sibling 5:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='sibling5' value='$sibling5'>URN:<input type='text' name='sibling5urn' value='$sibling5urn'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>Sibling 6:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='sibling6' value='$sibling6'>URN:<input type='text' name='sibling6urn' value='$sibling6urn'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>Sibling 7:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='sibling7' value='$sibling7'>URN:<input type='text' name='sibling7urn' value='$sibling7urn'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>Sibling 8:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='sibling8' value='$sibling8'>URN:<input type='text' name='sibling8urn' value='$sibling8urn'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>Sibling 9:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='sibling9' value='$sibling9'>URN:<input type='text' name='sibling9urn' value='$sibling9urn'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>Sibling 10:&nbsp;&nbsp;<input type='text' name='sibling10' value='$sibling10'>URN:<input type='text' name='sibling10urn' value='$sibling10urn'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>Sibling 11:&nbsp;&nbsp;<input type='text' name='sibling11' value='$sibling11'>URN:<input type='text' name='sibling11urn' value='$sibling11urn'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>Sibling 12:&nbsp;&nbsp;<input type='text' name='sibling12' value='$sibling12'>URN:<input type='text' name='sibling12urn' value='$sibling12urn'></font><br>
 
</td>
 
    </tr>
 
    <tr>
 
        <td colspan='4'><hr></td>
 
    </tr>
 
    <tr>
 
        <td><b><font face='Arial' size='2'>CHRISTENING:</font></b></td>
 
        <td>&nbsp;</td>
 
        <td>&nbsp;</td>
 
        <td>&nbsp;</td>
 
    </tr>
 
    <tr>
 
        <td><font face='Arial' size='1'>DATE:</font></td>
 
        <td><font size='1' face='Arial' color='#000000'>
 
        <input type='text' name='christeningdate' value='$christeningdate'></font></td>
 
        <td><font face='Arial' size='1'>PLACE:</font></td>
 
        <td><font size='1' face='Arial' color='#000000'>
 
        <input type='text' name='christeningplace' value='$christeningplace'></font></td>
 
    </tr>
 
    <tr>
 
        <td colspan='4'><hr></td>
 
    </tr>
 
    <tr>
 
        <td><b><font face='Arial' size='2'>SPOUSE 1:</font></b></td>
 
        <td>&nbsp;</td>
 
        <td>&nbsp;</td>
 
        <td>&nbsp;</td>
 
    </tr>
 
    <tr>
 
        <td><font face='Arial' size='1'>NAME:</font></td>
 
        <td><font size='1' face='Arial' color='#000000'>
 
        <input type='text' name='spouse1' value='$spouse1'></font></td>
 
        <td><font face='Arial' size='1'>URN:</font></td>
 
        <td><font size='1' face='Arial' color='#000000'>
 
        <input type='text' name='spouse1urn' value='$spouse1urn'></font></td>
 
    </tr>
 
    <tr>
 
        <td><font face='Arial' size='1'>MARRIAGE DATE:</font></td>
 
        <td><font size='1' face='Arial' color='#000000'>
 
        <input type='text' name='spouse1marriagedate' value='$spouse1marriagedate'></font></td>
 
        <td><font face='Arial' size='1'>MARRIAGE PLACE:</font></td>
 
        <td><font size='1' face='Arial' color='#000000'>
 
        <input type='text' name='spouse1marriageplace' value='$spouse1marriageplace'></font></td>
 
    </tr>
 
    <tr>
 
        <td></td>
 
        <td colspan='3'>
 
                <font face='Arial' size='1'>Child 1:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='spouse1child1' value='$spouse1child1'>URN:<input type='text' name='spouse1child1urn' value='$spouse1child1urn'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>Child 2:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='spouse1child2' value='$spouse1child2'>URN:<input type='text' name='spouse1child2urn' value='$spouse1child2urn'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>Child 3:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='spouse1child3' value='$spouse1child3'>URN:<input type='text' name='spouse1child3urn' value='$spouse1child3urn'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>Child 4:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='spouse1child4' value='$spouse1child4'>URN:<input type='text' name='spouse1child4urn' value='$spouse1child4urn'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>Child 5:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='spouse1child5' value='$spouse1child5'>URN:<input type='text' name='spouse1child5urn' value='$spouse1child5urn'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>Child 6:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='spouse1child6' value='$spouse1child6'>URN:<input type='text' name='spouse1child6urn' value='$spouse1child6urn'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>Child 7:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='spouse1child7' value='$spouse1child7'>URN:<input type='text' name='spouse1child7urn' value='$spouse1child7urn'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>Child 8:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='spouse1child8' value='$spouse1child8'>URN:<input type='text' name='spouse1child8urn' value='$spouse1child8urn'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>Child 9:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='spouse1child9' value='$spouse1child9'>URN:<input type='text' name='spouse1child9urn' value='$spouse1child9urn'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>Child 10:&nbsp;&nbsp;<input type='text' name='spouse1child10' value='$spouse1child10'>URN:<input type='text' name='spouse1child10urn' value='$spouse1child10urn'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>Child 11:&nbsp;&nbsp;<input type='text' name='spouse1child11' value='$spouse1child11'>URN:<input type='text' name='spouse1child11urn' value='$spouse1child11urn'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>Child 12:&nbsp;&nbsp;<input type='text' name='spouse1child12' value='$spouse1child12'>URN:<input type='text' name='spouse1child12urn' value='$spouse1child12urn'></font><br>
 
</td>
 
    </tr>
 
    <tr>
 
        <td colspan='4'><hr></td>
 
    </tr>
 
    <tr>
 
        <td><b><font face='Arial' size='2'>SPOUSE 2:</font></b></td>
 
        <td>&nbsp;</td>
 
        <td>&nbsp;</td>
 
        <td>&nbsp;</td>
 
    </tr>
 
    <tr>
 
        <td><font face='Arial' size='1'>NAME:</font></td>
 
        <td><font size='1' face='Arial' color='#000000'>
 
        <input type='text' name='spouse2' value='$spouse2'></font></td>
 
        <td><font face='Arial' size='1'>URN:</font></td>
 
        <td><font size='1' face='Arial' color='#000000'>
 
        <input type='text' name='spouse2urn' value='$spouse2urn'></font></td>
 
    </tr>
 
    <tr>
 
        <td><font face='Arial' size='1'>MARRIAGE DATE:</font></td>
 
        <td><font size='1' face='Arial' color='#000000'>
 
        <input type='text' name='spouse2marriagedate' value='$spouse2marriagedate'></font></td>
 
        <td><font face='Arial' size='1'>MARRIAGE PLACE:</font></td>
 
        <td><font size='1' face='Arial' color='#000000'>
 
        <input type='text' name='spouse2marriageplace' value='$spouse2marriageplace'></font></td>
 
    </tr>
 
    <tr>
 
        <td></td>
 
        <td colspan='3'>
 
                <font face='Arial' size='1'>Child 1:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='spouse2child1' value='$spouse2child1'>URN:<input type='text' name='spouse2child1urn' value='$spouse2child1urn'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>Child 2:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='spouse2child2' value='$spouse2child2'>URN:<input type='text' name='spouse2child2urn' value='$spouse2child2urn'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>Child 3:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='spouse2child3' value='$spouse2child3'>URN:<input type='text' name='spouse2child3urn' value='$spouse2child3urn'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>Child 2:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='spouse2child4' value='$spouse2child4'>URN:<input type='text' name='spouse2child4urn' value='$spouse2child4urn'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>Child 2:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='spouse2child5' value='$spouse2child5'>URN:<input type='text' name='spouse2child5urn' value='$spouse2child5urn'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>Child 2:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='spouse2child6' value='$spouse2child6'>URN:<input type='text' name='spouse2child6urn' value='$spouse2child6urn'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>Child 2:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='spouse2child7' value='$spouse2child7'>URN:<input type='text' name='spouse2child7urn' value='$spouse2child7urn'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>Child 2:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='spouse2child8' value='$spouse2child8'>URN:<input type='text' name='spouse2child8urn' value='$spouse2child8urn'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>Child 2:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='spouse2child9' value='$spouse2child9'>URN:<input type='text' name='spouse2child9urn' value='$spouse2child9urn'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>Child 2:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='spouse2child10' value='$spouse2child10'>URN:<input type='text' name='spouse2child10urn' value='$spouse2child10urn'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>Child 2:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='spouse2child11' value='$spouse2child11'>URN:<input type='text' name='spouse2child11urn' value='$spouse2child11urn'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>Child 2:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='spouse2child12' value='$spouse2child12'>URN:<input type='text' name='spouse2child12urn' value='$spouse2child12urn'><br>
 
</td>
 
    </tr>
 
    <tr>
 
        <td colspan='4'><hr></td>
 
    </tr>
 
    <tr>
 
        <td><b><font face='Arial' size='2'>EMPLOYMENT:</font></b></td>
 
        <td>&nbsp;</td>
 
        <td>&nbsp;</td>
 
        <td>&nbsp;</td>
 
    </tr>
 
    <tr>
 
        <td><font face='Arial' size='1'>OCCUPATION:</font></td>
 
        <td><font size='1' face='Arial' color='#000000'>
 
        <input type='text' name='occupation' value='$occupation'></font></td>
 
        <td>&nbsp;</td>
 
        <td>&nbsp;</td>
 
    </tr>
 
    <tr>
 
        <td colspan='4'><hr></td>
 
    </tr>
 
    <tr>
 
        <td><b><font face='Arial' size='2'>DEATH:</font></b></td>
 
        <td>&nbsp;</td>
 
        <td>&nbsp;</td>
 
        <td>&nbsp;</td>
 
    </tr>
 
    <tr>
 
        <td><font face='Arial' size='1'>DATE:</font></td>
 
        <td><font size='1' face='Arial' color='#000000'>
 
        <input type='text' name='dateofdeath' value='$dateofdeath'></font></td>
 
        <td><font face='Arial' size='1'>PLACE:</font></td>
 
        <td><font size='1' face='Arial' color='#000000'>
 
        <input type='text' name='placeofdeath' value='$placeofdeath'></font></td>
 
    </tr>
 
    <tr>
 
        <td><font face='Arial' size='1'>CAUSE:</font></td>
 
        <td colspan='3'><font size='1' face='Arial' color='#000000'>
 
        <input type='text' name='causeofdeath' size='108'  value='$causeofdeath'></font></td>
 
        </tr>
 
    <tr>
 
        <td colspan='4'><hr></td>
 
    </tr>
 
    <tr>
 
        <td><b><font face='Arial' size='2'>LINK IMAGES:</font></b></td>
 
        <td>&nbsp;</td>
 
        <td>&nbsp;</td>
 
        <td>&nbsp;</td>
 
    </tr>
 
    <tr>
 
        <td><font face='Arial' size='1'>PHOTOGRAPHS</font></td>
 
        <td><input type='text' value='$photographs' name='photographs'></td>
 
        <td><font face='Arial' size='1'>CENSUS</font></td>
 
        <td><input type='text' value='$census' name='census'></td>
 
    </tr>
 
    <tr>
 
        <td><font face='Arial' size='1'>SCRAPBOOK</font></td>
 
        <td><input type='text' value='$scrapbook' name='scrapbook'></td>
 
        <td><font face='Arial' size='1'>CERTIFICATES</font></td>
 
        <td><input type='text' value='$certificates' name='certificates'></td>
 
    </tr>
 
    <tr>
 
        <td colspan='4'><hr></td>
 
    </tr>
 
    <tr>
 
        <td><b><font face='Arial' size='2'>PHOTOGRAPHS:</font></b></td>
 
        <td></td>
 
        <td>&nbsp;</td>
 
        <td>&nbsp;</td>
 
    </tr>
 
    <tr>
 
        <td></td>
 
        <td colspan='3'>
 
                <font face='Arial' size='1'>PHOTO 1 FILENAME:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='photo1urn' value='$photo1urn'>DESCRIPTION:<input type='text' name='photo1description'  value='$photo1description'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>PHOTO 2 FILENAME:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='photo2urn' value='$photo2urn'>DESCRIPTION:<input type='text' name='photo2description'  value='$photo2description'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>PHOTO 3 FILENAME:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='photo3urn' value='$photo3urn'>DESCRIPTION:<input type='text' name='photo3description'  value='$photo3description'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>PHOTO 4 FILENAME:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='photo4urn' value='$photo4urn'>DESCRIPTION:<input type='text' name='photo4description'  value='$photo4description'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>PHOTO 5 FILENAME:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='photo5urn' value='$photo5urn'>DESCRIPTION:<input type='text' name='photo5description'  value='$photo5description'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>PHOTO 6 FILENAME:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='photo6urn' value='$photo6urn'>DESCRIPTION:<input type='text' name='photo6description'  value='$photo6description'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>PHOTO 7 FILENAME:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='photo7urn' value='$photo7urn'>DESCRIPTION:<input type='text' name='photo7description'  value='$photo7description'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>PHOTO 8 FILENAME:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='photo8urn' value='$photo8urn'>DESCRIPTION:<input type='text' name='photo8description'  value='$photo8description'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>PHOTO 9 FILENAME:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='photo9urn' value='$photo9urn'>DESCRIPTION:<input type='text' name='photo9description'  value='$photo9description'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>PHOTO 10 FILENAME:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='photo10urn' value='$photo10urn'>DESCRIPTION:<input type='text' name='photo10description'  value='$photo10description'><br>
 
                </font>
 
    </td>
 
    </tr>
 
    <tr>
 
        <td colspan='4'><hr></td>
 
    </tr>
 
    <tr>
 
        <td><b><font face='Arial' size='2'>CERTIFICATES:</font></b></td>
 
        <td>&nbsp;</td>
 
        <td>&nbsp;</td>
 
        <td>&nbsp;</td>
 
    </tr>
 
    <tr>
 
        <td></td>
 
        <td colspan='3'><font face='Arial' size='1pt' color='#000000'>TYPE:&nbsp;&nbsp;&nbsp;&nbsp;</font><select size='1' name='cert1urn'>
 
<option selected value='$cert1urn'>$cert1urn</option>
 
<option value='bc'>Birth</option>
 
<option value='mc'>Marriage</option>
 
<option value='dc'>Death</option>
 
</select><font face='Arial' size='1pt' color='#000000'>&nbsp;&nbsp;&nbsp;&nbsp;DESCRIPTION:&nbsp;&nbsp;&nbsp;&nbsp;</font><select size='1' name='cert1description'>
 
<option selected value='$cert1description'>$cert1description</option>
 
<option value='Birth Certificate'>Birth</option>
 
<option value='Marriage Certificate'>Marriage</option>
 
<option value='Death Certificate'>Death</option></select><font face='Arial' size='1pt' color='#000000'>&nbsp;&nbsp;&nbsp;&nbsp;FILENAME:&nbsp;&nbsp;&nbsp;&nbsp;</font><input type='text' name='cert1fn' value='$cert1fn'><br>
 
<font face='Arial' size='1pt' color='#000000'>TYPE:&nbsp;&nbsp;&nbsp;&nbsp;</font><select size='1' name='cert2urn'>
 
<option selected value='$cert2urn'>$cert2urn</option>
 
<option value='bc'>Birth</option>
 
<option value='mc'>Marriage</option>
 
<option value='dc'>Death</option>
 
</select><font face='Arial' size='1pt' color='#000000'>&nbsp;&nbsp;&nbsp;&nbsp;DESCRIPTION:&nbsp;&nbsp;&nbsp;&nbsp;</font><select size='1' name='cert2description'>
 
<option selected value='$cert2description'>$cert2description</option>
 
<option value='Birth Certificate'>Birth</option>
 
<option value='Marriage Certificate'>Marriage</option>
 
<option value='Death Certificate'>Death</option></select><font face='Arial' size='1pt' color='#000000'>&nbsp;&nbsp;&nbsp;&nbsp;FILENAME:&nbsp;&nbsp;&nbsp;&nbsp;</font><input type='text' name='cert2fn' value='$cert2fn'><br>
 
<font face='Arial' size='1pt' color='#000000'>TYPE:&nbsp;&nbsp;&nbsp;&nbsp;</font><select size='1' name='cert3urn'>
 
<option selected value='$cert3urn'>$cert3urn</option>
 
<option value='bc'>Birth</option>
 
<option value='mc'>Marriage</option>
 
<option value='dc'>Death</option>
 
</select><font face='Arial' size='1pt' color='#000000'>&nbsp;&nbsp;&nbsp;&nbsp;DESCRIPTION:&nbsp;&nbsp;&nbsp;&nbsp;</font><select size='1' name='cert3description'>
 
<option selected value='$cert3description'>$cert3description</option>
 
<option value='Birth Certificate'>Birth</option>
 
<option value='Marriage Certificate'>Marriage</option>
 
<option value='Death Certificate'>Death</option></select><font face='Arial' size='1pt' color='#000000'>&nbsp;&nbsp;&nbsp;&nbsp;FILENAME:&nbsp;&nbsp;&nbsp;&nbsp;</font><input type='text' name='cert3fn' value='$cert3fn'><br>
 
<font face='Arial' size='1pt' color='#000000'>TYPE:&nbsp;&nbsp;&nbsp;&nbsp;</font><select size='1' name='cert4urn'>
 
<option selected value='$cert4urn'>$cert4urn</option>
 
<option value='bc'>Birth</option>
 
<option value='mc'>Marriage</option>
 
<option value='dc'>Death</option>
 
</select><font face='Arial' size='1pt' color='#000000'>&nbsp;&nbsp;&nbsp;&nbsp;DESCRIPTION:&nbsp;&nbsp;&nbsp;&nbsp;</font><select size='1' name='cert4description'>
 
<option selected value='$cert4description'>$cert4description</option>
 
<option value='Birth Certificate'>Birth</option>
 
<option value='Marriage Certificate'>Marriage</option>
 
<option value='Death Certificate'>Death</option></select><font face='Arial' size='1pt' color='#000000'>&nbsp;&nbsp;&nbsp;&nbsp;FILENAME:&nbsp;&nbsp;&nbsp;&nbsp;</font><input type='text' name='cert4fn' value='$cert4fn'><br>
 
<font face='Arial' size='1pt' color='#000000'>TYPE:&nbsp;&nbsp;&nbsp;&nbsp;</font><select size='1' name='cert5urn'>
 
<option selected value='$cert5urn'>$cert5urn</option>
 
<option value='bc'>Birth</option>
 
<option value='mc'>Marriage</option>
 
<option value='dc'>Death</option>
 
</select><font face='Arial' size='1pt' color='#000000'>&nbsp;&nbsp;&nbsp;&nbsp;DESCRIPTION:&nbsp;&nbsp;&nbsp;&nbsp;</font><select size='1' name='cert5description'>
 
<option selected value='$cert5description'>$cert5description</option>
 
<option value='Birth Certificate'>Birth</option>
 
<option value='Marriage Certificate'>Marriage</option>
 
<option value='Death Certificate'>Death</option></select><font face='Arial' size='1pt' color='#000000'>&nbsp;&nbsp;&nbsp;&nbsp;FILENAME:&nbsp;&nbsp;&nbsp;&nbsp;</font><input type='text' name='cert5fn' value='$cert5fn'><br>
 
</td>
 
    </tr>
 
    <tr>
 
        <td colspan='4'><hr></td>
 
    </tr>
 
    <tr>
 
        <td><b><font face='Arial' size='2'>SCRAPBOOK:</font></b></td>
 
        <td>&nbsp;</td>
 
        <td>&nbsp;</td>
 
        <td>&nbsp;</td>
 
    </tr>
 
    <tr>
 
        <td></td>
 
        <td colspan='3'>
 
                <font face='Arial' size='1'>SCRAPBOOK 1 FILENAME:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='stories1urn' value='$stories1urn'>DESCRIPTION:<input type='text' name='stories1description' value='$stories1description'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>SCRAPBOOK 2 FILENAME:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='stories2urn' value='$stories2urn'>DESCRIPTION:<input type='text' name='stories2description' value='$stories2description'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>SCRAPBOOK 3 FILENAME:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='stories3urn' value='$stories3urn'>DESCRIPTION:<input type='text' name='stories3description' value='$stories3description'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>SCRAPBOOK 4 FILENAME:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='stories4urn' value='$stories4urn'>DESCRIPTION:<input type='text' name='stories4description' value='$stories4description'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>SCRAPBOOK 5 FILENAME:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='stories5urn' value='$stories5urn'>DESCRIPTION:<input type='text' name='stories5description' value='$stories5description'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>SCRAPBOOK 6 FILENAME:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='stories6urn' value='$stories6urn'>DESCRIPTION:<input type='text' name='stories6description' value='$stories6description'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>SCRAPBOOK 7 FILENAME:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='stories7urn' value='$stories7urn'>DESCRIPTION:<input type='text' name='stories7description' value='$stories7description'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>SCRAPBOOK 8 FILENAME:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='stories8urn' value='$stories8urn'>DESCRIPTION:<input type='text' name='stories8description' value='$stories8description'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>SCRAPBOOK 9 FILENAME:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='stories9urn' value='$stories9urn'>DESCRIPTION:<input type='text' name='stories9description' value='$stories9description'><br>
 
                </font>
 
 
 
                <font face='Arial' size='1'>SCRAPBOOK 10 FILENAME:&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' name='stories10urn' value='$stories10urn'>DESCRIPTION:<input type='text' name='stories10description' value='$stories10description'><br>
 
                </font>
 
    </td>
 
    </tr>
 
    <tr>
 
        <td colspan='4'><hr></td>
 
    </tr>
 
    <tr>
 
        <td>
 
<b><font face='Arial' size='2'>MISCELLANEOUS:</font></b></td>
 
        <td>&nbsp;</td>
 
        <td>&nbsp;</td>
 
        <td>&nbsp;</td>
 
    </tr>
 
    <tr>
 
        <td align='left' valign='top'>
 
<font face='Arial' size='1'>NOTES:</font></td>
 
        <td colspan='3'>
 
        <input type='text' size='108' name='notes' value='$notes'>
 
        </td>
 
    </tr>
 
    <tr>
 
        <td colspan='4'>
 
<hr></td>
 
    </tr>
 
    <tr>
 
        <td>
<input type=hidden name='urn' value='$urn'>
<input type='submit' value='SAVE CHANGES'><input type='reset' value='Reset'>
 
        </form></td>
 
        <td>&nbsp;</td>
 
        <td>&nbsp;</td>
 
        <td>&nbsp;</td>
 
    </tr>
 
    </table>
 
 
 
</body>
 
</html>";}
 
?>
 
 
I've tried escape strings and slashes to no avail.

If somebody knows how I can get this PHP page to process apostrophes and everything thereafter on the ENTIRE database this would be preferable as it would also cover ancestors with names like O'Brien and O'Keefe that currently show as:
O
Thanks in advance for your help.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Re: Apostrophes causing problems

Post by Kieran Huggins »

Try enclosing your xhtml form attributes in double quotes instead.
kdidymus
Forum Contributor
Posts: 196
Joined: Tue May 13, 2008 3:37 am

Re: Apostrophes causing problems

Post by kdidymus »

Tried that..
<input type='text' name='christeningdate' value="$christeningdate"></font></td>
But when I do, I get the following error:
Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in /home/kdidymus/public_html/admin/editrecord.php on line 353
Clearly my niaveity is showing here because I'm not doing SOMETHING right but I can't get my head around what that something is!
kdidymus
Forum Contributor
Posts: 196
Joined: Tue May 13, 2008 3:37 am

Re: Apostrophes causing problems

Post by kdidymus »

I'm going to take myself outside and have a few words.

How stupid...
<input type='text' name='christeningplace' value=\"$christeningplace\">
And it works.

Thanks Kieran.

KD.
ilikeitgui
Forum Newbie
Posts: 3
Joined: Thu Jun 19, 2008 3:44 pm

Re: Apostrophes causing problems

Post by ilikeitgui »

Another solution would be to replace the single quotes ( ' ) with aspostrophes (`) before saving it to the database. This will prevent future problems if you decide to use the data else where.

The Apostrophe is the key on the keyboard above Tab that, I believe, no one actaully uses.

Jonathan
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Apostrophes causing problems

Post by califdon »

ilikeitgui wrote:Another solution would be to replace the single quotes ( ' ) with aspostrophes (`) before saving it to the database. This will prevent future problems if you decide to use the data else where.

The Apostrophe is the key on the keyboard above Tab that, I believe, no one actaully uses.

Jonathan
That is the back tick, not the apostrophe, which is the same as a single quote.
kdidymus
Forum Contributor
Posts: 196
Joined: Tue May 13, 2008 3:37 am

Re: Apostrophes causing problems

Post by kdidymus »

A superb suggestion fellas.

Will try using the ` instead of the ' in future.

Thanks.

KD.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Re: Apostrophes causing problems

Post by Kieran Huggins »

don't use the backtick - it has real uses and is simply not an apostrophe.

Instead, try writing your display code thusly:

Code: Select all

<?php
while($row = mysql_fetch_assoc($result)){
?>
<html>
  <form>
    <input name="name" value="<?php echo(str_replace('"','\"',$row['name']));?>"/>
  </form>
</html>
<?php 
}
?>
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Apostrophes causing problems

Post by califdon »

Just for clarification:

Double quote (") - used to enclose literal strings - php expands simple variables within double quotes.

Single quote or Apostrophe (') - also used to enclose literal strings, but php does not expand variables within single quotes - also used to enclose string index of an array (as in $myArray['lastname']).

Back tick (`) - used by MySQL to enclose names of tables and fields (as in $sql="SELECT `name`,`address` FROM `myTable` WHERE `id`=$id";) - also used in some other contexts, such as executing commands.
Post Reply