Updating Issues
OK, this is going to drive me nuts. I'm trying to update a table containing 82 odd variables. It will not, however, update at all. I'm using the following in all effect, just on a much larger scale.
Variables
cname (unique)
ctype
Code - Update Page
~connection and variable grabbing~
[form method=post action="update.php"]
[input type=hidden name="ud_cname" value=" echo "$cname"; ?>"]
[input type=text name="ud_ctype" value=" echo "$ctype"; ?>"]
[input type=submit]
[/form]
Note: This all picks up fine, as far as I can see, so I assume the issue is with the insertion code
Code - Insertion Page
$ud_cname=$_POST['ud_cname'];
$ud_ctype=$_POST['ud_ctype'];
$username="*******";
$password="*******";
$database="********";
mysql_connect(localhost,$username,$password);
$query=" UPDATE characters WHERE cname='$ud_cname' SET ctype='$ud_ctype' ";
mysql_query($query);
echo "Record Updated";
mysql_close();
This code was effectively taken from http://www.freewebmasterhelp.com/tutorials/phpmysql/ which has been damn helpful in the past. I did note that in the tutorial, however, they have, in the update, two "value" listed per variable, one of which replaces the name. I think this is a mistake, but if it is not, then could someone correct me? Thanks :)
EDIT: Found the error... I wasn't selecting a databse... Yes, I am that much of a newbie sometimes ^_^ thanks to all nonetheless however, as it now works perfectly after following all suggestions
Variables
cname (unique)
ctype
Code - Update Page
~connection and variable grabbing~
[form method=post action="update.php"]
[input type=hidden name="ud_cname" value=" echo "$cname"; ?>"]
[input type=text name="ud_ctype" value=" echo "$ctype"; ?>"]
[input type=submit]
[/form]
Note: This all picks up fine, as far as I can see, so I assume the issue is with the insertion code
Code - Insertion Page
$ud_cname=$_POST['ud_cname'];
$ud_ctype=$_POST['ud_ctype'];
$username="*******";
$password="*******";
$database="********";
mysql_connect(localhost,$username,$password);
$query=" UPDATE characters WHERE cname='$ud_cname' SET ctype='$ud_ctype' ";
mysql_query($query);
echo "Record Updated";
mysql_close();
This code was effectively taken from http://www.freewebmasterhelp.com/tutorials/phpmysql/ which has been damn helpful in the past. I did note that in the tutorial, however, they have, in the update, two "value" listed per variable, one of which replaces the name. I think this is a mistake, but if it is not, then could someone correct me? Thanks :)
EDIT: Found the error... I wasn't selecting a databse... Yes, I am that much of a newbie sometimes ^_^ thanks to all nonetheless however, as it now works perfectly after following all suggestions
