PHP Ajax Request Returns a 503

Discussion in 'Software' started by Godspeed phi, Mar 29, 2009.

  1. Godspeed phi

    Godspeed phi Private E-2

    Hello All,

    I have an ajax request (using MooTools) that sends some fields for a blog post. One of the fields is 'body.'

    Everything has been fine, until now. I was trying to draft a post about opening files in PHP. In the text area I wrote the following:

    $handle = opendir('.');
    while(false !== ($file = readdir($handle))) {
    fopen($file, 'r');
    }
    closedir($handle);

    When I hit submit the POST variable 'body' equals

    $handle = opendir('.');<br />while(false !== ($file = readdir($handle))) {<br />&nbsp;&nbsp;&nbsp; fopen($file, 'r');<br />}<br />closedir($handle);

    The page receiving this POST returns an error 503 - Service Temporarily Unavailable.

    I'm guessing it's executing the code rather than taking it as a string.

    How do I send it to the other page without throwing this error?
     
  2. PC-XT

    PC-XT Master Sergeant

    Perhaps you could wrap it in double quotes, after replacing any existing double quotes by '\"' (and perhaps other characters via addslashes). Then if the page finds double quotes at the ends, it strips them, and then takes the backslashes out again, (perhaps via stripslashes.)
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds