Jump to content

rmbarnes82

Members
  • Posts

    37
  • Joined

  • Last visited

    Never

Contact Methods

  • MSN
    helloeveryone192@hotmail.com
  • Yahoo
    robinmbarnes

Profile Information

  • Gender
    Not Telling

rmbarnes82's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Wasn't meaning to attack your post, its just I really wanted to get across to OP that what he's doing is wrong on a fundamental level, so he needs to completely rethink his whole approach, not look for optimizations to what he currently has.
  2. Hi, You have a problem with how you have conceptualized the database design, not with your client side coding. You need a user table in your database, representing the user currently playing the game. The round round 1, round 2, round 3 rows need to be associated with the user somehow, or you could even just store them in the session. A possible design for this in terms of the database is (I am presuming the seed stays constant here): surfer ------- id seed user -------- email password game ------- id user_id game_surfer ---------------- game_id (primary key) surfer_id (joint primary key) round1 round2 round3 Then just use the session to keep track of the users current game id. Robin
  3. Hi, For form containing a tuple, also generate a hidden form field inside the given form containing the primary key (id) for that row in the database. E.g.: <input type="hidden" name="row_id" value="$rowId" /> Then the submitted row_id value is the id you want to use in the where clause of your delete statement. Robin
  4. Hi, Is the reason you need to know which button was clicked so you know which row in the database the submitted tuple refers too? Robin
  5. You mean the user pretending to be paypal and send back a purchase successful form to your website?
  6. Hi, Not strictly a PHP question, but meh. You problem is the way you call the CountWords function: <input type=button value="Count Words" OnClick ="CountWords(this.form.x, true, true);"> You use this.form.x to identify the text area, not no form exists. To fix this: 1. Give each text area a unique id, eg: <textarea id="text1"></textarea> 2. Call CountWords using the textarea's id, so for text1: <input type=button value="Count Words" OnClick ="CountWords(document.getElementById('text1'), true, true);"> Robin
  7. Don't paypal use some sort of secret key only you and they know, then use that and a hashing algorithm they give you to encrypt the form data?
  8. That usually only happens if you actually take the payment details on your own site. Usually with stuff like paypal you hash the cart contents then post it to the payment provider. It's just there to stop ppl altering the form (eg changing all the product prices to 1 cent to rip you off). Far better to send the post form using curl.
  9. Hi, The general rule of thumb is filter input, escape output. What you are doing sounds right. 1. Turn off gpc_magic_quotes 2. Use mysql_real_escape_string on all variables which are added to MySQL queries (note that addslashes may *not* be effective. I've heard that people can use hex codes to inject stuff into your DB, addslashes won't stop this). 3. Use htmlentities on all output which has come from the user which is not meant to display as html (if you have a cms system you may want to display user input as html). This isn't just stuff out of the database. Take a search box. Most sites have a search box, and after the user has searched the results page displays the search term, eg 'You searched for "xxx"'. This search term never gets saved in the DB, but people can type JavaScript into the search box to create an iframe (which could show a competitors website). Not a major risk but can make you look quite amateur. Robin
  10. Hi, PFMaBiSmAd is right. Gziping your script / output is basically pissing in the wind here and won't help you. Your program as is will time out with 100,000 rows in the database. I think you need to provide a detailed account of what you want your script to achieve, as your whole approach seems wrong. Robin
  11. <?php $string = 'this is a string&more=this is some more stuff'; if(($pos = strpos($string, '&')) !== false) $string = substr($string, 0, $pos);
  12. Hi, What are you trying to accomplish? Will a user view this page or is it just some kind of automated maintenance script? If it's a maintenance script then viewing via the web is the wrong way to go about this. Robin
  13. Hi, Are you really looping through all 2000 rows in the database table in that script? If so thats always going to be slow.
  14. Hi, As the previous poster pointed out you need to use a technique called recursion: http://en.wikipedia.org/wiki/Recursion_(computer_science). Recursion is cross language, and is usually implemented as a function which calls itself. This is one of the more complex techniques in programming, and some people never understand it. Here is an example of the standard way to print the numbers 1 - 10: for($i = 1; $i <= 10; $i++) { echo $i . PHP_EOL; } To do the same using recursion, you could do the following: <?php function printNums($num) { if($num < 1) return; printNums($num-1); echo $num . PHP_EOL; } printNums(10); Note that the printNums function is recursive because it calls itself. In terms of looping through an array of unknown depth, you would probably need a function which took an array as the argument. If the function was passed and empty array, it would return. If the array was not empty, it would call itself with the arrays child array as the argument. Robin
×
×
  • 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.