Results 1 to 10 of 10

Thread: Problem with displaying inverted commas input into MYSQL database

  1. #1
    Join Date
    Feb 2006
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Problem with displaying inverted commas input into MYSQL database

    Hello,

    I hope somebody can help me.

    My provider has recently changed the PHP version and apparently the php settings have been changed. The version number is 4.3.9.

    It used to be a later version: 4.3.11.

    I have a data entry page, a data update/changing page, and a public page which displays the data, and it was working fine.

    Now, whenever I enter in a field something within inverted commas (within apostrophe is fine), it will appear on the public page. No problem there.

    But when I access the data update page to change certain other details, anything AFTER the first inverted comma does not appear.

    I re-entered the data within inverted commas again, and then click on submit, the changes then appear on the public page.

    Hence my problem is "when my update page draws data from the mysql database, it deletes anything that is after an inverted comma".

    What should I do?

    Here is my php settings for magic quotes:
    magic_quotes_gpc On On
    magic_quotes_runtime Off Off
    magic_quotes_sybase Off Off

    Please help!

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Not without said script, we can't.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,162
    Thanks
    263
    Thanked 690 Times in 678 Posts

    Default

    "inverted commas" means backticks? ````? (below the tilde above the tab key)
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  4. #4
    Join Date
    Feb 2006
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hiya!

    Here is the script, I have tried the quote_smart function:


    <p>
    <? echo quote_smart("$filename5")?>
    File 05:<br>
    <input name="ud_filename5" type="text" value="<? echo quote_smart("$filename5")?>" size="80"><br>

    URL 05:<br><input name="ud_filelink5" type="text" value="<? print "$filelink5"?>" size="80">
    </p>

    The result I got was:

    Presentation by Helen Penn on Providing for Children Under Three in England: The Difficulties of a Targeted "Approach" File 05:
    [Presentation by Helen Penn on Providing for Children Under Three in England: The Difficulties of a Targeted ]

    --- [] being within the input box.
    Whatever I have done for stripping the text of slashes turned out beautifully in text, but when it comes to echoingit in input box, it didn't appear after the inverted commas.

    Perhaps someone can advise me further?

  5. #5
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    That's not the whole script.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  6. #6
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,162
    Thanks
    263
    Thanked 690 Times in 678 Posts

    Default

    Indeed.

    And why are you using print some and echo other times?

    I still don't get what you mean by inverted commas... I'm not seeing them.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  7. #7
    Join Date
    Feb 2006
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi there,

    Maybe it's a cultural misunderstanding. Inverted commas are what some people call "quotes", like those enclosing the word quote. Or do you call them "double quotes"?

    Anyway, what I meant to say was:
    - I input into a field a text, say: I love "Google"
    - It would appear fine on the webpage which draws the info from the database.
    - Then on my 'data correction form' which I have done up to amend data, in the textbox which echos this field, anything AFTER the first doublequotes/open-inverted-comma does not appear.

    My question is: why?

    I can give you the whole code here but it is too long but here goes:
    --------------------





    <html>
    <head>
    <link rel="stylesheet" type="text/css" href="../../css/style.css">
    <title>Update Record</title>
    </head>
    <body>
    <h3>Update Record</h3>
    <?
    if (!empty($HTTP_GET_VARS)) while(list($name, $value) = each($HTTP_GET_VARS))
    $$name = $value;
    if (!empty($HTTP_POST_VARS)) while(list($name, $value) = each($HTTP_POST_VARS))
    $$name = $value;



    $id=$_POST['id'];
    include "../../tornsocks.php";
    $link = mysql_connect("localhost",$username,$password);
    if (! $link)
    die("Couldn't connect to MySQL");

    mysql_select_db($db , $link)
    or die("Couldn't open $db: ".mysql_error());

    $query=" SELECT * FROM calendar_en WHERE id='$id'";
    $result=mysql_query($query);
    $num=mysql_num_rows($result);

    $i=0;
    while ($i < $num) {
    $startdate=mysql_result($result,$i,"startdate");
    $enddate=mysql_result($result,$i,"enddate");
    $eventname=mysql_result($result,$i,"eventname");
    $eventsummary=mysql_result($result,$i,"eventsummary");
    $filename1=mysql_result($result,$i,"filename1");
    $filename2=mysql_result($result,$i,"filename2");
    $filename3=mysql_result($result,$i,"filename3");
    $filename4=mysql_result($result,$i,"filename4");
    $filename5=mysql_result($result,$i,"filename5");
    $filename6=mysql_result($result,$i,"filename6");
    $filename7=mysql_result($result,$i,"filename7");
    $filename8=mysql_result($result,$i,"filename8");
    $filename9=mysql_result($result,$i,"filename9");
    $filename10=mysql_result($result,$i,"filename10");
    $filelink1=mysql_result($result,$i,"filelink1");
    $filelink2=mysql_result($result,$i,"filelink2");
    $filelink3=mysql_result($result,$i,"filelink3");
    $filelink4=mysql_result($result,$i,"filelink4");
    $filelink5=mysql_result($result,$i,"filelink5");
    $filelink6=mysql_result($result,$i,"filelink6");
    $filelink7=mysql_result($result,$i,"filelink7");
    $filelink8=mysql_result($result,$i,"filelink8");
    $filelink9=mysql_result($result,$i,"filelink9");
    $filelink10=mysql_result($result,$i,"filelink10");


    ?>



    <p>You are about to edit <strong>calendar</strong> id number: <? echo "$id" ?> in <strong>English</strong>.</p>
    <p>If you do not wish to make any changes, click on the <strong><< Editorial Interface</strong> button to return.</p>

    <form method="POST" action="dbase_interface.php">
    <input type="submit" value="<< Editorial Interface">
    </form>


    <table width="100%" border="0" align="center"cellpadding="5" cellspacing="5">
    <form action="change_record.php" method="post">
    <input type="hidden" name="ud_id" value="<? echo "$id" ?>">
    <tr valign="top">
    <td width="150">
    <p><strong>Start Date</strong>:</p>
    </td>
    <td width="530">
    <p><input name="ud_startdate" type="text" value="<? echo "$startdate"?>" size="10" maxlength="10"> (YYYY-MM-DD, for example: 2005-12-28)</p>
    </td>
    </tr>
    <tr valign="top">
    <td width="150">
    <p><strong>End Date</strong>:</p>
    </td>
    <td width="530">
    <p><input name="ud_enddate" type="text" value="<? echo "$enddate"?>" size="10" maxlength="10"> (YYYY-MM-DD, for example: 2005-12-28)</p>
    </td>
    </tr>
    <tr valign="top">
    <td width="150">
    <p><strong>Event Name</strong>:</p>
    </td>
    <td width="530">
    <p><input name="ud_eventname" type="text" value="<? echo "$eventname"?>" size="80" maxlength="255"></p>
    </td>
    </tr>
    <tr valign="top">
    <td width="150">
    <p><strong>Event Summary</strong>:</p>
    </td>
    <td width="530">
    <textarea rows=50 cols=80 name="ud_eventsummary"><? echo "$eventsummary"?></textarea>
    </td>
    </tr>

    <tr valign="top">
    <td width="150">
    <p><strong>File downloads</strong>:</p>
    </td>
    <td width="530">
    <p>
    File 01:<br><input name="ud_filename1" type="text" value="<? echo "$filename1"?>" size="80"><br>
    URL 01:<br><input name="ud_filelink1" type="text" value="<? echo "$filelink1"?>" size="80">
    </p>
    <p>
    File 02:<br><input name="ud_filename2" type="text" value="<? echo "$filename2"?>" size="80"><br>
    URL 02:<br><input name="ud_filelink2" type="text" value="<? echo "$filelink2"?>" size="80">
    </p>
    <p>
    File 03:<br><input name="ud_filename3" type="text" value="<? echo "$filename3"?>" size="80"><br>
    URL 03:<br><input name="ud_filelink3" type="text" value="<? echo "$filelink3"?>" size="80">
    </p>
    <p>
    File 04:<br><input name="ud_filename4" type="text" value="<? echo "$filename4"?>" size="80"><br>
    URL 04:<br><input name="ud_filelink4" type="text" value="<? echo "$filelink4"?>" size="80">
    </p>
    <p>

    File 05:<br><input name="ud_filename5" type="text" value="<? echo "$filename5"?>" size="80"><br>
    URL 05:<br><input name="ud_filelink5" type="text" value="<? echo "$filelink5"?>" size="80">
    </p>
    <p>
    File 06:<br><input name="ud_filename6" type="text" value="<? echo "$filename6"?>" size="80"><br>
    URL 06:<br><input name="ud_filelink6" type="text" value="<? echo "$filelink6"?>" size="80">
    </p>
    <p>
    File 07:<br><input name="ud_filename7" type="text" value="<? echo "$filename7"?>" size="80"><br>
    URL 07:<br><input name="ud_filelink7" type="text" value="<? echo "$filelink7"?>" size="80">
    </p>
    <p>
    File 08:<br><input name="ud_filename8" type="text" value="<? echo "$filename8"?>" size="80"><br>
    URL 08:<br><input name="ud_filelink8" type="text" value="<? echo "$filelink8"?>" size="80">
    </p>
    <p>
    File 09:<br><input name="ud_filename9" type="text" value="<? echo "$filename9"?>" size="80"><br>
    URL 09:<br><input name="ud_filelink9" type="text" value="<? echo "$filelink9"?>" size="80">
    </p>
    <p>
    File 10:<br><input name="ud_filename10" type="text" value="<? echo "$filename10"?>" size="80"><br>
    URL 10:<br><input name="ud_filelink10" type="text" value="<? echo "$filelink10"?>" size="80">
    </p>
    </td>
    </tr>
    </table>
    <input type="Submit" value="Update">
    </form>

    <?
    ++$i;
    }
    ?>
    </body>
    </html>

  8. #8
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,162
    Thanks
    263
    Thanked 690 Times in 678 Posts

    Default

    Ah. Yeah, they're technically quotation marks, "quotes" for short. Ok, got it.
    now... looking at the script...

    Hmm.... I'm not sure.

    Quotes generally cause problems when you have something like:

    echo "stuff "other stuff" and stuff";

    And then the quotes in the middle would end the string, leaving random stuff after that didn't fit.

    However, it seems like your php works fine.

    I believe the issue is that you end up with something like this:
    <input value="textgoeshere">
    where the text contains quotes, ending the "value" parameter, making the rest not do anything.

    If you use:
    htmlentities($yourtext)
    and echo that instead, it'll make the " into &quot; so it won't act as an operator in html, but as just a character to be displayed.

    that help at all?

    If you link to your page, it'll really help with this too.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  9. #9
    Join Date
    Feb 2006
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    aha!

    It works!! What I did was that in the textbox, I did echo htmlentities($mydata)
    And it works beautifully!! Thanks djr33!!
    ))))

  10. #10
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,162
    Thanks
    263
    Thanked 690 Times in 678 Posts

    Default

    Sure. It's just like messing up the quotes in php, but when it outputted to html... a bit harder to catch when just looking at the php code. Quotes, aka Inverted Commas, are evil
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •