str_replace
<pre><code>$tag = mysql_real_escape_string($_GET['tag']);
$tag = str_replace("-", " ", $_GET['tag']);

$query = mysql_query("SELECT * FROM tags WHERE name = '$tag'");
$row = mysql_fetch_assoc($query);

if (!mysql_num_rows($query)) exit('That tag dont exist.');
</code></pre>

<p>I have a tag with spaces in its name, how should i do to replace the spaces with hyphens?
I think the above code should work but it doesnt :/</p>

<p><b>Update:</b></p>

<pre><code>$tag = str_replace(' ', '-', $_GET['tag']);
$tag = mysql_real_escape_string($tag);

$query = mysql_query("SELECT * FROM tags WHERE name = '$tag'");
$row = mysql_fetch_assoc($query);

if (!mysql_num_rows($query)) exit('That tag dont exist');
</code></pre>

<p><b>Db tags</b></p>

<pre><code>`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(40) COLLATE utf8_unicode_ci DEFAULT NULL



INSERT INTO `tags` (`id`, `name`) VALUES
(1, 'test'),
(2, 'test test'),
(3, 'test test test test');
</code></pre>
