I am having no issue running a select statement but I keep having issues running this update statement, even without where criteria being specified. I have tried everything from defining the sql statement with single quotes, concatenation, calling the sql statement via mysqli and etc but I don't get any error messages that let me know what the actual problem is. The login user has privileges to select, update, and insert so as to separate from the root user and autocommit has been turned off via mysqlworkbench. The html of course is a one page app that submits the form to itself with a select element named p_game, with one of the options being Game A.
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
echo 'Posted.';
if ( !empty($_POST['p_game'])) {
echo 'Got here';
$p_game = $conn->real_escape_string(trim($_POST['p_game']));
$sql = "UPDATE db_name.football_games set home_score = 50, away_score = 100 where name = ''$p_game''";
try{
$result = $conn->query($sql);
echo $sql;
$conn->commit();
echo 'Commit worked.';
}
catch(Exception $e) {
echo $e->getMessage();
}
}
else {
echo 'Game name not found';
}
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire