ok, ive spent who knows how many hours trying to figure this out, but this script just wont update my database, it seems to "skip over" the red part:
<form action="<? echo $PHP_SELF ?>" method="post">
<?
mysql_connect("localhost","****","****"); //enter name and password
mysql_select_db("****"); //select the database
if(!$cmd)
{
$result = mysql_query("select * from aff"); //replace news with your table name
while($r=mysql_fetch_array($result))
{
$name=$r["name"]; // name
$id=$r["ID"]; //id
?>
<INPUT TYPE="RADIO" NAME="id" VALUE="<?php echo $id;?>"><? echo $id;?> <? echo $name ?>
<? } ?>
<input type="submit" name="cmd" value="edit"></form>
<? }
if($cmd=="edit")
{
if (!$submit)
{
mysql_connect("localhost","****","****"); //enter name and password
mysql_select_db("****"); //select the database
$sql = "SELECT * FROM aff WHERE ID=$id";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
?>
<form method="post" action="<? echo $PHP_SELF ?>">
<input type="hidden" name="shortname" value="<?php echo $myrow["short"] ?>">
<input type="hidden" name="id" value="<?php echo $myrow["ID"] ?>"> <?php echo "Affiliate number $id"; ?>
Site Name:<INPUT TYPE="TEXT" NAME="sname" VALUE="<?php echo $myrow["name"] ?>" SIZE=30>
Site URL:<INPUT TYPE="TEXT" NAME="surl" VALUE="<?php echo $myrow["url"] ?>" SIZE=30>
Site Short Name:<INPUT TYPE="TEXT" NAME="shortname" VALUE="<?php echo $myrow["short"] ?>" SIZE=30>
Button URL:<INPUT TYPE="TEXT" NAME="buttonurl" VALUE="<?php echo $myrow["button"] ?>" SIZE=30>
IN:<INPUT TYPE="TEXT" NAME="inn" VALUE="<?php echo $myrow["in"] ?>" SIZE=30>
OUT:<INPUT TYPE="TEXT" NAME="outt" VALUE="<?php echo $myrow["out"] ?>" SIZE=30>
<input type="hidden" name="cmd" value="edit">
<input type="Submit" name="submit" value="Post Comment">
</form>
<? }
if($submit)
{
mysql_connect("localhost","*****","*****"); //enter name and password
mysql_select_db("*****"); //select the database
$sql2 = "UPDATE aff SET name='$sname',url='$url',short='$shortname', button='$buttonurl',in='$inn',out='$outt' WHERE ID=$id";
$result = mysql_query($sql2);
echo "Thank you! Information updated.";
}
}
?>
i've tried every combo of quotations, commas, everything, but it just skips over that part. any suggestions?
|