I have been trying to create a form that updates to my database but... when I click "update" just says could not connect !!! WHY??? I know it hasn't updated because when I go on to my database nothing has changed... :-( .
<html>
<head>
<title></title>
</head>
<body>
<?php
if(isset($_POST['update'])) {
$dbhost = 'localhost';
$dbuser = '***';
$dbpass = '******';
$conn = mysqli_connect($dbhost, $dbuser, $dbpass);
if(! $conn ) {
die('Could not connect: ' . mysqli_error());
}
$Userid = $_POST['UserID'];
$TableID = $_POST['tableID'];
$Life_points = $_POST['Life_points'];
$xp_points = $_POST['xp_points'];
$sql = "UPDATE points"." SET TableID = $TableID". "WHERE UserID= $UserID"."WHERE life_points= $Life_points"."WHERE xp_points= $xp_points" ;
mysqli_select_db('womath');
$retval = mysqli_query( $sql, $conn );
if(! $retval ) {
die('Could not update data: ' . mysqli_error());
}
echo "Updated data successfully
";
mysqli_close($conn);
}
else {
?>
<form method = "post" action = "<?php $_PHP_SELF ?>">
<table width = "400" border =" 0" cellspacing = "1"
cellpadding = "2">
<tr>
<td width = "100">UserID</td>
<td><input name = "UserID" type = "int"
id = "UserID"></td>
</tr>
<tr>
<td width = "100">TableID</td>
<td><input name = "TableID" type = "int"
id = "TableID"></td>
</tr>
<tr>
<td width = "100">life_points</td>
<td><input name = "life_points" type = "int"
id = "life_points"></td>
</tr>
<tr>
<td width = "100">xp_points</td>
<td><input name = "xp_points" type = "int"
id = "xp_points"></td>
</tr>
<tr>
<td width = "100"> </td>
<td> </td>
</tr>
<tr>
<td width = "100"> </td>
<td>
<input name = "update" type = "submit"
id = "update" value = "Update">
</td>
</tr>
</table>
</form>
<?php
}
?>
</body>
</html>