Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About FreakingOUT

  • Rank
    Regular Member
  1. FreakingOUT

    Conversion of text data from $variables issue

    Thanks for your replies. There is no problem with retrieving the data from MySQL, which I also verified echo'ing the $variables via the assignments from the mysqli query. These printed fine on the screen (inside a <textarea> box). The actual text content (inside example $text1 and $text2) is clean as a whistle. I then (manually) typed that same (real) data text inside of double-quotes into the same $data (array) which uploaded everything fine to a "Realtime Processing" destination with verified acceptance. There are passwords and and a special API involve, but the end result cannot be viewed by here --- because it displays on a 3rd party private password protected web system. I've used the same browser involved to successfully make things work WHEN I (manually) put the text content into the 2 fields (other fields in the array are for confidential email address, password & the API key. FYI, I continually ran all the PHP & MySQL combo code through a Code Checker each time I tried something different, with the result being "No Issues Found". THAT is what baffles me. What I will have to do is redact or <snip> all confidential info from the code (on another computer), and use some dummy field and data names/content to maintain Confidentiality. - FreakingOUT
  2. ARRAY Example scaled down to two (renamed example only) fields $data = array( "field1" => "Text within quotes processes OK", "field2" => "Text within quotes processes OK" ); The frustating thing has been trying to figure out how to substitute actual text data contained in these 2 example variables to use data from a MySQL query: $text1 = $db_field['sampletext1']; $text2 = $db_field['sampletext2']; I have tried: $data = array( "field1" => $text1, "field2" => $text2 ); *** (AND) *** $data = array( "field1 => '$text1', "field2 => '$text2' ); But neither approach works, even though the text in both $text1 and $text absolutely works IF I (manually) type the actual text within double-quotes like this: $data = array( "field1 => "text1", "field2 => "text2" ); I also tried using strval but that did not work. So how on earth to get the (actual) text from $text1 and $text2 into the two array fields as-if the contained text would (manually) be typed in double-quotes is the Mystery. It is probably something simple, so maybe I don't know exactly what to search for in seeking code snippet examples? Thanks for any enlightenent. -FreakingOUT
  3. Sorry, had problems logging back in here and other stuff hitting the fan. It turns out part of my problem was apparently fgetcsv will not work on my ISP's "Dark Ages" version of PHP and they will not upgrade ;-( Someone else came up with a workaround, but the initial php://input suggestion was indeed an accurate first step in the food chain, so thanks again !!! -FreakingOUT
  4. Finally .. this at least works as a starting point and verified the data is received: $entityBody = file_get_contents('php://input'); - FreakingOUT Top
  5. Hours of trying various things but nil. I came back to this possibility before calling it quits after hours and hours ;-( <?php $myfile = fopen("php://input", "r") or die("Unable to open file!"); echo fread($myfile,filesize("php://input")); fclose($myfile); ?> Yielded the following with still no uploaded data being displayed: Warning: filesize() [function.filesize]: stat failed for php://input in /home/............./test.php on line 3 Warning: fread() [function.fread]: Length parameter must be greater than 0 in /home/............./test.php on line 3 on line 3 -FreakingOUT
  6. print_r($_SERVER) .......... output is lots of Server, Gateway, Port, etc. Info. I'm still trying some other code snippet, but this is very frustrating ;-(
  7. I must still be missing something. Tried the following but still "No Joy" NOTE: Added the first 2 lines and there is definitely a connection as the (Remote) IP address displayed OK: <?php $ipaddress = $_SERVER["REMOTE_ADDR"]; echo "$ipaddress"; $row = 1; if (($handle = fopen("php://input", "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $num = count($data); echo "<p> $num fields in line $row: <br /></p>\n"; $row++; for ($c=0; $c < $num; $c++) { echo $data[$c] . "<br />\n"; } } fclose($handle); }; ?> So I remain "Baffled in Bytesville". - FreakingOUT
  8. Ahhh... very interesting. Will give it a try. THANKS !!! - FreakingOUT
  9. Thanks, requinix. I've found several examples, but still am baffled about how to use since I do not believe an actual 'filename.csv' file is uploaded - only a .csv record line (or multiple records). Nothing in the Java App upload actions I have monitored via a Command Prompt windows indicate a filename. So I'm still "Stuck up in Lodi again" (old Creedence Clearwater Revival lyrics) on how to integrate the requisite code to simply append each incoming csv format record line (as is- with commas) to a local server 'somename.csv' file.' fopen() example: $myfile = fopen("webdictionary.txt", "r") or die("Unable to open file!"); echo fread($myfile,filesize("webdictionary.txt")); fclose($myfile); fgetscv() example: $row = 1; if (($handle = fopen("test.csv", "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $num = count($data); echo "<p> $num fields in line $row: <br /></p>\n"; $row++; for ($c=0; $c < $num; $c++) { echo $data[$c] . "<br />\n"; } } fclose($handle); } - FreakingOUT
  10. Thanks for your reply! I put both var_dump($_POST) and readfile("php://input" on the page, but only this displayed before and after another upload: array(0) { } This is the info about what apparently the Java App uses POST-request to upload data to WEB-server (Example of upload schema) POST /some_path HTTP/1.1 Content-type: text/csv; charset=ISO-8859-1 User-Agent: Jakarta Commons-HttpClient/3.1 Host: localhost:8080 Content-Length: 311 text1,text2,text3,text4 (etc) -can be multiple records per upload - FreakingOUT
  11. After searching postings on multiple forums, I am officially now "Freaking OUT" trying to understand something that is probably very simple, but cannot seem to grasp. I simply want to read basic .csv data that is sent/uploaded directly to a PHP page, and to then append each record that shows up to a single .csv file on the server. The incoming data is supposed incoming via $_POST['csv'] ... at least that's what I was told. Each.csv record line being sent/uploaded is very simple (either single or multiple records in one small file): text1,text2,text3,text4,text5 For additional processing I know about 'explode', etc., but right now I am stuck even trying to do an 'echo' to display the simple incoming data "as is". One option I tried was: $postdata = file_get_contents("php://input"); echo $postdata; In the Java App monitoring I get the following after 3 records are sent/uploaded to the PHP URL: Server response status line: HTTP/1.1 200 OK I find this strange since I did not include... http_response_code(200); ... in the page code. Obviously, I do NOT know what I am doing here {SIGH}. Any assistance or guidance is appreciated. Thank you ! - FreakingOUT
  12. OOOOOPS... And in conjunction with this in the page header...: <meta http-equiv="refresh" content="3600"> ... the desired content *should* always display automatically as desired and can easily be changed. No, that would limit the page refresh to one time per hour... DUH! Excuse the bandwidth. -FreakingOUT
  13. Hello, Barand: Once again you have kindly come to my rescue! As I was pouring through multiple lines of code in various function examples trying to figure out some type of 'reverse engineering', everything became a blurrrr on only 2 hours of sleep. Now I am blown away (again) by the simplistic elegance of your concise solutions. Another learning experience for me! I tested both and really appreciate the two options you provided. Using $pastdatetime in the PHP code will keep what is already a very lengthy $sql querey shorter. And in conjunction with this in the page header...: <meta http-equiv="refresh" content="3600"> ... the desired content *should* always display automatically as desired and can easily be changed. Thank you very, very much !!! -FreakingOUT <- (No more in this time related matter :^)
  14. I've been researching online resources and seen a lot of code and functions for calculating an interval or difference between two date/time figures. What I'm trying to do is somewhat in reverse... I want to establish an interval to determine a past date/time to be used in a MySQL Query but just can't figure the critical part. // STEP #1 = DEFINE THE DESIRED DATE/TIME DIFFERENCE INTERVAL DESIRED FOR QUERIES $timeinterval = '60'; // Interval is in MINUTES and can be changed as desired // STEP #2 = GET THE CURRENT LOCAL SERVER DATE/TIME // as YYYY-MM-DD HH:MN:SE $serverdatetime = date('Y-m-d H:i:s'); // My local Server Date & time // STEP #3 = CALCULATE THE ***PAST** (OLDER) DATE/TIME LIMIT BASED ON $timeinterval (Minutes) // as YYY-MM-DD HH:MN:SE $pastdatetime = [stuckinarut here] <- 60 MINUTES prior to current Server Date/Time // STEP #4 = MySQL QUERY (`submitted` column is auto-timestampped on record insertions) $sql="[columnsblahblah] FROM mydb WHERE `submitted` >= $pastdatetime"; In a Perfect World, the MySQL Query would yield ONLY records with a `submitted` DATE/TIME equal to 60 Minutes (or less) PRIOR TO from the Current Server Time. Any assistance is appreciated! Thanks. -FreakingOUT
  15. Thanks very much guys for the considerable Educational Enlightment here. Now my eyeballs are REALLY rolling :^) I reallly appreciate the feedback and insights. -freakingOUT

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.