Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
Unliked characters

Posted by TedH (TedH), 6 May 2005
Sometimes I gotta laugh. This really got me.

I had tried the code for passing values to a form we talked about sometime back and that didn't actually work (maybe way I did it). So okay I got it working by putting $input{"f003"} in the textarea. Now I can edit and delete records okay.

Except ..... it does not like these characters:
hashmark #
pipe |
plus sign +
equal sign =
Ampersand &
Single quote '

Or (this is where I laughed) 2002 characters in the field. It worked great with 2001 characters. Why one earth does it hang at 2002 characters plus? What's it got against that 2002nd character? It's a nice character: it doesn't take drugs, it doesn't support strange political parties and it doesn't drive weird eastern European cars.

Open file and make links
$f001 is date and time - works okay.
$f002 is subject - works okay.
$f003 is field for text entry.

Code:
# database info
if ($input{'database'} eq ''){
$db=$database;
}else{
$db=$input{'database'};
}

# Open and read
open (ORGDB,"$database");
@ODB=<ORGDB>;
close (ORGDB);

# administrate data
print "
<div align='center'><b>Entries</b></div>
<table bgcolor='#00cccc' align='center' border='0' cellpadding='2' cellspacing='1'>
<tr bgcolor='#00cccc' align='center'><td colspan='2'><b>Actions</b></td>
<td><b>Subject</b></td></tr>
";

foreach $rec (@ODB){
chomp($rec);
($f001,$f002,$f003)=split(/\|/,$rec);
print <<"ADV";
<tr bgcolor='#eeeeee'><td align='center'>
<form action='editor.pl?f001=$f001&f002=$f002&f003=$f003' method='POST'>
<input type='submit' class='buttn' name='' value='Edit'>
</form>
</td><td align='center'>
<form action='delete.pl?action=delete&f001=$f001&f002=$f002&f003=$f003' method='POST'>
<input type='submit' class='buttn' name='' value='Delete'>
</form>
</td>
<td><b>$f002</b></td></tr>
ADV
}


Form it's passed to in separate script

[code]print <<"EOF";
<b>Edit Record</b>
<form action="editrec.pl" method="POST">
<input type="hidden" name="f001" value="$input{"f001"}">
<input type="hidden" name="f002" value="$input{"f002"}">
<input type="hidden" name="f003" value="$input{"f003"}">
<table bgcolor='#00cccc' align='center' border='0' cellpadding='7' cellspacing='1'>
<tr><td align='left'>
$input{"f001"}<br>
<b>$input{"f002"}</b>
<br>
<textarea name='nf003' rows='10' cols='50'>$input{"f003"}

Posted by TedH (TedH), 6 May 2005
What happened here? Does YABB have the same problem?

I'll redo the second bit.

Posted by TedH (TedH), 6 May 2005
Form it's passed to in separate script

Code:
print <<"EOF";
<b>Edit Record</b>
<form action="editrec.pl" method="POST">
<input type="hidden" name="f001" value="$input{"f001"}">
<input type="hidden" name="f002" value="$input{"f002"}">
<input type="hidden" name="f003" value="$input{"f003"}">
<table bgcolor='#00cccc' align='center' border='0' cellpadding='7' cellspacing='1'>
<tr><td align='left'>
$input{"f001"}<br>
<b>$input{"f002"}</b>
<br>
<textarea name='nf003' rows='10' cols='50'>$input{"f003"}</textarea>
</td></tr>
<tr><td align='center'>
<input type="Submit" class="buttn" value="Edit Record">
</td></tr>
</table>
</form>
EOF



I did try max chars in the textarea to no avail. I also tried passing the value from a text link as well as form button - made no difference. Did hours of searching on the net but came up with nothing - so back here again.
O what fun we have


Posted by admin (Graham Ellis), 6 May 2005
on 05/06/05 at 12:43:26, TedH wrote:
What happened here? Does YABB have the same problem?

I'll redo the second bit.


YaBB has some things it takes as special tags and smilies.

I'm running a Python course today ... will respond with a Perl answer this evening, but it won't be during the UK working day

Posted by admin (Graham Ellis), 7 May 2005
Ted,

Yes, I know what the problem is.  I've written a very long answer that's of quite general interest so I'v posted it into our solutions centre. And this link here will take you directly to the page.

Posted by TedH (TedH), 7 May 2005
Graham, read the article, thanks. The parse is virtually identical to mine. I solved the problem partially by accident (during a tidy up). In the form which has the button for the edit or delete script, single quotes were used. When double quotes were used, words which contain an apostrophe - like don't and it'll - showed up fine (other characters still fail).

Looks as though I'm stuck with the 2k limit the way the data is passed (using the ?). So I shall look for another way to do that. I suppose this applies to all databases flat-file or otherwise. Since this is going to be a diary 2k is way too small. I know about the 32k limit, but doubt any entry will ever reach that size.

Posted by TedH (TedH), 8 May 2005
Got it working. Tested a 2.5mb field entry and it work (slowly) fine. I could edit it and delete (I had read and been told once that a textarea would only handle a max of 32k - looks like that was wrong info).

Passing the values was done using "input type=hidden" form fields - as long as the values are matching with the way the database is read it works.

The characters were solved with:
(code didn't work here) I used entities like mentioned previously which are field specific.

The other characters work fine as is now. The only thing left to do is make the textarea in the editing form have a linebreak instead of showing the existing BR tags during the edit.

many thanks - Ted



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho