PHP intval() weird results
<p>I'm encountering something weird and I don't know why it is happening!</p>

<p>I have a URL like:</p>

<p><a href="http://mysite.com/users/" rel="nofollow">http://mysite.com/users/</a><code>USER_ID</code></p>

<p>this user id could be <code>INT</code> and could be <code>STRING</code>, it's something like Facebook page addresses, if you call the page with page ID it loads it, also you could call it with page name like "my_page_name"</p>

<p>So imagine a user which it's ID is <code>1</code> and it's address is <code>my_name</code>
On my php page I need query db, but before that I need to know which column to look, <code>id</code> or <code>page_name</code></p>

<p>So I came with this solution:</p>

<pre><code>&lt;?php
    $id = $_GET['id'];
    $id_inted = intval($_GET['id']);

    if($id == $id_inted){
    // The column which I should look into is id
    $column = 'id';
    }else{
    // The column which I should look into is page_name
    $column = 'page_name';
    }

    $query = mysql_qyery(SELECT * FROM members WHERE $column = '$id');
?&gt;
</code></pre>

<p>So I tested it, but the results is weird, even if I call this URL:</p>

<p><a href="http://mysite.com/users/" rel="nofollow">http://mysite.com/users/</a><code>page_name</code></p>

<p>This happens: <code>$column = 'id';</code></p>

<p>I opened a new test page:</p>

<pre><code>&lt;?php
$real_string = 'abcdefg';
$string_inted = intval($real_string);
echo "Real String is: " . $real_string . "&lt;br /&gt;"; 
echo "The same string as int is: " . $string_inted . "&lt;br /&gt;"; 
if($real_string == $string_inted) echo "Weird!"; else echo "Fine...";
?&gt;
</code></pre>

<p>and the results:</p>

<pre><code>Real String is: abcdefg
The same string as int is: 0
Weird!
</code></pre>

<p>Why this is happening?</p>

<p>Thanks in advance.</p>
