Jump to content

Pandemikk

Members
  • Posts

    144
  • Joined

  • Last visited

Everything posted by Pandemikk

  1. How do you fix a "file doesn't exist" error? Uhm... You create the file? Why are you trying to include a file that doesn't exist in the first place?
  2. It means the file doesn't exist. Hence: "No such file or directory".
  3. that's because $result doesn't contain the value of your SUM. It contains the array of the selected values, which, in this case, is just one value. sum(price) AS price echo $result['price'];
  4. No. I'm assigning $row['item_quantity'] that value then making sure it isn't 0 so I don't divide by 0. I didn't test it but it should work fine.
  5. That's a big mess. Why are you over complicating it with functions? There's no need for it and it just looks sloppy. And you're getting that error because you're using mysqli_fetch_array on a delete query. Why the #$% are you doing that?
  6. Be sure to escape $_POST['project'] before actually using this script (http://php.net/manual/en/function.mysql-real-escape-string.php). What exactly goes wrong in your script? Does it echo "Project not found"? In that case, a row was not found. You should be using LIMIT 1 since you're doing one redirect. And you should use die; after header to stop code processing. I don't recommend using * to select everything. Just select what you need. <?php include("project_admin/includes/config.php"); $db = new Database($db_host, $db_username, $db_password, $db_database, $db_table_prefix); $db -> connect(); if ($_POST['findproject']{ $q = $db->mysql_query("SELECT * FROM projects WHERE project LIKE '" . mysql_real_escape_string($_POST['project']) . "' LIMIT 1"); if (!$q){ echo "Project Not Found"; }else{ header('Location:' . $r['url']); die; } ?> Use die($_POST['project']); at the top of the script to make sure its value is correct.
  7. I don't recommend you wrap integers in single quotes^. If you are unsure if your variable is an integer you should sanitize it. There's no reason to use LIMIT 1. How could he possibly know he's deleting the right row that way?
  8. Uhm I think I do... http://dev.mysql.com/doc/refman/5.0/en/control-flow-functions.html#function_if SELECT IF(response = 'Yes', COUNT(whatever you're counting), 0)
  9. $query ="SELECT article_id FROM article_updates GROUP BY article_id ORDER BY timestamp_of_update ASC"; Simple group by statement will return all (unique) article_ids with the highest timestamp. For your second question we'll need to see your table information.
  10. Foreign keys to what? I don't think that's even relevant information. Anyway, what you're asking is to delete rows with a user_id of 1, question_id of 7 and answer_id of 3. If a row(s) with all those values exists, it will be deleted.
  11. No it's not. Like he said it only shows in IE which means it most likely has nothing to do with PHP and is something browser specific to IE.
  12. CRON scripts are not something you can do with PHP alone. You need your server to run the CRON scrips for the nth time. If your server does not offer that option, you can emulate it by placing the script to run the emails on pages on the web site. This way, whenever someone hits say index.php your CRON script would execute to see if anything should be sent. This is not very efficient.
  13. Or if you just want total damage and don't care about individual weapon stats: <?php $total_power = 0; $total_weapons = 0; $soldiers = 100; $q = mysql_query("SELECT `item_quantity`, `item_power` FROM `items` WHERE `owner_id` = " . intval($userid) . " ORDER BY `item_power` DESC"); while($row = mysql_fetch_assoc($q)) { $row['item_quantity'] = intval($row['item_quantity']); $total_weapons += $row['item_quantity']; if ($total_weapons > $soldiers) { $extra_weapons = $total_weapons - $soldiers; // trim the item_quantity so that it doesn't surpass how many soliders you have if ($row['item_quantity'] = ($row['item_quantity'] - $extra_weapons) != 0) { $total_power += $row['item_quantity'] * intval($row['item_power'])); } break; } $total_power += $row['item_quantity'] * intval($row['item_power'])); }
  14. Okay, now you're making sense: <?php $weapons = array(); $total_weapons = 0; $soldiers = 100; $q = mysql_query("SELECT `item_quantity`, `item_power` FROM `items` WHERE `owner_id` = " . intval($userid) . " ORDER BY `item_power` DESC"); while($row = mysql_fetch_assoc($q)) { $row['item_quantity'] = intval($row['item_quantity']); $weapon[] = array('quantity' => $row['item_quantity'], 'damage' => $row['item_quantity'] * intval($row['item_power'])); $total_weapons += $row['item_quantity']; if ($total_weapons >= $soldiers) { break; } }
  15. Example of what I mean by contradicting comments: "I want to assign all the weapons until there's not enough soldiers to assign them to" "I'm not literally trying to assign an array of values to each individual soldier"
  16. Your comment says "assign weapons to soliders" which is what my code does. I'm not sure what you're asking now, because your comments are conflicting.
  17. I don't see where $user is getting assigned anything? Can you show me where $user is assigned a value? (If it doesn't have a value that's why you're not getting any results!) Use this to show an error message: if (!$email = mysqli_query($link,"SELECT email FROM members WHERE username= '$user' LIMIT 1")) { die('Invalid user specified.'); }
  18. Well how else are you going to assign the soldiers a weapon? That loop will either pass through every soldier or through every weapon, whichever case is smaller. So if you want to assign weapons to soldiers but don't want to loop through every weapon you're out of options.
  19. You really shouldn't leave PHP to guess the index on associative arrays. $sql = "INSERT INTO `sa_enemystats` VALUES (null, '$enemyID', '" . $_SESSION['username'] . "', '" . $enemy[$enemyID]['current_health'] . "')"; Now that should work ASSUMING $enemy[$enemyID]['current_health'] actually has the value you're looking for. So let's put echo $enemy[$enemyID]['current_health']; die; right before $sql and see if it returns what you want, okay?
  20. You're posting way too much code. You're going to have a hard time finding help when you overwhelm people with that much information. $_GET will retrieve parameters from a URL. For example: $_GET['topic'] would contain 349165.0 for this page, I believe (SMF is weird). Now you don't need to urlencode integers. Just take out the urlencode altogether (unless they're strings, in which case keep them). Now I believe you're looking for something like this: http://www.mindpalette.com/tutorials/breadcrumbs/index.php ? I don't think you'll find anyone here that will make you a navigation system just out of good will. It's gonna take some time to make. So keep looking on the net for solutions and ask for help when you have a more specific problem you've encountered.
  21. $email = mysqli_query($link,"SELECT email FROM members WHERE username= '$user' LIMIT 1"); echo $email['email']; This should work. I don't know if your link values are correct or how your table is designed. I also don't know if $user is the username properly escaped as it should be since you're using it in a query.
  22. <?php $i = 1; $damage = 0; // don't surrond integers with single quotes. single quotes are for strings. $q = mysql_query("SELECT `item_quantity`, `item_power` FROM `items` WHERE `owner_id` = " . intval($userid). " ORDER BY `item_power` DESC"); while($row = mysql_fetch_assoc($q) AND $i <= 100 # 100 = soldier count) { // $solider[] now contains array('item_quantity', 'item_power'); $solider[] = $row; ++$i; }
×
×
  • 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.