php - mySQL insert just won't work, but will with other table -
this question has answer here:
i have mysql issue has me stumped hours!
context: creating web-application teach children different musical symbols on touch devices
problem: after running individual script, no row created although last echo argument works.
wierd: modeled after other scripts have working.
edit: re-furnish code prepared statements after find problem.
here code:
<?php $database_connect = mysql_connect('localhost','ragstudi','*****'); if (!$database_connect) {die ('not connected sql' . mysql_error());}; mysql_select_db('ragstudi_musicgamescores') or die ('db doesnt exist'); $username = "jimmy";//$_post["username"]; $gamelevel = 1;//$_post["level"]; $gamescore = 2300;//$_post["score"]; $usergroup = "ragwway"; $highscores = mysql_query("insert highscores (name, groupby, level, score) values('".$username."','".$usergroup."','".$gamelevel."','".$gamescore."')"); if (!$highscores){ die( mysql_error() ) };
the database _musicgamescores set id, primary, auto increment, integer name, varchar groupby, varchar level, integer score, integer
the password star'ed out. thank in advance!
group
reserved keyword. must escape not generate error.
insert highscores (id, user, `group`, level, score) values(...)
as sidenote, query vulnerable sql injection
if value(s) of variables came outside. please take @ article below learn how prevent it. using preparedstatements
can rid of using single quotes around values.
Comments
Post a Comment