SitePoint Sponsor |
|
User Tag List
Results 1 to 8 of 8
-
Nov 18, 2000, 11:55 #1
- Join Date
- Aug 2000
- Location
- N.S., Canada
- Posts
- 487
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi,
I don't know much about php but I have a problem. I have a script that I just spent 2 hours on modifying and trying to get working. I finaly did get it to work but when a type for example, "That's a pain", said the old man., quotes it shows up like, /"That/'s a pain/", said the old man.
Is there anything I could type to stop it from doing that like if I put a "\" in front of quotes or something?
Thanks,
Justin Sampson
-
Nov 18, 2000, 12:02 #2
- Join Date
- Aug 2000
- Location
- San Diego, CA
- Posts
- 5,460
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Actually if you are storing this in a databse you need to have the slashes in fornt of the quotes. If you are simply emailing this data. You can use $data = stripslashes($data) before you use it. With the other example when you pull the data back out of the database you would need to again use stripslashes() before displaying the data.
Please don't PM me with questions.
Use the forums, that is what they are here for.
-
Nov 18, 2000, 12:38 #3
- Join Date
- Aug 2000
- Location
- N.S., Canada
- Posts
- 487
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks but it's not going into a database, it's just printing it to a file. So how would I do that?
Do I use $data = stripslashes($data)?
If I do where in the code do I put it?
Thanks,
Justin Sampson
-
Nov 18, 2000, 16:05 #4
- Join Date
- Aug 2000
- Location
- San Diego, CA
- Posts
- 5,460
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Before you write the data to the text file.
Please don't PM me with questions.
Use the forums, that is what they are here for.
-
Nov 18, 2000, 18:40 #5
- Join Date
- Apr 2000
- Location
- Melbourne, Australia
- Posts
- 2,571
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
Alternatively, you can set the magic_quotes_gpc option in your php.ini file to 'Off'. This will prevent PHP from automatically adding those quotes, and will actually result in a small speed increase!
Kevin Yank
CTO, sitepoint.com
I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
Baby’s got back—a hard back, that is: The Ultimate CSS Reference
-
Nov 19, 2000, 09:04 #6
- Join Date
- Aug 2000
- Location
- N.S., Canada
- Posts
- 487
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I'm not the best at php so could you tell me where I have to put $data = stripslashes($data) in the following code to keep the slashes from showing up?
Code:<? include ("template.inc"); include ("config.php"); $summary_template = "t_summary.shtml"; $article_template = "t_article.shtml"; $max_summary = 20; function summary_page ($subject, $date, $summary, $article_id) { global $summary_template; $t = new Template(); $t->set_file("SummaryPage", $summary_template); $article_url = "article_".$article_id.".shtml"; $date = nl2br($date); $summary = nl2br($summary); $t->set_var( array( "subject" => $subject, "date" => $date, "summary" => $summary, "article_url" => $article_url )); $t->parse("Summary", "SummaryPage"); return $t->get_var("Summary"); } function main_page ($subject, $date, $summary, $article_id, $body) { global $article_template; $t = new Template(); $t->set_file("ArticlePage", $article_template); $article_url = "article_".$article_id.".shtml"; $date = nl2br($date); $summary = nl2br($summary); $body = nl2br($body); $t->set_var( array( "subject" => $subject, "date" => $date, "summary" => $summary, "body" => $body, "article_url" => $article_url )); $t->parse("Article", "ArticlePage"); return $t->get_var("Article"); } function add_article($filename, $news) { if(file_exists($filename)){ $fh = fopen($filename, "r"); $old_news = fread($fh, filesize($filename)); fclose($fh); } /* TODO: Multipage articles preg_match_all("<!--ARTICLE PAGE=(\d*)-->", $old_news, $matches; if( count($matches[0]) >= $max_summary){ $oldfilename = $filename.($matches[0][0]+1); } */ $fh = fopen($filename, "w"); fwrite($fh, "\n<!--ARTICLE-->\n$news $old_news"); fclose($fh); } ?> <? if(strcmp($subject, "")){ if(!(strcmp($passwd, $password))){ add_article("article_summary.shtml", summary_page($subject, $date, $summary, $article_id)); add_article("article_$article_id.shtml", main_page($subject, $date, $summary, $article_id, $body)); echo "<p> Article has been added! <p>"; }else{ echo "<p><b> Password is wrong! </b>"; } } ?> <form action=news.php method=post> <center><TABLE BGCOLOR="dedfdf" border="2" cellpadding="4"> <TR> <TD width="10000" colspan="3"><font size="4">Article Administration:</font></td></tr> <tr> <td> Password: </td><td colspan="2"> <input type=password name=passwd size=30> </td></tr> <tr> <td> Article File Name: </td><td colspan="2"> <input type=text name=article_id size=30> </td></tr> <tr> <td> Title: </td><td colspan="2"> <input type=text name=subject size=30> </td></tr> <tr> <td> Author: </td><td colspan="2"><input type=text name=date size=30></td></tr> <tr valign="top"> <td> Body: </td><td colspan="2"> <textarea name=body rows=15 cols=60></textarea> </td></tr> <tr valign="top"> <td> About the Author: </td><td colspan="2"> <textarea name=summary rows=5 cols=60></textarea> </td></tr> <tr> <td colspan="3"><center> <input type=submit name=submit value="Add Article To Database"></center></td><tr></table></center> </form>
I know pritty much no php
Thanks,
Justin Sampson
[Edited by W. Luke on 11-19-2000 at 10:14 AM]
-
Nov 19, 2000, 12:56 #7
- Join Date
- Aug 2000
- Location
- San Diego, CA
- Posts
- 5,460
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Somewhere in this function, above the following line($fh = fopen($filename, "w")
like I did here:
function add_article($filename, $news)
{
if(file_exists($filename)){
$fh = fopen($filename, "r");
$old_news = fread($fh, filesize($filename));
fclose($fh);
}
/* TODO: Multipage articles
preg_match_all("<!--ARTICLE PAGE=(\d*)-->", $old_news, $matches;
if( count($matches[0]) >= $max_summary){
$oldfilename = $filename.($matches[0][0]+1);
}
*/
$news = stripslashes($news);
$fh = fopen($filename, "w");
fwrite($fh, "\n<!--ARTICLE-->\n$news $old_news");
fclose($fh);
}
Please don't PM me with questions.
Use the forums, that is what they are here for.
-
Nov 19, 2000, 18:32 #8
- Join Date
- Aug 2000
- Location
- N.S., Canada
- Posts
- 487
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thank's so much for the help
It's works perfect! I don't know what I'd do with out all you guys!
Thanks,
Justin Sampson
Bookmarks