Capnstank Posted October 26, 2009 Share Posted October 26, 2009 Hi again, I've got a segment of code trying to insert an entry into my database but is failing the check. Can anyone see an issue with my code or can advise of the appropriate way to return an error that I can work with? if (!get_magic_quotes_gpc()) $sql_filename = addslashes($file["name"]); else $sql_filename = $file["name"]; $sql_metadata = base64_encode($alltorrent); if ((strlen($hash) != 40) || !verifyHash($hash)) //Check hash length $returnString = "<p CLASS=\"err\">ERROR: Hash value must be exactly 40 hex bytes.</p>"; else { $sql_result = mysql_query("INSERT INTO `torrents` (`info_hash`, `name`, `metadata`) VALUES (\"$hash\", \"$sql_filename\", \"$sql_metadata\")"); if (!$sql_result) $returnString = "<p CLASS=\"err\">WARNING: Torrent not uploaded to database. ". "Has it been added already?</p>"; else $returnBool=true; } The if (!$sql_result) check is returning true (the error is being thrown) if that helps. Link to comment https://forums.phpfreaks.com/topic/179094-solved-mysql-query-error/ Share on other sites More sharing options...
Mchl Posted October 26, 2009 Share Posted October 26, 2009 Try echoing mysql_error Link to comment https://forums.phpfreaks.com/topic/179094-solved-mysql-query-error/#findComment-944890 Share on other sites More sharing options...
Capnstank Posted October 26, 2009 Author Share Posted October 26, 2009 Try echoing mysql_error Thank you! Will you have my children? Missed... $db = mysql_select_db('tracker',$link); Link to comment https://forums.phpfreaks.com/topic/179094-solved-mysql-query-error/#findComment-944897 Share on other sites More sharing options...
Mchl Posted October 26, 2009 Share Posted October 26, 2009 Thank you! Will you have my children? I like them roasted. Link to comment https://forums.phpfreaks.com/topic/179094-solved-mysql-query-error/#findComment-944911 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.