Guest_imported
New member
- Jan 1, 1970
- 0
Hi can anyone see what's wrong with the script below. I thought it used to work but I guess not. The variables $rate and $id are sent from a form and then the script below detects whether the user is logged in. If so it then carries out the relevant coding. The problem is that when the database is updated it doesn't update the correct information.
If anyone could help, i'd be greatful. Thanx
<?php
require("../config.inc.php"
$pagetitle = "New Found Punk - Band Database - Rate Tab";
require("../style.php"
$db = mysql_connect($host,$login,$pass);
mysql_select_db($base,$db);
if($xmbuser) {
$sql = "UPDATE tabs_tbl set nbr_votes = nbr_votes+1 where id = $id";
$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
$sql = "UPDATE tabs_tbl set vote_tot = vote_tot+'.$rate.' where id = $id";
$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
$sql = "SELECT id,vote_avg,vote_tot,nbr_votes FROM tabs_tbl where id = $id";
$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
while($data = mysql_fetch_array($req))
$vote_avg = round($data['vote_tot']/$data['nbr_votes'],3);
$sql = "UPDATE tabs_tbl set vote_avg = '.$vote_avg.' where id = $id";
$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
{
echo '<table border="0" width="100%" cellspacing="0" cellpadding="0" height="100%"><tr><td width="100%" valign="middle" align="center"><font face="Verdana" size="2">Thankyou for your vote. Click <a href="javascript: window.close();">here</a> to close this window</font></td></tr></table>';
exit;
}
} else {
echo '<table border="0" width="100%" cellspacing="0" cellpadding="0" height="100%"><tr><td width="100%" valign="middle" align="center"><font face="Verdana" size="2">You\'re not a registered member of the site. Click <a href="javascript: window.close();">here</a> to close this window</font></td></tr></table>';
exit;
}
mysql_close($db);
?>
If anyone could help, i'd be greatful. Thanx
<?php
require("../config.inc.php"
$pagetitle = "New Found Punk - Band Database - Rate Tab";
require("../style.php"
$db = mysql_connect($host,$login,$pass);
mysql_select_db($base,$db);
if($xmbuser) {
$sql = "UPDATE tabs_tbl set nbr_votes = nbr_votes+1 where id = $id";
$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
$sql = "UPDATE tabs_tbl set vote_tot = vote_tot+'.$rate.' where id = $id";
$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
$sql = "SELECT id,vote_avg,vote_tot,nbr_votes FROM tabs_tbl where id = $id";
$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
while($data = mysql_fetch_array($req))
$vote_avg = round($data['vote_tot']/$data['nbr_votes'],3);
$sql = "UPDATE tabs_tbl set vote_avg = '.$vote_avg.' where id = $id";
$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
{
echo '<table border="0" width="100%" cellspacing="0" cellpadding="0" height="100%"><tr><td width="100%" valign="middle" align="center"><font face="Verdana" size="2">Thankyou for your vote. Click <a href="javascript: window.close();">here</a> to close this window</font></td></tr></table>';
exit;
}
} else {
echo '<table border="0" width="100%" cellspacing="0" cellpadding="0" height="100%"><tr><td width="100%" valign="middle" align="center"><font face="Verdana" size="2">You\'re not a registered member of the site. Click <a href="javascript: window.close();">here</a> to close this window</font></td></tr></table>';
exit;
}
mysql_close($db);
?>