i'm trying to make a function that displays some sql results. It works fine outside the function, but not in it
This is the error:
Warning: mysql_db_query(): supplied argument is not a valid MySQL-Link resource in /usr/home/desbrina/public_html/users/view.php on line 7
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /usr/home/desbrina/public_html/users/view.php on line 10
user.php
<?php
include 'db_con.php';
include 'view.php';
echo "Will Trade: <br />";
willtrade();
?>
view.php
<?php
function willtrade() {
$sql = "SELECT *
FROM `user_inventory`
WHERE `name` = '".$_GET['user']."'
AND `status` = 'collecting'";
$result = mysql_db_query($db_name, $sql, $con);
if (!$result) { echo( mysql_error()); }
while ($row = mysql_fetch_array($result)) {
echo "Exists" ;
}
}
?>
whys it not working?