Select previous/next nodes of same content type programmaticaly in Drupal 7
Clive is right. 
But $prev_nid is looking for the first node in the table.
So you could add an ORDER BY, like this:

$prev_nid = db_query("SELECT nid FROM {node} WHERE type = 'my_type' AND created &lt; :created ORDER BY created DESC LIMIT 1", array(':created' =&gt; $node-&gt;created))-&gt;fetchField();
$next_nid = db_query("SELECT nid FROM {node} WHERE type = 'my_type' AND created &gt; :created ORDER BY created LIMIT 1", array(':created' =&gt; $node-&gt;created))-&gt;fetchField();