Having a quick glance at the code, I believe your problem is a result of the fact that you failed to specify the "resource link identifier" in your mysql_query function calls.
PHP Code:
$result = mysql_query($sql);
should be:
PHP Code:
$result = mysql_query($sql,$con);
EDIT - I would also recommend echoing your SQL query as an HTML comment before you try to loop through the array. That way, if the SQL query does generate an error, you can try to look at the query to see if you can figure out what the error was.
If that doesn't help, then try replacing the "while" loop with an if statement. It would look something like:
PHP Code:
if($row = mysql_fetch_array($sql2,$con2)) {
echo "OK";
}
else {
echo mysql_error();
}
Finally, and I just noticed this, but I'm a little confused about your methodology. Why are you opening two separate connection threads to the same database? You should be able to use $con for both SQL queries.
EDIT AGAIN - One more thing, and this has no bearing on the error you're encountering, but it really is necessary when working with PHP and MySQL.
If you're going to send information to the database that you're getting from some sort of user interaction (any POST or GET variables, basically), you really need to escape those items properly before sending them.
PHP Code:
$i = $_GET['page_num'];
should be:
PHP Code:
$i = mysql_real_escape_string($_GET['page_num'],$con2);
Have a look at the
mysql_escape_string and
mysql_real_escape_string functions in PHP. They could save you a lot of headaches in the future, if anyone ever tries to hack your site.