Jump to content

btherl

Staff Alumni
  • Posts

    3,893
  • Joined

  • Last visited

Everything posted by btherl

  1. The same way you use php to construct html. There's a few different styles of that. For example print '<script type="text/javascript">"; print 'alert('Hi there');'; print '</script>';
  2. Hmm. You cannot have php code that executes within javascript. But you can use php to dynamically generate code that is later executed by javascript. If you want to execute php code after the javascript has begun execution, then you need to use ajax techniques to call the php code on the server. The reason for all this is that php is server side and javascript is client side (it runs in your browser).
  3. I've read your description and your code and I still don't understand ??? Can you post an example of the date format you are using, and point out the problems with it?
  4. The functions you listed are fine for UTF8 in MOST cases. UTF8 extends ascii by using characters with the high bit set, so as long as you are dealing only with the standard ascii character set, you are ok. Basically, most functions will treat your utf8 extended characters as binary data and ignore them. For example, stripslashes() deals with the character '\', which is standard ascii, so it is safe. But calling trim() to trim a character above 0x7f may corrupt your UTF8. Standard trim() is fine Functions like mysql_real_escape_string() are binary-safe, so you do not need to worry what encoding you are using. binary safe - mysql_real_escape_string() http://il2.php.net/manual/en/function.mysql-real-escape-string.php safe - stripslashes() http://il2.php.net/manual/en/function.stripslashes.php ? - addslashes() http://il2.php.net/manual/en/function.addslashes.php safe - strstr() http://il2.php.net/manual/en/function.strstr.php safe for input < 0x7f - trim() http://il2.php.net/manual/en/function.trim.php ? probably safe - wordwrap() http://il2.php.net/manual/en/function.wordwrap.php safe - vsprintf() http://il2.php.net/manual/en/function.vsprintf.php safe - nl2br() http://il.php.net/manual/en/function.nl2br.php I don't think addslashes makes much sense on UTF8. I would avoid it if possible. Whatever you use addslashes for can be replaced with more specific escaping. Note that trim() will only trim ascii whitespace, and will not trim any UTF8 characters that are "whitespace". You'll have to do that yourself if you happen to have some of those.
  5. What code do you use to check the password? Make sure you include any processing done to the inputs, such as stripslashes()
  6. Can you try this out? <script type="text/javascript"> function refresh_parent() { window.parent.location.href = window.parent.location.href; }</script> Then you can call that javascript function somewhere in your iframe. For example: <input type=button onclick='refresh_parent()'> Not sure if that will work.. and it may not be browser independent, but it's worth a try!
  7. It looks to me like you are adding the castle to the castles array based on $prev_proi, which increments every time through the loop. Instead, you should add the castle inside the first if statement. In fact, you can do everything in there - Put guards in the castle, and put castle in the castle list. Then you empty out the castle and guard lists and initialize them for the new castle (which is in the current loop iteration). If (new castle) { Put guards in the castle Put castle in the castle list Initialize new castle and guard lists } if (new guard) { Put guard in the guard list } There's no need to put the guards in the castle when finding a new guard, only when finding a new castle.
  8. Did you use a user-defined function to find jdelacruz? If so, alter that function to return the array key as well. If you want us to help, post your current code.
  9. Sorry, I'm tripping.. I meant to say $$varname = 'Value';
  10. If Berkeley DB is available you can use that. You can also store the data in text files if all else fails.. but how you structure those depends very much on what data you need to store, and how you want to access it. Berkeley db info here: http://sg.php.net/manual/en/ref.dba.php
  11. Those are generated by the browser, not the script.. the only way to stop them is to ask the user to switch them off.
  12. You can do this: $n = 1; $varname = 'Variable' . $n; $$n = 'Value'; print $Variable1; The "$$" is what allows it to work. The other option is using eval(), but there's no need for that in this case.
  13. Ooh, you want your iframe to trigger the parent's reload. No it can't be done with headers, but i am pretty sure it can be done with javascript. Unfortunately I'm hazy on how it works. A google for "iframe access parent" turns up sites like this: http://www.esqsoft.com/javascript_examples/iframe_talks_to_parent/ The value you want to set is probably "document.parent.location".. again I am hazy on that. "iframe refresh parent" also shows up useful stuff in google.
  14. If you are trying to refresh the page without refreshing the iframe, then no that is not possible. An iframe is "part of" the main page. But I see no reason why you cannot use the location header early to abort the current page processing, and redirect to the alternate page which has everything you want. btw, relative "location" headers are not standard, so it's safer to give a full url instead (you can extract the correct url from $_SERVER variables). Another option you may consider is using javascript to edit the div and put the name there. Javascript can edit any virtually any part of a page without requiring a reload.
  15. Hi! Actually the method you are using for dup detection is what I use all the time. I don't think there is any more elegant way. Just remember that the final item will must be added manually following the loop! Because the test against the previous item is not made for the final item, as there is nothing following it .. while (get a row) { if (row != previous row) { add to array } } Add final row to array Also I notice you have no "order by" in your sql. That's essential if you're going to do duplicate detection like that. The order by should match the structure you are building. If you want the array to be associative, use something like $castles[$cn] = $castle instead of array_push(). Apart from that, the idea is sound, so I am sure you will get it working!
  16. This works for me: $url = 'http://www.youtube.com/watch?v=kP5rpxEhTsw'; if(!preg_match("~http://www.youtube.com/watch\?v=\w+~", $url)){ print "Failure \n"; } else { print "Success :)\n"; }
  17. $num = $max_value -$min_value + 1; $query1 = mysql_query("SELECT * FROM pagination ORDER BY id LIMIT $min_value, $num"); while ($row = mysql_fetch_assoc($query1)){ echo "ID Number: {$row['id']}<br>Name: {$row['name']}<br>Age: {$row['age']}<br>Referer: {$row['referer']}<br>-----------------------------------------------------<br>"; } Give that a try and let us know how it goes. My mysql syntax is a bit rusty, as i'm a postgres user.
  18. Ok, makes sense. Does it really matter if the user refreshes, since the user never knows what the computer has guessed? If you don't want the guess to change, you could do something like this: if (user made a guess) { Check guess Update score Generate new guess } else { Do nothing. Keep the old guess. }
  19. When a function returns a value, you need to set that value to a variable. For example: $max_value = max_ammount($getpage,2); $min_value = next_number($getpage);
  20. We can't give you any more detailed help unless you describe your game's structure in more detail. You can reset the session counter any time you want. Just $_SESSION['counter'] = 0.
  21. Try printing out this: print urlencode($_POST['headline']); \r will show up as %0d, and \n will show up as %0a. Then check to see if it's what you expect. You might want to look at nl2br() as well. You can always strip out the \n and \r after using nl2br().
  22. Compression (such as mod_gzip or zlib.output_compression) will buffer output, even if php is not buffering it. Even if you have zlib output compression enabled in the config but disable it at runtime, your output will STILL be buffered. You might want to try ob_implicit_flush() if you haven't already..
  23. The simplest method I can think of is to set a session variable. If you're not familiar with sessions, it's time to learn They are very useful things. If you set the session variable when the form is first submitted, then you can test it the second time and recognize that something is awry.
  24. Suggestion 3: parse_str($string, &$array); print_r($array);
  25. The SORT_NUMERIC option should do the trick.. http://sg2.php.net/manual/en/function.array-multisort.php
×
×
  • 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.