Jump to content

kicken

Gurus
  • Posts

    4,704
  • Joined

  • Last visited

  • Days Won

    179

Everything posted by kicken

  1. setInterval (or a recursive setTimeout) is how you run something on a specific frequency. When you say it didn't work it's most likely you were just doing something wrong in your code, they both work fine. There may be a better way to do what you want, but we'd need more information detailing exactly what you want to do and how you want it done.
  2. Also note that the above is only true in <5.4. In 5.4.0 and newer, <?= will always work and is no longer tied to short tags.
  3. The uint32 fields would be one of these codes: l, L, N, or V The uint16 fields would be one of: s, S, n, or v The char field would be: c The int field could be any of the uint32, uint16, or i, I codes. As I said before, you need to determine what the byte order being used is. For stuff sent over a socket, Network Byte Order (big-endian) is common. If you can't find it anywhere in the documentation, debug the code to try and find out. You can google for ways to determine the byte order. One quick way to check would be to check the C code for calls to htons/htonl functions The format code x can be used to represent a nul character, or c + chr(0). PHP provides a special code for a nul-terminated string though (a), which is what would be used for the char arrays. pack('a20', $str); When generating $str you would ensure that it consists of only 19 characters (or less). PHP will nul chars to pad the string to 20 characters. Use strlen($packed). If you do all the packing correctly, it will equal 62.
  4. Use var div = $(this); var img = $("img", div); instead. You need to be limiting each iteration to the scope of the current element, which is provided by the this keyword.
  5. <?= is just a shortcut way of saying <?php echo, so that line is equal to: <?php echo $_POST['submitted'] ? "sorted by {$sortType}" : "unsorted"; ?> It will echo 'sorted by $sortType' if the post variable exists, otherwise it will echo 'unsorted'.
  6. I'm going to assume you mean it adds a \, not a /. In that case, it sounds like the problem server probably has magic_quotes enabled. You will need to either disable it via your php.ini if possible, or update your code to be able to handle that situation by checking for it using get_magic_quotes_gpc
  7. What I would do is create a class which will be able to either deconstruct a binary string using unpack, or construct a binary string using pack. Something like: class SPMSifHdr { private $synch1; private $synch2; private $version; private $cmd; private $bodySize; public __construct($params){ foreach ($params as $nm=>$v){ $this->$nm = $v; } } public static function createFromBinaryString($str){ $params = unpack("Nsynch1/Nsynch2/nversion/Ncmd/NbodySize", $str); return new self($params); } public function toBinaryString(){ return pack("NNnNN", $this->synch1, $this->synch2, $this->version, $this->cmd, $this->bodySize); } public function __toString(){ return $this->toBinaryString(); } } You'll need to make sure you use the correct codes for your bit length and byte order when you pack and unpack. The structure names imply an unsigned ints, one is 16-bits the others are 32-bits. You'll need to determine which byte order to use either from documentation or by checking the existing code.
  8. mt_rand - you can use that to just generate a random number. mt_srand - This seeds the random number generator with an initial value. Using the same seed will cause mt_rand to generate the same number date - This will let you get the current date. So, to get a random number that changes each day, seed the number generator with the current date and then call mt_rand.
  9. No, there is no limit on the length of a field sent via post in jQuery. Your issue is being caused either by your own code, or some kind of filter on your server. You need to do some debugging and trace the entire process from clicking the submit button to receiving your response in order to find out where the issue is at.
  10. Typecasting is just causes one value to be changed from one type to another type. If the value is already in the proper type, then it's a no-op (ie, nothing happens, the value is returned as-is).
  11. My best guess would be that your server is running mod_security and has a rule which is matching your Russian text somehow. You need to either disable mod_security or remove the rule. Check this post for some info: HTTP 406 Error Also note that you probably should be using $.post, not $.get. POST is more semantically correct for saving information, and it has no length restrictions like GET does.
  12. Those are not PHP code, they are shell commands. You'd SSH into your host and run them on the command line.
  13. You can't have multiple style attributes. Combine all the rules into a single attribute. Or better yet, add a class then define your rules in a stylesheet.
  14. Only the first true condition in a series of if/else if/else statements will have it's statements executed. All the rest of the branches will be skipped. It's just a nice way to write: if (a){ . } else { if (b){ . } else { if (c){ . } else { if (d){ . } else {} } } } What exactly are you trying to do with all these conditions? There may be a better way that doesn't involve so many if's.
  15. Not entirely sure what you are after, but it sounds like you want to do two things 1) Prevent a person from skipping ahead in a subject (ie, before they get to page 10, they have to visit page 9) and 2) Provide a continue button that takes them to whatever page they left off on. The way to do both of those is just to track what pages the user has visited. Whenever they visit one of the pages, run a query to update a table indicating they have visited that page. To prevent skipping, you'd add some code to query the visit tracking table to make sure they have visited the previous page in the subject. If not, either show an error or maybe redirect them to their continue point. To add the continue button, you'd query that visit table for the highest page in the subject that they have visited. Then either send them to that page or the next page, depending on what you want.
  16. Your database class doesn't provide any functionality for actually querying the database. The only thing it does is create and store a connection using mysqli. The getConnection method returns that connection so that your other code can then use it to actually do work with the database.
  17. Whatever is causing your issue of not being able to save 50 characters is likely not an issue with your field definition, but rather your code processing the data. Are you sure that you are only using 50 characters? Add debugging logic to your code so you can see exactly how long the string you are inserting is and also verify the SQL query you generate is valid.
  18. You need to add the X-Requested-With: XMLHttpRequest header. It is checking for that to validate that it is an ajax request. See CURLOPT_HTTPHEADER
  19. The length given to varchar does set the maximum byte length of what the field will store. How many characters this correlates to would depend on the charset in use but for plain English text usually it is about the same. As for what value you should use for a bio field, that depends on how long you want to allow a persons bio to be. If you want to allow someone to write a several page BIO about themselves then you'd probably want to use a TEXT type rather than varchar. If you want to keep the bio's short with just a few paragraphs then probably a 1000 length would be plenty. Either way you need to include a length check in your code so that if they exceed the allowed length they will get an error. Depending on what settings your mysql server is running with trying to insert a longer than allowed value may either cause an error or just silently truncate the value.
  20. PHP has GnuPG functions you can use to potentially re-implement whatever your current system command is doing using PHP. You'll need to check with your host to see if these functions are enabled. If they are not currently enabled, they may be more willing to enable them vs opening up system() to you.
  21. foreach ($_POST['emp'] as $empId=>$dateList){ foreach ($dateList as $date=>$textboxValue){ //... } }
  22. Potentially yes, if your server is poorly configured.
  23. Your query text is using ? placeholders, but your parameters array is using :name placeholders. You can't mix-n-match the two, you have to use one or the other in both places. Either change your queries to use the same :name placeholders, or remove them from your array and use just a simple numerically indexed array.
  24. Check your server's error log file. Likely you have a setup where errors get sent to a log file rather than displayed on screen. It happens on some CGI setups.
  25. nl2br Assuming the text has the new lines still when posted to your script
×
×
  • 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.