Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Script puts slashes after posting form

Posted on 2002-03-19
16
Medium Priority
?
308 Views
Last Modified: 2010-05-18
Hello,

I have a php script (thanks to dkjariwala for help b4 ;) , that does what I want but it puts slashes/doesn't show some characters when you post.

Here is my sample page http://only.host.sk/sample_pk_list.html

Here is where you post to the list http://only.host.sk/sample_post_pk.html

Here is the script code http://only.host.sk/pklist_sk.txt

You can test out the page and post any kind of stuff you want to see what I mean.

Questions:

1) How do I prevent the slashes, fix missing symbols?

2) When I view the source, why is there suddenly huge gaps/spaces in the code, except for the new entries?

Thanks for you help.
0
Comment
Question by:sayhi
  • 8
  • 6
  • 2
16 Comments
 
LVL 5

Expert Comment

by:andriv
ID: 6881280
The links above do not work but I believe the symbols are missing because of the slashes.  You can remove the slashes by using the stripcslashes(text) function:

Example:

$mystring = 'This is a "string"';

stripcslashes($mystring);

2) may be solved with the above but since I cannot get to the links it's hard to determin what is causing it.

0
 
LVL 1

Author Comment

by:sayhi
ID: 6881503
doh the host went down
0
 
LVL 1

Author Comment

by:sayhi
ID: 6881506
erm, maintenance on the 19th, hopefully be back up tomorrow
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Expert Comment

by:dkjariwala
ID: 6881745
You would have to store the returned value of stripcslashes somewhere otherwise statements,

$mystring = 'This is a "string"';

stripcslashes($mystring);

Wont do *anything*.

Do it like

$mystring = 'This is a "string"';

$new_string = stripslashes($mystring);

Also, the link you gave is giving error so cant say much about second problem.

JD
0
 
LVL 5

Expert Comment

by:andriv
ID: 6881783
Not all true, you do not need to store it because you can use it in a query, use it when writing to a file or send it to the browser:

print(stripcslashes($mystring));

As long your using it immediately you do not need to store it in a variable.
0
 
LVL 5

Expert Comment

by:dkjariwala
ID: 6881885
Yeah but you didn't print it or used it any other way, and that was my point.

JD
0
 
LVL 1

Author Comment

by:sayhi
ID: 6884302
hi guys, too bad my host hasn't finished maintenance =\

well, if they don't come back up. here is where a form of my script is at http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=php&qid=20275170


for the slashes thing, say they put this in one of the boxes: "i don't know". on the list page it will post as "i don\'t know"


for the code gaps, you oughta see the list page to see what i mean. though the page shows up fine.


Also, on March 21st I'm gonna be going to Hawaii for my Spring Break =). So I'll be gone for a week, to let ya know.
0
 
LVL 5

Expert Comment

by:andriv
ID: 6884465
I don't know the exact functions and variables you are using in PHP but it will look similar to what follows:

fputs($myfile,stripcslashes($classtype)."<br>");

$myfile is the link you created for the actual file.

0
 
LVL 1

Author Comment

by:sayhi
ID: 6884507
ok, i'll see what I can do tonight before I pack my stuff
0
 
LVL 1

Author Comment

by:sayhi
ID: 6884664
okay guys, my host is backup, the links should work now... (i hope)
0
 
LVL 5

Expert Comment

by:andriv
ID: 6884702
Yes, you will need the stripcslashes($classtype):

foreach($lines_array as $line)
{
     fwrite($fp,stripcslashes($line) . $CRLF); //write original lines as it is.
     if(eregi('\<\!--data--\>',$line)) // if line stats its a place where data is stored
     {        
     fwrite($fp,"<table width=\"70%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">". $CRLF);
     fwrite($fp,"<tr><td>".$CRLF);  //write out new entry.
     fwrite($fp,"<font size=\"-1\" face=\"Verdana, Arial, Helvetica, sans-serif\">". $CRLF);
     fwrite($fp,"<b>Believed to be <font color=red>". "stripcslashes($danger) . "</font></b> <BR>" . $CRLF);
     fwrite($fp,"<b>Last seen on:</b>" . stripcslashes($lastseen) . "<BR>" . $CRLF);
     fwrite($fp,"<b>Name:</b>" . stripcslashes($pkname). "($pkacct) <BR>" . $CRLF);
     fwrite($fp,"<b>Level:</b>" . stripcslashes($pklvl) . "<BR>".$CRLF);  
     fwrite($fp,"<b>Class:</b>" . stripcslashes($classtype) . "<BR>".$CRLF);
     fwrite($fp,"<b>Explaination:</b>" . stripcslashes($explain) . "<BR>". $CRLF);
     fwrite($fp,"<font color=white><b>Submitted by: " . stripcslashes($myname) . "($myacct)</b></font><BR>" . $CRLF);
     fwrite($fp,"</font> <BR>" . $CRLF);
     fwrite($fp,"</td></tr></table> <BR>" . $CRLF);
     }

}
0
 
LVL 1

Author Comment

by:sayhi
ID: 6884716
hmm, didn't work
0
 
LVL 1

Author Comment

by:sayhi
ID: 6884721
oh yeah, when i view source now on the list page, there are now gigantic spaces in the code. wow
0
 
LVL 5

Expert Comment

by:andriv
ID: 6884736
To remove the spaces change the following line:

$CRLF = "\r\n"; //keep it "\r\n" if on unix/linux. original is "\n"

To:

$CRLF = "\n"; //keep it "\r\n" if on unix/linux. original is "\n"

remove the \r.

did it correct the slash problem?
0
 
LVL 5

Accepted Solution

by:
andriv earned 200 total points
ID: 6884743
I gave you the wrong function for striping the slashes, remove the 'c' from it.

stripslashes
0
 
LVL 1

Author Comment

by:sayhi
ID: 6885346
ah ha. thx.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question