View Full Version : Problem with displaying inverted commas input into MYSQL database
titanite
05-31-2006, 09:54 AM
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! :)
Not without said script, we can't.
djr33
05-31-2006, 04:50 PM
"inverted commas" means backticks? ````? (below the tilde above the tab key)
titanite
06-02-2006, 08:47 AM
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?
That's not the whole script.
djr33
06-02-2006, 05:09 PM
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.
titanite
06-06-2006, 08:19 AM
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>
djr33
06-06-2006, 09:37 PM
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 " 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.
titanite
06-07-2006, 06:18 AM
aha!
It works!! What I did was that in the textbox, I did echo htmlentities($mydata)
And it works beautifully!! Thanks djr33!!
:)))))
djr33
06-07-2006, 07:10 AM
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 :p
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.