Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Storing an html template in a blob or text type field

Status
Not open for further replies.

webscripter

Programmer
Jul 29, 2002
266
US
I read that the only difference between blob and text type fields is that blob is case sensitive. I'm not comparing any values to the html text that I would like to enter into the field, so I guess text is better. Right?

Another question I have is how do I enter a variable that is full of characters ' and ".

I'm using perl with this code:
my$stmt = "CREATE TABLE IF NOT EXISTS user_templates(purpose VARCHAR(200), name VARCHAR(200) PRIMARY KEY, page TEXT, ext VARCHAR(10))";
$pkg::dbh->do($stmt) || &dberror("Couldn't do the statement $stmt");
my$tmplt_content2 = $tmplt_content;
$tmplt_content2 =~ s@'@\\'@g;
$stmt = "INSERT INTO user_templates (purpose, name, page, ext) values ('$tmplt_pur_val','$tmplt_name_val','$tmplt_content2','$pkg::ext')";
if($DBI::errstr =~ /Duplicate/){
my$replace = "REPLACE INTO user_templates (purpose, name, page, ext) values ('$tmplt_pur_val','$tmplt_name_val','$tmplt_content2','$pkg::ext')";
print STDERR "\n Found Duplicate field";
$pkg::dbh->do($replace) || &dberror("Couldn't do replace because\n");
}if($DBI::errstr =~ /Duplicate/){
my$replace = "REPLACE INTO user_templates (purpose, name, page, ext) values ('$tmplt_pur_val','$tmplt_name_val','$tmplt_content2','$pkg::ext')";
$pkg::dbh->do($replace) || &dberror("Couldn't do replace because\n");
}

This enters something into the field, but when I do this from the prompt window:

mysql>select page from user_templates where name='test';
I get this:
---------------
--------------+
1 row in set (0.06 sec)

Is there a reason I can't view the html in a msdos window?


Thanks
Pat
admin@websiteprogrammin.com
 
the ' and " characters must be replaced. i dont know how that can be done in pearl i gues u have the ereg() function or something...

and regarding the other problem i dont understand them...

Known is handfull, Unknown is worldfull
 
Code:
$content =~ s/'/\\'/g;
$content =~ s/"/\\"/g;
might do it. It's been a while since I used PERL.

//Daniel
 
Because I'm inserting the variable between quotes everything inside the quotes is considered literal till the next ' . ('$variable') So All I need to backwack is the '. The code works and adds something to the table. But when I go to view it in an msdos window all I see is

------------
-----------*

I'm going to work on it some more today. maybe it's there, I'm just not able to see it.



Thanks
Pat
admin@websiteprogrammin.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top