Hi, I'm a newbie and am having a problem with either my where clause in my sql statement or something else, I think its the where because if I take that out the script works fine...
Here is the error I get:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Inetpub\wwwroot\NewBeginnings\jobsOutput.php on line 12
Here is the code:

<?php  include 'inc/dbconnOpen.php';
ini_set('error_reporting', E_ALL);
ini_set('display_errors', true);

 $sql = "SELECT * FROM `textads` WHERE `expos` GREATER THAN `xCount` ORDER BY RAND() LIMIT 3"; 
$result = mysql_query($sql);

echo "<b><center>Database Output</center></b><br><br>
<table border= 1 height=90px width=468px bgcolor=#cccccc>
<tr>";

while ($row = mysql_fetch_array($result)) {
    echo "
    <td>{$row['title']}<br>{$row['blurb']}<br>
    <A HREF='{$row['href']}'>{$row['href']}</a></td>";
    //Add to exposure count
    $views = $row['xCount'] + 1;
    mysql_query("UPDATE `textads` SET `xCount` = '{$views}' WHERE `ID` = '{$row['ID']}'");
}

echo " </tr>
</table>"; 

/* $num=mysql_num_rows($result);

mysql_close();

echo "<b><center>Database Output</center></b><br><br>";

$i=0;
while ($i < $num) {

$href=mysql_result($result,$i,"href");
$blurb=mysql_result($result,$i,"blurb");
$title=mysql_result($result,$i,"title");

   
echo "<table border= 1 height=90px width=468px bgcolor=#0066CC><tr><td>$title<br>$blurb<br>
<A HREF='$href'>$href</a></td><td>$title<br>$blurb<br>
<A HREF='$href'>$href</a></td><td>$title<br>$blurb<br>
<A HREF='$href'>$href</a></td></tr></table>";

$i++; */

/* }?> */
Comments
Nice to see person using code tags on very first post. Thank you!

Just use > instead of GREATER THAN. Since xCount is numeric, you also won't need quotes around it. So I think:

$sql = "SELECT * FROM `textads` WHERE `expos` > xCount ORDER BY RAND() LIMIT 3";

should work.

Ok, the error says that no result has been returned from sql. This may be caused either by no data in tables or by a wrong sql statement.
I suggest you to put this line just after $result=mysql_query($sql);

if (!$result)
  {
die mysql_error();
  }

If this does not return an error, then your tables are empty, or your sql is valid, but returns no records.
I think that you need to revise your sql statement though.
I don't really get the idea of this statement

SELECT * FROM `textads` WHERE `expos` GREATER THAN `xCount` ORDER BY RAND() LIMIT 3

First of all, I would remove the useless quotes around the column names and table name.
Then - greater than, you can just use '>' sign.
Next, what do you mean by setting an ordering which uses RAND() function - you want to randomize your results or what?
And last - LIMIT 3 - the limit clause normally should be used like
Limit "# of records to omit, # of records to return". So if you want to see only the first 3 records only, LIMIT 0,3 should be used instead.

This question has already been answered. Start a new discussion instead.