PDA

View Full Version : PHP error!



thatsdjmk
08 Sep 2010, 10:45 PM
Hello i'm making a website and i'm new to sql so i get an error:
the website is http://aboutraveling.com and the code is:

<?

$story = $_GET['sid'];

// establish connection to the database containing the quotes.
$db = mysql_connect("localhost", "*****", "*****") or die ("Unable to connect to database.");
mysql_select_db("******") or die ("Unable to select database.");
// select the quotes that have not been displayed (q_mark = 0).


$author_id = mysql_query("SELECT author_id from travelstories WHERE story_id = $story");
$ts_username = mysql_query("SELECT username from community_users WHERE user_id = $author_id ");


while ($row = mysql_fetch_array($ts_username)) {
echo $row['username'];
}


?>

the error i get is:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/aboutra/public_html/travelstories_single.php on line 15

i'm trying for several hours to fix it but i cannot :(