Updating database

I am having trouble getting this code to work not sure how to make it work.

if ($_POST[‘fform’] == ‘allocate’) {
$res = mysql_query(“select * from site where usrid=$usrid”);
for ($i = 0; $i < mysql_num_rows($res); $i++) {
$allocate = $allocate[$i];
$id = $id[$i];
$url = $url[$i];
if (is_numeric($allocate) && $allocate <= $credits && $allocate >= 0) {
$allocate = round($allocate, 1);
$res2 = mysql_query(“update site set credits=credits+$allocate where id=$id”);
$credits = $credits - $allocate; }
elseif (is_numeric($allocate) && $allocate >= 0) {
$credits = $credits - $allocate;
$res2 = mysql_query(“update site set credits=credits+$allocate where id=$id”); } }
$res = mysql_query(“update user set credits=$credits where id=$usrid”);
header("Location: ".$self_url.“members/?done&”.session_name() . “=” . session_id());
mysql_close;
exit;

The form that is being posted to the above is:

if ($credits > 1) { echo(“them”); }
else {echo(“it”);}
echo(" to the following site(s):

<form action=$self_url" . “members/ method=post>”);$res = mysql_query(“select id, url, credits from site where usrid=$usrid order by id asc”);
for ($i = 0; $i < mysql_num_rows($res); $i++) {
$id = mysql_result($res, $i, “id”);
$url = mysql_result($res, $i, “url”);
$scred = mysql_result($res, $i, “credits”);
$scred = round($scred, 2);
//hidden form filds
echo("");echo("");}echo("<form action=$self_url" . “members/ method=post>
URL Site credits Allocate
$url $scred
”);

Thanks For Any Help
Lee Qualls
http://www.leequalls.com

Okay, we’re not going to dig through your code, that’s not our job. What exactly is it supposed to do, what does it do that it shouldn’t, and what are your error messages (if any)?

Sorry I didnt explain. I am not getting an error code but the code is not working either. Basicly the form method is post and in the for loop it displays all the data for each user. When the form is submitted the allocate field is supposed to update the credits data in the database for each user where the id or url match from the form.

Thanks
Lee Qualls
http://www.leequalls.com

Try using error_reporting(E_ALL); or any of the other options in the debugging thread (to which my signature links) to give us some more information on what exactly is the problem with your script. Scripts that don’t work, nor give an error message sound fishy to me.

Sponsor our Newsletter | Privacy Policy | Terms of Service