Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/09/2020 in all areas

  1. // recursive function to trim data function _trim($val){ if(is_array($val)){ return array_map('_trim',$val); // recurse if an array } else { return trim($val); // call php's trim function, if not an array } } $post = []; // define an array to hold a trimmed, working copy of the submitted form data // inside the form processing code, get a trimmed copy of the submitted form data $post = array_map('_trim',$_POST); // you would refernce the elements in $post in the rest of the code, i.e. $post['search_products']
    1 point
  2. You should spend some time learning about... well, the basics. Then you should be able to see what's wrong with what you're trying and know what the correct syntax is.
    1 point
  3. You cannot overwrite or delete a file from the client's computer. The user has to tell their browser that they want to overwrite, and that means a Save dialog.
    1 point
  4. Side note: glob() returns the path to each file according to the pattern you gave it. So all those filenames will look like /path/to/directory/foo.txt. What the client (C++) needs to know is the URL to hit on the server; if every file is in the same directory (which it sounds like it is) then you can get just the file names with basename(). Since you're working from C++, and by the way this is all something doable scriptable a shell and without the use of a compiled program, you'll want to make this all as simple as possible. The server should return just a plaintext list of filenames. You can read each line, get the filename, then download the file. <?php header("Content-Type: text/plain"); foreach (glob("/path/to/directory/*.txt") as $path) { echo basename($path), "\n"; } You still have the problem of having to send an HTTP request to the server and reading the response...
    1 point
  5. You should be getting at least a notification as the 'status' array in the response doesn't have a 'tickets' index. Check your data nodes before attempting to output anything, and make the code more explicit in what it's trying to do: $return = json_decode($response, true); if($return['status'] == 'success' && !empty($return['data']['tickets'])){ foreach($return['data']['tickets'] as $ticket){ echo $ticket['ticketNumber'].' - '; echo $ticket['title'].' - '; echo $ticket['content'].'<br />'; } } If the call fails, I assume 'status' will not be 'success' and 'tickets' will be empty - the above will stop your program from crashing at that point.
    1 point
This leaderboard is set to New York/GMT-05:00
×
×
  • 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.