I can not use str_replace for the word "wget "

Discussion in 'PHP' started by baris22, Nov 24, 2007.

  1. #1
    I have got a stupid problem. it took 2 days find out and i can not solve it now.

    When i try to insert the "wget " into the database it does not work. (there is space after wget)

    I get this error:

    Service Temporarily Unavailable
    The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.


    I am trying to replace it using str_replace. it does not work either.

    $to_replace = array("\r\n","|","wget ","\n","\\r\\n","\\n");
    			  $title = str_replace($to_replace, " ", $title);
    			  $description = str_replace($to_replace, " ", $description);
    PHP:
    i do not know whatto do
     
    baris22, Nov 24, 2007 IP
  2. drunnells

    drunnells Peon

    Messages:
    79
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I tried passing these values through your code:

    $title = "this is the word 'wget '.\n";
    $description = "this is the word 'wget '.\n";

    And the results were:

    $title: this is the word ' '.
    $description: this is the word ' '.

    This would seem to be the expected behavior because your replace string is " ".. you did not want to replace "wget " with just a space?
     
    drunnells, Nov 24, 2007 IP
  3. baris22

    baris22 Active Member

    Messages:
    543
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #3
    I changed the code to

    <?php 
    $con = mysql_connect("localhost","user","pass"); 
    if (!$con) 
      { 
      die('Could not connect: ' . mysql_error()); 
      }mysql_select_db("database name", $con); 
       
      $title=$_POST['title']; 
      $description=$_POST['description']; 
       
      $title = str_replace("wget", "ddd", $title); 
      $description = str_replace("wget", "ddd", $description); 
       
      $query="INSERT INTO `filedetails` VALUES ('', '', '".$title."', '".$description."', '','0000000000')"; 
     mysql_query($query); 
     echo 'MYSQL ERROR IS: '.mysql_error(); 
     mysql_close($con) 
    ?>  
    <html> 
    <body> 
    <form action="insert.php" method="post"> 
    title:<input name="title" type="text" size="100" /> 
    <br> 
    desc:<textarea name="description" cols="150" rows="10"></textarea> 
    <br> 
    <input type="submit" /> 
    </form> 
    </body> 
    </html> 
    PHP:
    but same problem.If i try to insert "wget" it works. It changes to "ddd" but when i try "wget " i get this error

    Service Temporarily Unavailable
    The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
     
    baris22, Nov 25, 2007 IP
  4. PowerExtreme

    PowerExtreme Banned

    Messages:
    2,118
    Likes Received:
    75
    Best Answers:
    0
    Trophy Points:
    0
    #4
    i could be a host problem aswell
     
    PowerExtreme, Nov 25, 2007 IP
  5. baris22

    baris22 Active Member

    Messages:
    543
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #5
    I think so. I am just going to give up.
     
    baris22, Nov 25, 2007 IP
  6. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #6
    Don't give up. Email your hosting's support about it. Perhaps they can help you.
     
    nico_swd, Nov 25, 2007 IP
  7. mindphp

    mindphp Well-Known Member

    Messages:
    88
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    121
    #7
    i could be a host problem aswell too
    what is Your OS ?
     
    mindphp, Nov 25, 2007 IP