dink87522 Posted August 23, 2009 Share Posted August 23, 2009 I have $servername = "localhost"; $username = "admin_admin"; $password = "admin"; $dbCon = mysql_connect($servername, $username, $password); if (!$dbCon) { die(); } $userID = "a"; $score = 33; $ageGroup = "mm"; $dateTimeStamp = "2345432"; mysql_select_db("admin_GTWE") or die(mysql_error()); mysql_query("INSERT INTO 'Highscores' (userID, score, ageGroup, saveTimeDate) VALUES($userID, $score, $ageGroup, $dateTimeStamp) "); except it doesn't work (althoguh nor does it throw any errors). The database details are defiantly correct and I can connect to it. The table exists. The rows exist. However I do have another column first called ID which is the priamry key? Quote Link to comment Share on other sites More sharing options...
richarro1234 Posted August 23, 2009 Share Posted August 23, 2009 Hey, instead of mysql_query("INSERT INTO 'Highscores' (userID, score, ageGroup, saveTimeDate) VALUES($userID, $score, $ageGroup, $dateTimeStamp) "); Try: mysql_query("INSERT INTO 'Highscores' (userID, score, ageGroup, saveTimeDate) VALUES ('$userID', '$score', '$ageGroup', '$dateTimeStamp') "); Quote Link to comment Share on other sites More sharing options...
dink87522 Posted August 23, 2009 Author Share Posted August 23, 2009 Still doesn't work Quote Link to comment Share on other sites More sharing options...
gergy008 Posted August 23, 2009 Share Posted August 23, 2009 You have no error handling. Also, You left in your database passwords so I took them out... Do the same for your post or you could get hackers! Try this: $servername = "localhost"; $username = "xxxx"; $password = "xxxx"; $dbCon = mysql_connect($servername, $username, $password); if (!$dbCon) { die(); } $userID = "a"; $score = 33; $ageGroup = "mm"; $dateTimeStamp = "2345432"; mysql_select_db("admin_GTWE") or die(mysql_error()); mysql_query("INSERT INTO `Highscores` (userID, score, ageGroup, saveTimeDate) VALUES('$userID', '$score', '$ageGroup', '$dateTimeStamp') ") or die("There was an error. Error returned was: ".mysql_error()); Also on Highscores I used ` not ' Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.