Query not returning results

I cant get the query to give me results

[php]

<?php $hostname="myelstonfamily.db.######.hostedresource.com"; $dbuser="myelstonfamily"; $pass="password"; $link = mysql_connect($hostname,$dbuser, $pass); $db_selected = mysql_select_db('myelstonfamily', $link)or die ('Can\'t use foo : ' . mysql_error()); $result = mysql_query("SELECT total FROM Reunion WHERE username = '.$_SESSION[username].'"); echo "Your total is:"; echo $result['total']; ?>

[/php]

I think you need to fetch the $total variable:

[php]<?php

$username = $_session[‘username’]; //What’s this session variable previously defined?

$hostname=“myelstonfamily.db.######.hostedresource.com”;
$dbuser=“myelstonfamily”;
$pass=“password”;
$link = mysql_connect($hostname,$dbuser, $pass);
$db_selected = mysql_select_db(‘myelstonfamily’, $link)or die ('Can’t use foo : ’ . mysql_error());
$result = mysql_query(“SELECT total FROM Reunion WHERE username = ‘.$_SESSION[username].’”);

while ($row = mysql_fetch_assoc($result)) {

$total = $row[‘total’];

echo "Your total is: " . " ". $total . “”; //total amound displayed in bold.

}

Also, make sure your session variable is defined some where in your page.

?>[/php]

See if this works for you. You may or may not need to get rid of the Session variable I defined for you at the top, depending on whether this was an issue for you.

Sponsor our Newsletter | Privacy Policy | Terms of Service