thecase Posted June 29, 2009 Share Posted June 29, 2009 Hi, Cant seem to figure out why this SQL line wont insert to the db $query = sprintf("INSERT INTO raceadmin (username, matchid, text) VALUES ('%s', '%s', '%s')", mysql_real_escape_string($username), mysql_real_escape_string($id), mysql_real_escape_string($text2)); Any ideas will be greatful Thanks Link to comment https://forums.phpfreaks.com/topic/164167-sql-not-inserting/ Share on other sites More sharing options...
celsoendo Posted June 30, 2009 Share Posted June 30, 2009 PHP error? MySQL error? what?!?! Anyway, before call mysql_query(), just print $query variable and check if the query is ok. Link to comment https://forums.phpfreaks.com/topic/164167-sql-not-inserting/#findComment-866147 Share on other sites More sharing options...
flyhoney Posted June 30, 2009 Share Posted June 30, 2009 <?php $query = " INSERT INTO raceadmin SET username = '%s', matchid = '%s', text = '%s' "; $query = sprintf( $query, mysql_real_escape_string($username), mysql_real_escape_string($id), mysql_real_escape_string($text2) ); $result = mysql_query($query); if (!$result) { die('Invalid query: ' . mysql_error()); } Link to comment https://forums.phpfreaks.com/topic/164167-sql-not-inserting/#findComment-866149 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.