slickdeals Posted April 20, 2009 Share Posted April 20, 2009 whats causing this error for me? its on line 636 and 670 which I assume is while($row1 = mysql_fetch_assoc($get1)) { and while($row = mysql_fetch_assoc($get)) { but why? function admin_ratesite() { echo "<center>"; $get = mysql_query("SELECT url as surl, siterating as srating FROM wlddl_sites"); if(isset($_REQUEST['ratesite'])){ $rating = $_POST['srating']; $siteurl = $_POST['surl']; } echo '<b>Rate Site</b><br /><br />'; echo '<form action="" method="post">'; echo '<b>Site:</b> '; echo '<select name="surl" size="1">'; echo '<option value="">- Select -</option>'; while($row = mysql_fetch_assoc($get)) { echo '<option value="'.$row['surl'].'">'.$row['surl'].'</option>'; } echo '</select>'; echo ' <b>Rating:</b> '; echo '<select name="srating" size="1">'; echo '<option value="">- Select -</option>'; for($i=1;$i<=5;$i++) {$return = '<option value="'.$i.'">'.$i.'</option>'; echo $return;} echo '</select>'; echo '<br /><br /><input type="submit" value="Rate Site!" name="ratesite" />'; echo '</form>'; if(isset($_REQUEST['ratesite'])){ if(!$siteurl){ echo "<br /><b>Error: Invalid Site</b>"; } else if(!$rating) { echo "<br /><b>Error: Invalid Rating</b>"; } else { mysql_query("UPDATE wlddl_sites SET siterating = '".mysql_real_escape_string($rating)."' WHERE url = '".mysql_real_escape_string($siteurl)."'"); echo '<br /><b>'.$siteurl.' Has Successfully Been Rated!</b>'; } } echo '<br /><hr /><br />'; // Check Site Rating $get1 = mysql_query("SELECT url as surl, siterating as srating FROM wlddl_sites"); if(isset($_REQUEST['checksrating'])){ $siteurl = $_POST['surl']; $currentsrating = mysql_query("SELECT siterating, url FROM wlddl_sites WHERE url = '".mysql_real_escape_string($siteurl)."'"); } echo '<b>Check Site Rating</b><br /><br />'; echo '<form action="" method="post">'; echo '<b>Site:</b> '; echo '<select name="surl" size="1">'; while($row1 = mysql_fetch_assoc($get1)) { echo '<option value="'.$row1['surl'].'">'.$row1['surl'].'</option>'; } echo '</select>'; echo '<br /><br /><input type="submit" value="Check Site Rating" name="checksrating" />'; echo '</form>'; if(isset($_REQUEST['checksrating'])){ while($row2 = mysql_fetch_assoc($currentsrating)) { echo "<br /><b>Site Rating For ".$row2['url'].":</b> ".$row2['siterating']; } } echo "</center>"; } Quote Link to comment Share on other sites More sharing options...
teynon Posted April 20, 2009 Share Posted April 20, 2009 $get = mysql_query("SELECT url as surl, siterating as srating FROM wlddl_sites") or die(mysql_error()); Post the error it outputs or if it doesn't. Quote Link to comment Share on other sites More sharing options...
alphanumetrix Posted April 20, 2009 Share Posted April 20, 2009 He showed the error: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource It seems to me that you aren't connecting to the database with a valid connection. I don't know for sure, because I don't code like you are, but you should probably turn your database connection into a variable, if you haven't already. As so: $link = mysql_connect($host,$user,$pass) or die('Database Error: ' . mysql_error()); Then rewrite your mysql_query functions to connect directly, as so: mysql_query("SELECT url as surl, siterating as srating FROM wlddl_sites", $link); Also, remember, if you don't create the $link variable directly in the function, you'll have to make the variable a global within the function, as so: function admin_ratesite() { global $link; Again, I'm not sure, because your coding style is a little weird to me. This is just something to try. Quote Link to comment Share on other sites More sharing options...
slickdeals Posted April 20, 2009 Author Share Posted April 20, 2009 thanks that helped me with my spelling lol as it is wcddl not wlddl thanks again for your quick help Quote Link to comment Share on other sites More sharing options...
teynon Posted April 20, 2009 Share Posted April 20, 2009 Really? I know he posted the error. I'm having him output the MYSQL QUERY ERROR. If the Mysql QUERY fails, the fetch will also fail. Mmmk, thanks. Which apparently fixed his problem. Quote Link to comment Share on other sites More sharing options...
alphanumetrix Posted April 20, 2009 Share Posted April 20, 2009 sorry about that. read it too fast to see. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.