Jump to content

gurpreet94

Members
  • Posts

    20
  • Joined

  • Last visited

    Never

Everything posted by gurpreet94

  1. Thank you very much Alex, that's what I needed.
  2. I have a form made to enter 1 number, and stored in the DB. On another page this gets called, and I need a way of turning that number into a percentage chance. E.G I input 50, and that gets stored. On the page it's needed, how would I turn 50 into 50% chance (rand(1,2)), but it has to work for every number inputted. Any ideas?
  3. Once again thanks a lot for this, it has been bugging me for a while!
  4. Yes it was just that error, but it works perfectly now. The $upkeep was just used to store the value of the total. However, would you suggest storing this new $upkeep in the DB, or just running this code on every page load?
  5. Sorry for the double post but I though I'd clarify a bit more. What I'm trying to achieve is basically: $upkeep += $remove['upkeep']; in a while loop. But that produces errors.
  6. What do you mean by keys? I am trying to get every row of upkeep that a certain user has, and then store them in $upkeep. For example if my userid is 1, and I have 5 upkeep records of 1000 each. My $upkeep is 5000, which I'll be using later in the script. This is to let users know their total upkeep cost. Edit: I tried using count($upkeep) and echoing $upkeep, and it returns the value 126. However, I ran the query $rem in PHPmyadmin, and it should equal to 100. Here is what the query returns: http://i40.tinypic.com/28ko5zo.png
  7. Hey guys, I've got a problem with an array sum. I tried doign array_sum(), and a few other stuff but none worked. Here's my code: $upkeepcheck = $db->query("SELECT i.itmid, i.upkeep, inv . * , u.userid, u.will, u.maxwill, u.upkeepowed, u.money, h.hPRICE, hWILL FROM items i LEFT JOIN inventory inv ON inv.inv_itemid = i.itmid LEFT JOIN users u ON inv.inv_userid = u.userid LEFT JOIN houses h ON h.hWILL = u.maxwill WHERE i.upkeep >0"); $q5 = $db->query("SELECT * FROM settings WHERE conf_name = 'upkeep'"); while($upkeep=mysql_fetch_array($upkeepcheck)) { while($upkeep1=mysql_fetch_array($q5)) { if($upkeep['money'] > $upkeep['upkeep']) { $db->query("UPDATE users SET money = money - {$upkeep['upkeep']} WHERE userid = {$upkeep['userid']}"); } else { $db->query("UPDATE users SET upkeepowed = upkeepowed + {$upkeep['upkeep']} WHERE userid = {$upkeep['userid']}"); } if($upkeep1['conf_value'] == 'Stackup') { if($upkeep['upkeepowed'] > $upkeep['hPRICE']) { $db->query("UPDATE users SET will=100,maxwill=100 WHERE userid = {$upkeep['userid']}"); $db->query("UPDATE users SET upkeepowed = 0 WHERE userid = {$upkeep['userid']}"); event_add($upkeep['userid'], "You haven't paid your upkeep, so your house has been taken away. Next time sell some weapons or earn some more money to pay your upkeep!", $c); } } else if($upkeep1['conf_value'] == 'RemoveItems') { $rem = $db->query("SELECT i.itmid, i.upkeep, inv.*, u.userid, u.upkeepowed FROM items i LEFT JOIN inventory inv ON inv.inv_itemid = i.itmid LEFT JOIN users u ON inv.inv_userid = u.userid WHERE userid = {$upkeep['userid']}"); while($remove = mysql_fetch_array($rem)) { if(isset($remove['upkeep'])) { var_dump($remove['upkeep']); $upkeep = $upkeep + $remove['upkeep']; } } } } } The part that is messed up is $upkeep = $upkeep + $remove['upkeep']; var_dump($remove['upkeep']); produces: which is correct, I have 4 null values and 1 value of 100. And the error I get is: Fatal error: Unsupported operand types in C:\wamp\www\pagetest.php Any ideas how to fix this? I want the $upkeep to be updated with $remove['upkeep'] if the value isn't null.
  8. Couldn't you add this after your script executes the query? <meta http-equiv="refresh" content="0">
  9. With that code, do you mean I should put my images and everything within the <div id="main">?
  10. Hi guys, I can't explain it with words properly but when someone tries to drag and drop an image, I want to turn it in the bar that appears when you hover over an input form. An example can be seen here: http://www.prisonstruggle.com/ Could anyone help me out here? I got no idea how to start because I don't know which terms to search for in google.
  11. I use this method: $thirty_days = time()+60*60*24*30; Simply because it's easier to change the number of days or whatever you want, or spot any errors in time (for example I might put an extra 0 your way)
  12. Thanks for that great explanation
  13. Works perfectly, thanks once again. Could you explain how it works because I don't understand it? The count(*) hasn't been pointed to the refREFER? Or does the count(*) count whatever the GROUP BY is?
  14. I've been trying to add a bit more to this script, to make it so that if someone has referred more than 1 person, their name will come up in a table and a number showing how many referrals they have. I can't get the count function working properly as I've never really used it. Any help would be great <?php include "globals.php"; if($ir['user_level'] != 2 && $ir['user_level'] != 3) //User level check { die("You can't access this page"); } $q=mysql_query("SELECT u.userid, u.username, u.laston, u2.userid AS u2userid, u2.username AS u2username, u2.laston AS u2laston, r.* FROM referals r JOIN users u ON u.userid = r.refREFER JOIN users u2 ON u2.userid = r.refREFED WHERE r.refREFERIP=r.refREFEDIP ORDER BY u.userid ASC"); //Selecting everything that's needed print "<center><br /><b><font color=white><h1>Referral Multis</h1></b><br /> <table width=75% border=1> <tr style='background:black'> <th><font color=grey>Referer</font></th> <th><font color=grey>Refered</font></th> <th><font color=grey>IP</font></th> <th><font color=grey>Time</font></th> </tr>"; while($r=mysql_fetch_array($q)) //Making all of the select stuff into $r { $reftime = date('F j, Y g:i:s a', $r['refTIME']); if($r['laston'] >= time()-60*60) { $on="<font color=green><b>Online</b></font>"; } else { $on="<font color=red><b>Offline</b></font>"; } print " <tr> <td><a href='viewuser.php?u={$r['userid']}'><font color=brown><b>{$r['username']}</b></font></a> [{$r['refREFER']}]</td> <td><a href='viewuser.php?u={$r['u2userid']}'><font color=brown><b>{$r['u2username']}</b></font></a> [{$r['refREFED']}]</td> <td>{$r['refREFERIP']}</td> <td>$reftime</td> </tr>"; } print "</table>"; $q2=mysql_query("SELECT u.userid, u.username, r.refREFERIP, r.refREFER, COUNT(*) FROM referals r JOIN users u ON u.userid = r.refREFER GROUP BY r.refREFER ORDER BY u.userid ASC") or die(mysql_error()); //Selecting everything that's needed for the 2nd part print "<center><br /><b><font color=white><h1>Multiple referals (check these)</h1></b><br /> <table width=75% border=1> <tr style='background:black'> <th><font color=grey>Refered</font></th> <th><font color=grey>IP</font></th> <th><font color=grey>No. of referrals</font></th> <th><font color=grey>Time</font></th> </tr>"; while($r2=mysql_fetch_array($q2)) //Making all of the select stuff into $r { $reftime = date('F j, Y g:i:s a', $r['refTIME']); $num_rows = mysql_num_rows($q2); if($r['laston'] >= time()-60*60) { $on="<font color=green><b>Online</b></font>"; } else { $on="<font color=red><b>Offline</b></font>"; } print " <tr> <td><a href='viewuser.php?u={$r2['userid']}'><font color=brown><b>{$r2['username']}</b></font></a> [{$r2['userid']}]</td> <td>{$r2['refREFERIP']}</td> <td>count({$r2['refREFER']})</td> <td>$reftime</td> </tr>"; } print "</table>"; echo "$num_rows"; $h->endpage(); ?> The problem parts: $q2=mysql_query("SELECT u.userid, u.username, r.refREFERIP, r.refREFER, COUNT(*) <td>count({$r2['refREFER']})</td> The echo "$num_rows" shows the number 11 at the bottom, but that's how many users have more than 1 referral. Would anyone like to provide any help so the number of referrals column could show how many referrals that user has? Thanks in advance
  15. Sorry for the confusion, it seems when I edited the IP's I accidentally put a space after the IP. D'oh! Thanks for all your help! Solved
  16. Oh right, I didn't spot you done that. That works perfectly now, however it is still only loading up 1 record. There are a few in my database with the same IP, but it's only showing the first one. If I change the order from ASC to DESC it will show the same one ando nly one. I have tried limit but that doesn't work either If I run this: $q2=mysql_num_rows($q); echo "$q2"; It prints out the number 1.
  17. With both of the above queries, under the column Refered, the referer's username came up, but the refered ID is correct. Also, the list is limited to 1, even though I have set up 3 entries with the same IP's. Here's an example: refID refREFER refREFED refTIME refREFERIP refREFEDIP refCREDITED 37 2 7 1193519079 127.0.0.1 127.0.0.1 0 This is displayed as: Referer Refered IP Time Test [2] Test - 7 127.0.0.1 October 27, 2007 9:04:39 pm However, ID 7 belongs to Klikoka
  18. Neither of those worked. Here is my table structure: Users: userid, username, lastip, and more referals: refID (auto_increment), refREFER, refREFED, refTIME, refREFERIP, refREFEDIP, refCREDITED I want it so that under the Referer column on the page it has the username of the refREFER, and under the column of Refered it has the username of the refREFED, as long as they are both the same IP - refREFEDIP
  19. I have created a file with this basic structure in the referals table: refREFER = the referer, person who sent the referal link out refREFED = the refered person, the one who signed up with the link refREFERIP = the referer's IP refREFEDIP = the refered person's IP I'm trying to create a code that will list any user that has signed up on the same IP with a referal link. Everything works except the Refered column, which I can't seem to figure out how to do. Basically I have made the refREFER = the userid in the users table, so it can be output as a username. However I want to do the same with the refREFED but don't know how. Here's my code so far: <?php include "globals.php"; if($ir['user_level'] != 2 && $ir['user_level'] != 3) //User level check { die("You can't access this page"); } $q=mysql_query("SELECT u.userid, u.username, u.laston, r.* FROM users u LEFT JOIN referals r ON r.refREFER=u.userid WHERE r.refREFERIP=r.refREFEDIP ORDER BY userid ASC",$c); //Selecting everything that's needed print "<center><br /><b><font color=white><h1>Referral Multis</h1></b><br /> <table width=75% border=1> <tr style='background:black'> <th><font color=grey>Referer</font></th> <th><font color=grey>Refered</font></th> <th><font color=grey>IP</font></th> <th><font color=grey>Time</font></th> </tr>"; while(($r=mysql_fetch_array($q) or die(mysql_error()))) //Making all of the select stuff into $r { $reftime = date('F j, Y g:i:s a', $r['refTIME']); if($r['laston'] >= time()-60*60) { $on="<font color=green><b>Online</b></font>"; } else { $on="<font color=red><b>Offline</b></font>"; } print " <tr> <td><a href='viewuser.php?u={$r['userid']}'><font color=brown><b>{$r['username']}</b></font></a> [{$r['refREFER']}]</td> <td> {$r['username']} - {$r['refREFED']}</td> <td>{$r['refREFERIP']}</td> <td>$reftime</td> </tr>"; } print "</table>"; $h->endpage(); ?> At the moment under the Refered column it shows the wrong username, but the correct ID. Any ideas?
×
×
  • 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.