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? Link to comment https://forums.phpfreaks.com/topic/171468-solved-inserting-dat-into-table/ 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') "); Link to comment https://forums.phpfreaks.com/topic/171468-solved-inserting-dat-into-table/#findComment-904217 Share on other sites More sharing options...
dink87522 Posted August 23, 2009 Author Share Posted August 23, 2009 Still doesn't work Link to comment https://forums.phpfreaks.com/topic/171468-solved-inserting-dat-into-table/#findComment-904219 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 ' Link to comment https://forums.phpfreaks.com/topic/171468-solved-inserting-dat-into-table/#findComment-904224 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.