title: Got doomed with PHP Strings, any idea?
body: <p>I have a website which takes price from Steam Market. It is taking price by item's name. Then my javascript bot gets the information about item and process it to MySQL (while PHP file processing it to another table).</p>
  
  <p>So the problem is starting with it. Some items has string ' on names. And it causes my javascript bot to get bugged and crash. So far I have the code below.</p>
  
  <p>Is there any way to save it DB and send info to javascript bot with strings? Sorry. Maybe I am lack of logic.</p>
  
  <pre><code>    &lt;?php
  $item = $_GET['item'];
  $item = str_replace("\"", "", $item);
  $item = str_replace("\'", "", $item);
  $item = str_replace(" ", "%20", $item);
  $item = str_replace("\\", "", $item);
  @include_once ("set.php");
  $rs = mysql_query("SELECT * FROM items WHERE name='$item'");
  if(mysql_num_rows($rs) &gt; 0) {
      $row = mysql_fetch_array($rs);
      if(time()-$row["lastupdate"] &lt; 604800) die($row["cost"]);
  }
  $link = "http://steamcommunity.com/market/priceoverview/?currency=1&amp;appid=730&amp;market_hash_name=".$item;
  $string = file_get_contents($link);
  $obj = json_decode($string);
  if($obj-&gt;{'success'} == "0") die("notfound");
  $lowest_price = $obj-&gt;{'lowest_price'};
  for($i = 5; $i &lt; strlen($lowest_price); $i++) {
      $lowest_price[$i-5] = $lowest_price[$i];
  }
  $lowest_price[strlen($lowest_price)] = 0;
  $lowest_price = (float)($lowest_price);
  mysql_query("DELETE FROM items WHERE name='$item'");
  mysql_query("INSERT INTO items (`name`,`cost`,`lastupdate`) VALUES ('$item','$lowest_price','".time()."')");
  echo $lowest_price;
  ?&gt;
  </code></pre>