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>';

Link to comment
Share on other sites

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']}")

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.