Jump to content

ignace

Moderators
  • Posts

    6,457
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by ignace

  1. Zend framework 2, just to put your teeth in their awesome Db component. https://github.com/zendframework/zf2
  2. You should write it in JavaScript, and preferably use a <canvas/> While on the matter, you should also read "JavaScript Patterns" this contains all the JS optimizations you will need to consider while building your game. Look at Command & Conquer Tiberium Alliances for a browser-based game with moving units. You will also need a book/resource with explanations of how you can create a fair multiplayer when dealing with clients. The server is the referee, and clients should only be able to communicate their actions, not their result. Examples of communicating their results: Examples of communicating their actions: This puts the server in control of what damage is done instead of the clients. The server should also validate each request, as you should with any normal application you build. You can further expand on this by creating admin specific requests: Obviously in admin-kill.php you should check whether the client is in fact an admin. Also any security measures you take with a normal application should also be present here, like for example preventing the obvious CSRF attacks.
  3. Hello and welcome. Hope to see you around.
  4. Have an hidden input field named section in each form: <input type="hidden" name="section" value="a"> Then when processing check which section: if ($_POST['section'] === 'a') { // section a processing } For the d part, let that be the else: } else if ($_POST['section'] === 'c') { // section c processing } else { // section d processing }
  5. This outputs: This is because when $test1 is passed to the function, it is not linked to $x. It's value is simply copied to $x and $x is part of the function scope where-as $test1 is part of the global scope. Using a reference you can bind $x in the function scope to $test1 by changing the declaration of $x to &$x. When you then run the above code you will get: I did not alter the code and then run it to tell you this. Most people on these forums can tell you this without executing the code because they understand how PHP/functions works, and you should too.
  6. Address please!
  7. That's backwards. The ring chooses someone worthy and you are automatically a part of the Green Lantern Corps. Speaking of rings.. that darn hobbit still has mine!
  8. I don't know what is scaries: that people write their code like that or that PHP happily parses and executes it...
  9. It was sarcasm! But you make a good point, and sure, getting a second opinion IS a good thing IF that person is qualified, not so sure about the kind of confidence you should put in an anonymous internet user. You also make my point:
  10. Can you elaborate why you think this is a bad idea? Because having a separate DB for each restaurant makes it easy to scale it in the future (for example all low-volume DB's on one node) where-as one DB means you need to replicate ALL the data over multiple nodes regardless of high- or low-volume websites.
  11. Of course, I didn't intend to write the entire script for you so you could just copy-and-paste it and learn nothing in the process. For example in your current code you use $getUserRank why? After the first while() $getUserRank will contain the lowest possible rank (12640), since the value is constantly overwritten. So at the second loop $getUserRank will be 12640 not 1,2,3,4,.. Just do the same thing as you did with $rank for $getUserRank and move it to your second while and be sure to enclose the $rank++ between parenteses and you'll find that it will now correctly display the rank (and remove the first while() loop altogether, you don't need it!).
  12. Apparently you have every confidence in the developer you hired!
  13. It's better to write public.
  14. Now you are just pissing me off! I wrote you some example code and asked you to try it out which would have let to you examining the code as to why mine works and yours dont. But instead you ignored my effort and went ahead with no clue of what you are doing or what is wrong. Everyone on this forum who glances over your code can tell you why everyone has the same rank, but I'm now just refusing to tell you because you showed no respect whatsoever!
  15. Try this: echo $blog_posts[0]->error[0]->code;
  16. bcrypt probably. I've never used it though. So far I have never had a case that had such a high security concern. And if the project does have to handle sensitive data, we employ licensed third-party software. Because it's better to be able to point the finger at someone other than you
  17. PHPass is a good idea as a minimum security measure. Unless you are storing more sensitive information like credit card info and such, which I doubt.
  18. I fail to see how this seems challenging? Use the host address to query the DB for the website details SELECT * FROM websites WHERE domain = 'website.com' and the content SELECT * FROM content WHERE domain_id = 1. Sure there are a few caveats (www.website.com versus website.com being just one).
  19. Does the below produce what you want? And if not then copy-paste (or link) the result. $sql = ' SELECT hungergames_users.id, hungergames_records.user_id, hungergames_records.victories, hungergames_records.biggest_kill_streak, hungergames_records.most_chests_opened, hungergames_records.total_chests_opened, hungergames_records.lastlogin, hungergames_records.longest_lifespan, hungergames_records.total_lifespan, hungergames_records.total_points, hungergames_records.most_points, hungergames_users.donor, hungergames_users.user FROM hungergames_records JOIN hungergames_users ON hungergames_users.id = hungergames_records.user_id ORDER BY hungergames_records.total_points DESC '; $result = mysql_query($sql, $mysql_link); if ($result && mysql_num_rows($result)) { $rank = 1; while ($row = mysql_fetch_array($result)) { echo ($rank++), ' ', $row['id'], ' ', $data['user'], '<br>', PHP_EOL; } }
  20. Read http://www.codinghorror.com/blog/2012/04/speed-hashing.html
  21. If you are using shared hosting then it will be unlikely for you to install them. You can try contacting the host provider and ask them if they could install the extension but it's also unlikely they will. An other option you may have is finding the poisson distribution in pure PHP like: http://www.phpmath.com/build02/PDL/docs/package.php?view=6c892fdf713fd5c15ff0cdd31daf79463531ceef Which uses PEAR (quite likely to be installed on your host). A full index of pure PHP mathematical functions can be found at: http://www.phpmath.com/build02/
  22. Do not write your PHP code in your HTML, but organize them in functions and use those in your HTML. This separates your core app functionality from your HTML and makes it easier to edit/re-use later on. functions.php function get_monthy_sales_for_year($year, $mysql_link) { $sql = 'SELECT * FROM MonthlySales WHERE Year = %d'; $sql = sprintf($sql, $year); return mysql_fetch_all($sql, $mysql_link, MYSQL_ASSOC); } function get_monthly_sales($mysql_link) { return mysql_fetch_all('SELECT * FROM MonthlySales', $mysql_link, MYSQL_ASSOC); } function mysql_fetch_all($sql, $mysql_link, $mode = MYSQL_ASSOC, $callback = null) { $rows = array(); $result = mysql_query($sql, $mysql_link); if ($result && mysql_num_rows($result)) { while ($row = mysql_fetch_array($result, $mode)) { if (is_callable($callback) && ($crow = call_user_func($callback, $row))) { $row = $crow; } $rows[] = $row; } } return $rows; } /** * @param array|ArrayAccess $array */ function get_param($array, $name, $default = null) { if (!isset($array[$name])) { return $default; } return $array[$name]; } function get_year_range() { // this may be used at several places but changing the actual range is done here. return range(2000/*start*/, 2001/*end*/); } As you can see this looks much cleaner than your example. The below code assumes you have $link = mysql_connect('localhost', 'root', 'root'); somewhere. monthly_sales.php <?php include 'functions.php'; ?> <form action="<?php /*leave empty if processed on same page*/ ?>" method="post" name="form_filter"> <select name="year"> <option value="all">All</option> <?php foreach (get_year_range() as $year): ?> <option value="<?php print $year; ?>"><?php print $year; ?></option> <?php endforeach; ?> </select> <input type="submit" value="Filter"> </form> <table> <?php if (!get_param($_POST, 'year')) { <?php foreach (get_monthly_sales($link) as $sale): ?> <tr> <td><?php print $sale['Id']; ?></td> <td><?php print $sale['ProductCode']; ?></td> <td><?php print $sale['Month']; ?></td> <td><?php print $sale['Year']; ?></td> <td><?php print $sale['SalesVolume']; ?></td> </tr> <?php endforeach; ?> <?php else: ?> <?php foreach (get_month_sales_for_year(get_param($_POST, 'year'), $link) as $sale): ?> <tr> <td><?php print $sale['Id']; ?></td> <td><?php print $sale['ProductCode']; ?></td> <td><?php print $sale['Month']; ?></td> <td><?php print $sale['Year']; ?></td> <td><?php print $sale['SalesVolume']; ?></td> </tr> <?php endforeach; ?> <?php endif; ?> </table>
  23. The code I provided will only work for the type=detached, you will have to write the other functions to handle semi-detached, etc... If you do not feel comfortable writing PHP then either: 1) go out and buy a book and read until you feel comfortable with the language or 2) pay someone to do it for you (or teach you, having someone to ask questions directly is often easier).
  24. You can make this as simple/straightforward as: function get_detached_houses($mysql) { $sql = 'SELECT * FROM real_estate WHERE type_id = 5'; // 5 = Detached House $rows = mysql_fetch_all($sql, $mysql, MYSQL_ASSOC); return $rows; } You can check what the user asked for by creating URL's like: estate.php?type=semi-detached estate.php?type=detached .. In your code you would use the type to display the correct properties: $mysql = mysql_connect(/*...*/); if (get('type') === 'detached') { $estate = get_detached_houses($mysql); } else if (get('type') === 'semi-detached') { // .. } else { $estate = get_houses(); } mysql_fetch_all and get are custom functions: function get($name, $default = null) { return array_key_exists($name, $_GET) ? $_GET[$name] : $default; } // executes a query and returns a result set function mysql_fetch_all($sql, $mysql, $mode = MYSQL_BOTH) { $rows = array(); $res = mysql_query($sql, $mysql); if ($res && mysql_num_rows($res)) { while ($row = mysql_fetch_array($res, $mode)) { $rows[] = $row; } } return $rows; }
×
×
  • 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.