Ninjakreborn Posted April 18, 2007 Share Posted April 18, 2007 I never used some before. <?php // this section of php here is made to go ahead and pull out all the deposits // that this specific user has made, add them up, and formulate a total so we can // display it on the page as "total deposits" $deposits = array(); $selectdeposits = "SELECT SUM(amount) FROM transactions WHERE type = 'Deposit' AND userid = '" . $_SESSION['cymember'] . "';"; $totaldeposits = mysql_query($selectdeposits); ?> Basically when I echo total deposits it throws out Invalid Resource ID #9 or something. Based on the many examples I looked at this should work. Originally I had "varchar" as the database type, but tried changing it to "Double." and it's still not working. They are all dollar amounts in the database. 450.00, 400.00, 600.50 obviously it removes the .00 when it's just a flat dollar amount, but it's not adding them up. Any advice. Quote Link to comment https://forums.phpfreaks.com/topic/47638-solved-resource-id-issue/ Share on other sites More sharing options...
bubblegum.anarchy Posted April 18, 2007 Share Posted April 18, 2007 remove the semicolon in the query string. Quote Link to comment https://forums.phpfreaks.com/topic/47638-solved-resource-id-issue/#findComment-232661 Share on other sites More sharing options...
Guest prozente Posted April 18, 2007 Share Posted April 18, 2007 If this is all of your code then the error is because you haven't connected to MySQL and mysql_query will use the last link opened. Also what is returned is a resource, there is no need to echo a resource. Quote Link to comment https://forums.phpfreaks.com/topic/47638-solved-resource-id-issue/#findComment-232695 Share on other sites More sharing options...
Ninjakreborn Posted April 19, 2007 Author Share Posted April 19, 2007 remove the semicolon in the query string. This is actually a good habit. When you pass a query into sql then it's required to have that after each command (except the last one). Well in php you are only passing one, so it's a good habit if you ever intend on writing standard sql (like for an install system or something). So I keep it there for habit, it can never cause negative affects. If this is all of your code then the error is because you haven't connected to MySQL and mysql_query will use the last link opened. Also what is returned is a resource, there is no need to echo a resource. This is not all my code, and it's just the part I am having problems with. As far as this problem, I gave up on using sum. I pulled them all out and did the calculations with PHP. Quote Link to comment https://forums.phpfreaks.com/topic/47638-solved-resource-id-issue/#findComment-233139 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.