Not updating table?

As the name says I’m trying to update/change values in tables but for some reason its not working.

Heres my form:

<?php $username = $_SESSION['name']; mysql_connect("localhost", "root", "*********************"); @mysql_select_db("accounts") or die( "Unable to select database"); $query = mysql_query ("SELECT * FROM skills WHERE playerName='".$username."'") or die(mysql_error()); $row = mysql_fetch_array($query); echo '<h1>Your Current Stats</h1> <form method="POST" action="resetSkillsFunction.php"> <span style="color:#FFFFFF;"> <b>Attack Lvl:XP - '.$row["Attacklvl"].':'.$row["Attackxp"].'</b> <input type="hidden" name="skill" value="Attack"/> <input type="submit" value="Reset Skill" name="submit"/> </span> </form> '; ?>

heres my function:

[code]<?php
$username = $_SESSION[‘name’];
$skill = $_POST[‘skill’].‘lvl’;
$skillxp = $_POST[‘skill’].‘xp’;
mysql_connect(“localhost”, “root”, “********************”);
@mysql_select_db(“accounts”) or die( “Unable to select database”);
$query = mysql_query (“SELECT * FROM skills WHERE playerName=’”.$username."’") or die(mysql_error());
echo $username.’ ‘.$skill . ’ ’ . $skillxp;
mysql_query("UPDATE skills SET ‘.$skill.’ = 1, ‘.$skillxp.’ = 0 WHERE playerName=’".$username."’");
mysql_close();

?>[/code]

The rows im updating are named Attacklvl and Attackxp in the database.

Assuming that’s all the code.

Your query is wrong. Should be
[php]
mysql_query(“UPDATE skills SET skill = ‘$skill’, skillxp = ‘$skillxp’ WHERE playerName= ‘$username’”);
[/php]

not really a serious problem, but since you’re dealing with just 1 record, you can use mysql_fetch_assoc();

Fix that query and it should work - provided you have an if statement looking for the submit button.

Sponsor our Newsletter | Privacy Policy | Terms of Service