PDA

View Full Version : no errors, connects, confirms, wont edit database


dredge
04-29-2004, 12:48 PM
I am building an administration page with many functions for my site. So far i have gotten everything to work pretty well and then when i put this as part of it, i can not get it to work no matter what i try.

I put in several pieces of coding to see if i can check and see if it works along the way and it does. but it just will not edit the database. i included the "config.php" further up above this in my coding to connect to the database.

What am I doing wrong? Will someone pleae hel me out?


if ($view == 'affcheck') {
$result = mysql_query("select * from affiliate");
while($out = mysql_fetch_array($result)) {
print "<table style='border-bottom:1px solid #4F5D69;' border=0 width=90% align=center><tr>";
print "<td width=40%><b>$out[name]</b></td>";
print "<td width=40%><a href=$out[addy]>$out[addy]</a></td>";
print "<td align=right width=10%>";
if ($out[check]=='N') {
print "<a href=admin.php?action=acceptaff&id=$out[id]&set=Y><img border=0 src='/images/notcheck.jpg'></a></td>";
} else {
print "<a href=admin.php?action=checkaff&id=$out[id]&set=N><img border=0 src='/images/check.jpg'></a></td>";
}
print "</tr><tr>";
print "<td><img src='$out[banner]'></td><td colspan=3 bgcolor=#4F5D69>$out[description]</td>";
print "</tr></table>";
}
}

if ($action == 'acceptaff') {
$getit = mysql_query("select * from affiliate where id='$id'");
$changeit = mysql_fetch_array($getit);
print "$action | $changeit[id] | $changeit[check]<br><br>";

if ($changeit[check] == 'N') {
mysql_query("update affiliate set check=Y where id=$changeit[id]");
} else {
mysql_query("update affiliate set check=N where id=$changeit[id]");
}

$getitagain = mysql_query("select * from affiliate where id='$id'");
$changeitagain = mysql_fetch_array($getitagain);

print "Changed $changeitagain[name]`s check value to $changeitagain[check]";

}

azlatin2000
04-29-2004, 03:02 PM
When you select an index out of an array in any programming language you must use quotes.

Ex.
Instead Of $changeitagain[name] It Is $changeitagain['name']

dredge
04-30-2004, 01:00 PM
hmm. wierd. it doesnt act like that on any of the other parts. but thanks. but then how come it shows the links and stuff, but just wont edit them?

dredge
04-30-2004, 01:04 PM
i did that and it came up with an error. it shows all the data just fine, but it wont change what i need to change when it comes to the database part. like this.

if ($changeit[check] == 'N') {
mysql_query("update affiliate set check=Y where id=$changeit[id]");
} else {
mysql_query("update affiliate set check=N where id=$changeit[id]");
}

azlatin2000
04-30-2004, 06:22 PM
if ($changeit['check'] == 'N') {
mysql_query("update affiliate set check='Y' where id='{$changeit['id']}'");
} else {
mysql_query("update affiliate set check='N' where id='{$changeit['id']}'");
}

You should really learn that such things as quotes exist, and if you don't know sql learn some.

dredge
05-01-2004, 08:18 AM
When i put the quotes around the id part it gave me an error. anytime i use quotes or single quotes inside the [] in arrays it gives me an error

azlatin2000
05-01-2004, 02:33 PM
Maybe giving us the error instead of just saying there is one?