<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="https://www.webmaster-forums.net/crss/node/1040929" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title></title>
    <link>https://www.webmaster-forums.net/crss/node/1040929</link>
    <description></description>
    <language>en</language>
          <item>
    <title>Excellent! Thanks for that</title>
    <link>https://www.webmaster-forums.net/web-database-development/if-statement-problem-php#comment-1229349</link>
    <description> &lt;p&gt;Excellent! Thanks for that both of you &lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/wink.png&quot; title=&quot;Wink&quot; alt=&quot;Wink&quot; class=&quot;smiley-content&quot; /&gt; I really will have to research and use PHP more because I&#039;m guessing that&#039;s a simple thing to do with PHP lol&lt;/p&gt;
 </description>
     <pubDate>Wed, 26 Mar 2008 20:52:04 +0000</pubDate>
 <dc:creator>drew22299</dc:creator>
 <guid isPermaLink="false">comment 1229349 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>Quote:

I don&#039;t even think</title>
    <link>https://www.webmaster-forums.net/web-database-development/if-statement-problem-php#comment-1229348</link>
    <description> &lt;blockquote class=&quot;bb-quote-body&quot;&gt;&lt;p&gt;Quote: I don&#039;t even think mysql_error() will show anything unless you make a syntax error in your queries.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;It will show other errors such as duplicate key fields, unknown columns, etc.  Still, should not be shown to the end user.&lt;/p&gt;
 </description>
     <pubDate>Wed, 26 Mar 2008 20:29:34 +0000</pubDate>
 <dc:creator>pr0gr4mm3r</dc:creator>
 <guid isPermaLink="false">comment 1229348 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>mysql_query() returns TRUE</title>
    <link>https://www.webmaster-forums.net/web-database-development/if-statement-problem-php#comment-1229347</link>
    <description> &lt;p&gt;mysql_query() returns TRUE (well, a resource, but it&#039;s still true) on all valid select queries even if the select query doesn&#039;t return any rows. So using that to test if a user name is already in use is no good. As long as the query syntax is correct, it returns true.&lt;/p&gt;
&lt;p&gt;You need to do something like&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt;$sql2 &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= \&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;SELECT COUNT(*) AS Cnt FROM `users` WHERE username=&#039;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$username&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;\&quot;;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$result2&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; = mysql_query(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$sql2&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$row&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; = mysql_fetch_assoc(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$result2&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$cnt&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; = &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$row&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;Cnt&#039;];&lt;br /&gt;&lt;br /&gt;if(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$cnt&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; &amp;gt; 0){&lt;br /&gt;...&lt;br /&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;br /&gt;
You run a query that counts how many rows contain that username. Fetch it and check if the fetched result row contains a cnt (short for count) that is greater than 0.&lt;/p&gt;
&lt;p&gt;Make sense?&lt;/p&gt;
&lt;p&gt;PS mysql_error() is not a very good message to show to your users &lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/smile.png&quot; title=&quot;Smiling&quot; alt=&quot;Smiling&quot; class=&quot;smiley-content&quot; /&gt;. I don&#039;t even think mysql_error() will show anything unless you make a syntax error in your queries.&lt;/p&gt;
 </description>
     <pubDate>Wed, 26 Mar 2008 19:57:19 +0000</pubDate>
 <dc:creator>teammatt3</dc:creator>
 <guid isPermaLink="false">comment 1229347 at https://www.webmaster-forums.net</guid>
  </item>
  </channel>
</rss>
