Jump to content

jim_keller

Members
  • Posts

    35
  • Joined

  • Last visited

    Never

Contact Methods

  • Website URL
    http://lamplighterphp.org

Profile Information

  • Gender
    Not Telling

jim_keller's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. There's no good way to do this, really. You could set a cookie that doesn't expire for a very long time using setcookie(), then check for it in the $_COOKIE array. However, if someone clears their cookies, they can vote again. The only half decent way of locking people out is by IP address, but obviously that is a problem if people are sharing an external IP (which they often are)
  2. I would probably just do this in code. To do it in mySQL, you'd have to use subselects. This stack overflow post has some information on getting percentages in your query using subselects though: http://stackoverflow.com/questions/1372260/get-percentage-average
  3. Processing time for a query is dependent on a lot of factors (underlying hardware, caching, current load of the server), so there's no way to determine how long it will take before you actually execute it. It's like estimating how long it will take you to drive somewhere. You can't always know if you're going to have car trouble or run into traffic; the best you can do is make an educated estimate based on historical data. If a sampling of 1,000 random executions of your query take an average of 0.5 seconds, the next one will probably take about 0.5 seconds.
  4. You should be able to use the microtime() function to get a timestamp in microseconds (and store it in a variable), run your query, then call microtime() again. Subtracting the two will give you the number of microseconds it took for PHP to run your query.
  5. try using two percent signs in your sprintf string, which will print a single % in the query: $query_rsCustomers = sprintf("SELECT * FROM customer_tbl WHERE customer_last_name LIKE '%%%s' ORDER BY customer_last_name ASC", GetSQLValueString($colname_rsCustomers, "text"));
  6. A couple of immediate notes: [*]Ideally, you should try not to mix PHP code and HTML. This may be a little bit too advanced for you at the moment, but you should think about looking into templates (e.g. Smarty templating) if you want to get serious about cleaner code. [*]choose a naming convention for your variables that doesn't have you sticking words together; it makes things more readable. Instead of $thisismyvariable, use $this_is_my_variable or $thisIsMyVariable [*]there's almost never a reason to use sleep(). [*]I don't know much about what this code is supposed to do, but I'm almost certain that instead of exec()ing a separate PHP script, you could write a function in a separate file to do what you need, then use include() to pull that file into your script
  7. as mentioned above, SQL injections are probably the most common way to exploit a script. A large margin of the code written by novice (and even intermediate) developers usually passes user input directly to SQL queries, which is potentially very bad news. The most reliable way to avoid injection is to use only prepared statements when interacting with the database.
  8. ...that's not true, but I wanted to post something other than the standard "hi everyone". Really I'm here to probably answer a lot of PHP questions and also promote Lamplighter, the PHP MVC Framework that's been built at my company over the course of the past few years. If you're the curious type and want PHP to be fun again, I recommend checking it out.
  9. what's the exact error? If it's related to the foreach, most likely it's because $rows isn't an array. You'll get an array if you try to pass something other than an array to a foreach loop. I would print your query to the browser, then try to run it directly in mySQL to see if the query is failing (which is one reason why $rows wouldn't be an array)
  10. I'm entirely biased since I'm the lead developer, but it's probably worth looking at Lamplighter
  11. if you don't put anything after the hash tag (#), the browser treats it as "current page". What are you trying to accomplish by adding just the hash tag? To go back to the top of the page? If so, use #top
  12. At first glance, it may be that you're using $row twice inside the same while loop, which means you won't get the behavior you're looking for. The same way you're using $query and $query1, try using $row and $row1 ($row1 would contain the subcategory data, $row the main category)
  13. Off the top of my head, I actually don't think this is possible; I believe it will always return the very last row inserted. You may just have to do your insert queries individually.
  14. it's probably a timezone difference between where you are and where the server is. Try calling date_default_timezone_set( 'your timezone here' ) early in your code, but replace 'your timezone here' with a valid timezone from this list: http://us3.php.net/manual/en/timezones.php
  15. This would be a huge security risk and is not possible with out having the client explicitly install a third-party app like a Java applet or an ActiveX control.
×
×
  • 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.