<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="https://www.webmaster-forums.net/crss/node/1040053" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title></title>
    <link>https://www.webmaster-forums.net/crss/node/1040053</link>
    <description></description>
    <language>en</language>
          <item>
    <title></title>
    <link>https://www.webmaster-forums.net/server-side-scripting/mysql-result-and-mysql-fetch-assoc-method#comment-1226215</link>
    <description> &lt;blockquote class=&quot;bb-quote-body&quot;&gt;&lt;p&gt;Quote: It&#039;s constantly running the same query over and over, without an end. You need to get the result from a mysql_query call and pass it to something like mysql_fetch_assoc().&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Yeah, that makes sense. I thought because I returned the results of mysql_fetch_assoc it would use that, but each time through the loop it re-runs the query, producing the exact same associative array each time. Got it.&lt;/p&gt;
&lt;blockquote class=&quot;bb-quote-body&quot;&gt;&lt;p&gt;Quote: I can post actual code of what I am talking about once I get it written.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;I&#039;d like that, because I really don&#039;t know what I&#039;m doing &lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/big.png&quot; title=&quot;Laughing out loud&quot; alt=&quot;Laughing out loud&quot; class=&quot;smiley-content&quot; /&gt;&lt;/p&gt;
 </description>
     <pubDate>Fri, 09 Nov 2007 15:47:19 +0000</pubDate>
 <dc:creator>teammatt3</dc:creator>
 <guid isPermaLink="false">comment 1226215 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/server-side-scripting/mysql-result-and-mysql-fetch-assoc-method#comment-1226088</link>
    <description> &lt;p&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;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;while(&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: #0000BB&quot;&gt;$db&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;query&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(\&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;SELECT * FROM User WHERE UserID = 9 OR UserID = 4\&quot;))&lt;br /&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;br /&gt;
The problem is in this line. Look at it closely and think what it&#039;s doing (it might help to cross your legs and make Yoga-like Ommmmmmmm noises at this point).&lt;/p&gt;
&lt;p&gt;It&#039;s constantly running the same query over and over, without an end. You need to get the result from a &lt;a href=&quot;http://www.php.net/manual/en/function.mysql-query.php&quot; class=&quot;bb-url&quot;&gt;mysql_query&lt;/a&gt; call and pass it to something like &lt;a href=&quot;http://www.php.net/manual/en/function.mysql-fetch-assoc.php&quot; class=&quot;bb-url&quot;&gt;mysql_fetch_assoc()&lt;/a&gt;. &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;&lt;/p&gt;
&lt;blockquote class=&quot;bb-quote-body&quot;&gt;&lt;p&gt;&lt;strong&gt;Matt wrote:&lt;/strong&gt; Any ideas of what else should go in a DB object? I should look through some CMSs and see what they do...&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Being a Drupal fan-boy I&#039;ll point you at their solution, they have a &lt;a href=&quot;http://api.drupal.org/api/group/database/6&quot; class=&quot;bb-url&quot;&gt;thin database abstraction layer&lt;/a&gt; (it&#039;s not done with objects, but it is object orientated-ish).&lt;/p&gt;
 </description>
     <pubDate>Tue, 06 Nov 2007 19:13:17 +0000</pubDate>
 <dc:creator>JeevesBond</dc:creator>
 <guid isPermaLink="false">comment 1226088 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/server-side-scripting/mysql-result-and-mysql-fetch-assoc-method#comment-1226085</link>
    <description> &lt;p&gt;I&#039;ve been working on something like this as well.  I&#039;ve been working on it as a side note, so I haven&#039;t gotten that far.&lt;/p&gt;
&lt;p&gt;I figure to have one class per table in a database and have each table class inherit a main database class.  The main database class can handle global stuff like connections and also methods for raw queries and such.  The table can have more table-specific methods.  For example, if I have a table of registered site users, I would have table methods like AddUser(), RemoveUser(), changePassword(), etc.  My goal is to completely remove raw SQL queries from my main code.  Replacing raw queries with custom methods like that allows you to tweak your SQL queries for the whole website and even make it relatively easy to migrate to a different SQL database system like PrestegeSQL or something similar if needed.&lt;/p&gt;
&lt;p&gt;I can post actual code of what I am talking about once I get it written.&lt;/p&gt;
 </description>
     <pubDate>Tue, 06 Nov 2007 18:42:19 +0000</pubDate>
 <dc:creator>pr0gr4mm3r</dc:creator>
 <guid isPermaLink="false">comment 1226085 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/server-side-scripting/mysql-result-and-mysql-fetch-assoc-method#comment-1226081</link>
    <description> &lt;p&gt;Yeah, realized that. For example what if the query is just an update query and I don&#039;t need to fetch anything? When I was testing I was just running select queries, I didn&#039;t even think about updating, inserting or deleting.&lt;/p&gt;
&lt;p&gt;Any ideas of what else should go in a DB object? I should look through some CMSs and see what they do...&lt;/p&gt;
&lt;p&gt;I probably need a result counter with mysql_num_rows and one for mysql_affected_rows too.&lt;/p&gt;
 </description>
     <pubDate>Tue, 06 Nov 2007 15:18:18 +0000</pubDate>
 <dc:creator>teammatt3</dc:creator>
 <guid isPermaLink="false">comment 1226081 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/server-side-scripting/mysql-result-and-mysql-fetch-assoc-method#comment-1226067</link>
    <description> &lt;p&gt;IMO, your logic is not correct. You are currently repeatedly calling the function to run the query.&lt;/p&gt;
&lt;p&gt;I think you require three functions:&lt;/p&gt;
&lt;p&gt;1) Connect - this is ok&lt;/p&gt;
&lt;p&gt;2) Query - Just to run the query&lt;/p&gt;
&lt;p&gt;3) Fetch - To return the results.&lt;/p&gt;
&lt;p&gt;Connect and Query should be run once before the while loop.&lt;/p&gt;
&lt;p&gt;Fetch should be run as the while condition.&lt;/p&gt;
 </description>
     <pubDate>Tue, 06 Nov 2007 11:31:44 +0000</pubDate>
 <dc:creator>kaykays</dc:creator>
 <guid isPermaLink="false">comment 1226067 at https://www.webmaster-forums.net</guid>
  </item>
  </channel>
</rss>
