Jump to content

kicken

Gurus
  • Content Count

    3,960
  • Joined

  • Last visited

  • Days Won

    117

Everything posted by kicken

  1. IDE's don't run code, they just analyze it. In the code above, your IDE can't figure out what the name of the constant being created by the define call is because the name is a dynamic value returned by the strtoupper function. You might be able to configure VScodium to not treat this as an error. I use PHPStorm and it highlights this as just a Warning not an Error. To make the problem go away though you need to define your constants individually in a way the IDE can understand.
  2. It is if you're doing multiple posts like you are describing, but that's not how this is typically supposed to work. The typical sequence only involves one POST. You load a form using GET After filling out the form you submit it using POST The server saves the data from the POST and issues a redirect to another page. The basic idea is that your POST request returns a redirect, not a page to be displayed. If your POST request returns a page to display then trying to refresh that page requires re-sending the POST request, data and all.
  3. I ran both your C# code and PHP code from your original post with the same inputs: $key = '01234567'; $iv = "\x01\x12\x23\x34\x45\x56\x67\x78"; $value = 'param=value'; And I get the same output from each code: C# Output: sFi4JhEGhA4awvJPqeK0Gg== PHP Output: sFi4JhEGhA4awvJPqeK0Gg== So it would seem likely your issue is that you're just not using the same inputs for both codes and that's why you get different outputs. You seem unwilling to give any details on what inputs you're using though so it's not really possible to provide you any further help until you do. Generate a ne
  4. Are you specifically interested in just the debugging process with XDebug, or about general development? I've debugged remote code before and it's worked out just fine without any real issues that I can remember. You need to install XDebug on the web server and be able to open the debugging port on the web server so that PHPStorm can connect. If you can't do either of those (ie, shared hosting environment) then you'll have issues. Developing remotely is more annoying due to needing to sync the files in some way when you make changes. That's not really a PHPStorm specific problem thoug
  5. I don't use annotations, so N/A. PHPStorm will apply some basic formatting to doc blocks, but trying your sample annotation it doesn't seem to do anything with it outside of wrapping long lines. As far as style, do whatever you like, just be consistent.
  6. You can't execute a powershell script on the end-user's machine if that's what you're trying to ask. If you want the end-user to be able to trigger the script on your server then you just make a request the PHP script which will then execute the powershell script. You can make that request with a simple link or form button or you could do it via javacript in the background.
  7. postMessage serializes the data that you want to send. That means that for the most part, only simple data is able to be sent, not complex stuff like functions or objects with methods. What you need to do is define MyClass on both pages and give it a way to be serialized to a string or simple object on the sending page and then unserialized back into the full object of the receiving page.
  8. That would be the browser choosing this option: It's taking that raw binary data and interpreting it as a text string and displaying the results. Of course, the result is a bunch of nonsense because that raw binary data isn't supposed to be interpreted that way.
  9. In the original example: foreach ($queryResults as &$row){ represents the loop for your query results processing. That'd be your while loop. So you'd replace the foreach with your while loop, not put the foreach inside your loop. Using the while loop means you have to unset($row) at the end to break the reference before the next iteration also, otherwise the first row data would just keep getting overwritten by future rows. The foreach handles this by using & before the variable, the while loop doesn't. $tree=[]; $map=[]; while ($row = mysqli_fetch_array($query)) { /
  10. You'd have to write code specifically to interpret it and display it that way, it's not something that the browser would do by itself. Depends on what your doing with the result. If you're sending it to a browser, then it depends on whether or not you sent the correct Content-type header. If you did, the browser would render the image. If you didn't, the browser might guess and render the image, might display it as text, or might just offer it as a download.
  11. Yes, fundamentally it all begins as a binary stream of data. Your "What do I see?" question doesn't really make sense because what you see depends on how you decide to interpret that binary data. You can see whatever you want. If you take an JPEG image for example and open it in notepad you'll see that binary data interpreted as text and you'll just see random characters. Which characters specifically would depend on which character set you use. If you open it in a hex editor, you'll see individual bytes represented in hexadecimal format, maybe with ASCII characters along the sid
  12. Use usort rather than sort, then you can provide a comparison function and implement whatever logic you need to get the correct sorting. The comparison function will be given two items from the array ($a and $b) and must return a number that indicates if $a is less than $b (-1), they are equal (0), or $a is greater than $b (1). If your files all began with the date in Y-m-d format you'd be able to simply compare them. In m-d-Y format though you need to parse the date out of the name and then compare the date. usort($files, function($a, $b){ $a = basename($a); $b = basename($
  13. instead of that, make your data function return your games variable. return $games; Then you can assign it when you call your data function and access whatever you want. $game = new CsvToArray(); $games = $game->data(); echo $games[64]['Home Team']; Make it a function argument. function data($file){ $fileName = fopen($file,'r+'); ...
  14. Select all the posts for your thread in one sql statement. As you loop over the query results, build a tree structure using an array that has all the posts nested under their parent post. An easy way to do this is by using references. $tree=[]; $map=[]; foreach ($queryResults as &$row){ if ($row['ParentId']){ $map[$row['ParentId']]['children'][] = &$row; } else { $row['children']=[]; $tree[] = &$row; } $map[$row['id']] = &row; } After that the first level of $tree contains all your top level posts. The child posts of each of them are stored in a key called
  15. You have another syntax error there. Extra ).
  16. You have a syntax error here: You're missing your closing ) at the end of your call to prepare().
  17. That's what's happening to your first row. Every time you call fetch_assoc it returns the next row. You call it here to return the first row, but don't ever echo that row data out in the table anywhere. Remove that call and let your loop down below fetch the first row. Since it looks like you're calling it there so you can get the seller name, you'll have to come up with an alternative way to obtain that information or re-arrange your code so you can get the name and all the row data.
  18. PHP will create an array of the posted values if your name ends with []. <input type="hidden" name="draggables[]" id="draggable3"> <input type="hidden" name="draggables[]" id="draggable4"> <input type="hidden" name="draggables[]" id="draggable5"> In your PHP code you can then take that array of values and do whatever you need to with it. The reason your "change" didn't work in the original code is because you only changed the value of the variable x, not the value of the actual input element. Assigning the value to x doesn't link the two, it makes a copy. Cha
  19. Additionally, if the only thing your javascript is going to do is either redirect or show an error, then there's really no reason to use javascript / ajax at all. Just use a normal form process and keep it simple.
  20. It sounds like you might just need to re-consider your design. If it's the client that's interested in whatever this change is, the typical solution to this is to just have the client make a request periodically. One name for this is Ajax Polling. You make an Ajax request to your change detection script. The script will check for the change in a loop and return when a change is detected. You could wait 30 minutes, but it's more typical to wait 30-sec to a minute then return a "No changes" response. This way your web-server's available threads don't get used up waiting. If th
  21. You need to call session_start() before you use any $_SESSION variable. That function looks up the stored session data and populates $_SESSION.
  22. I downloaded your code and added that attribute and it seemed to be working fine after that. You need to add it to both the CSP and the iframe's sandbox attribute.
  23. What if 5 different users want to make the folder "puppy"? Do you just mix all their files in that folder? What if their files are also all named "cutest.jpg"? Whoever uploads last gets the spot? That's one of the main reasons I just always generate a random name for the actual storage system of uploaded content. You don't have to deal with conflicting names. I generally just do something simple like: $ext = pathinfo($originalName, PATHINFO_EXTENSION); $newName = bin2hex(random_bytes(8)) . '.' . $ext; If I want to serve the files directly. If I serve them via a script instead
  24. This may be your issue MDN: <iframe>: The Inline Frame element Try adding allow-same-origin to your sandbox attribute.
  25. I'd suggest you try re-encoding the file, maybe in another format, and see if it helps. Light web searching suggests your issue is just that there is no duration metadata available and also suggests that may be somewhat common for .ogg in particular.
×
×
  • 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.