Jump to content

[SOLVED] MySQL Query error


Capnstank

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.