Jump to content

MySQL and PHP together (I'm kinda new to php)


Marsha

Recommended Posts

Can anybody spot any big mistakes that would lead to my code not working? :(

Have a good look please

					echo '<a href="' . $scripturl . '?action=downloads;sa=downfile&id=', $context['downloads_file']['ID_FILE'], '">', ($context['downloads_file']['fileurl'] == '' ? $context['downloads_file']['orginalfilename'] : $txt['downloads_app_download']), mysql_query("UPDATE smf_members SET karmaGood = karmaGood + 1 WHERE ID_MEMBER = $context[downloads_file][iD_MEMBER]"), '</a>';

Firstly that is one stupidly long line of code. Secondly care to define doesn't work? The combination of concatenation and using the comma to pass extra parameters to echo is a little confusing, but should work. Having mysql_query in the middle of the line will output a 1 on success, but nothing otherwise. If ID_MEMBER is not an integer it will require quotes around it, but I'm guessing it is. The two dimensional array will not be accessed correctly in the string I don't believe.

 

mysql_query("UPDATE smf_members SET karmaGood = karmaGood + 1 WHERE ID_MEMBER = $context[downloads_file][iD_MEMBER]")
// should probably be
mysql_query("UPDATE smf_members SET karmaGood = karmaGood + 1 WHERE ID_MEMBER = {$context['downloads_file']['ID_MEMBER']}")

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.