0
$sortAlgorithm = 'submissions.id * (submissions.upvote - submissions.downvote)';

Gives this erorr:

Warning: mysql_num_rows() expects parameter 1 to be resource

Which basically means the query is corrupt. However, if I change the * to a - it works fine:

$sortAlgorithm = 'submissions.id - (submissions.upvote - submissions.downvote)';

This is weird because this was working fine until just now when I tried upvoting a submission. I queried the database and all the ids, upvotes, and downvotes are numerical and not corrupt. Anyone have any ideas for why this is happening?

John Smith
  • 8,688
  • 13
  • 49
  • 66

1 Answers1

1

I'll guess that it is interpreting * as "all columns". What happens when you add more parens? (submissions.id)*(submissions.upvote - submissions.downvote)

cwallenpoole
  • 76,131
  • 26
  • 124
  • 163
  • Just tried +, -, and / and those all worked as well. Also tried many different variations of parenthesis placement and all yielded the same error. This is quite odd.. – John Smith Apr 02 '11 at 03:53
  • did you try wrapping the whole thing? '(submissions.id * (submissions.upvote - submissions.downvote))' – Erik Apr 02 '11 at 03:56
  • Maybe this is something wrong with something else in the query? if not, you may need to simply select the ID and the difference separately – cwallenpoole Apr 03 '11 at 21:26