Jump to content

psjtk

Members
  • Posts

    23
  • Joined

  • Last visited

psjtk's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Okay, so now I no longer get the error from my server, but the PHP file doesn't create the csv file anymore.
  2. Okay, I'm getting the foreach error again: [20-Feb-2013 05:39:37] PHP Warning: Invalid argument supplied for foreach() in /home1/asthmavi/public_html/demogstore.php on line 13
  3. ::smacks head:: thanks AyKay.
  4. Hi jazzman, I inserted the code as you suggested. <?php // decode JSON string to PHP object $timestamp = json_decode($_POST["timestamp"]); $decoded = json_decode($_POST["json"], true); echo '<pre>'.print_r($decoded, true).'</pre>; $fp = fopen('PHP_data/'.$timestamp.'_data.csv', 'a'); foreach ($decoded as $fields) { fputcsv($fp, $fields); } fclose($fp); ?> It creates a syntax error: [20-Feb-2013 05:14:04] PHP Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home1/asthmavi/public_html/demogstore.php on line 10
  5. Also, I double checked my permissions - everything is set to "read, write, and execute."
  6. So just to update everyone on what happened. This is a project I'm working on at a university. The server is owned by someone who has allowed me to use it for this project, but I don't have access to the web root directory. So, I uploaded the the files to a new server in the web root directory. I no longer have the issue that Jessica and everyone else pointed to, re: the missing of a layer in the path. I'm reposting my code below: This is the Javascript on the html document that gets all the values from the form when the submit button is pressed: //FUNCTION: Button press var demogCont = function(){ var timestamp = new Date().getTime(); var age = document.getElementById('age').value; var freq = document.demographics.item1.value; var time = document.demographics.item2.value; var eng = document.demographics.eng.value; var demogs = [[age, freq, time, eng]]; var JSONdemogs = JSON.stringify(demogs); var postArray = {timestamp:timestamp, json:JSONdemogs}; $.post("demogstore.php", postArray, function(){ window.open('demographics2.html?demog=true&ts='+ timestamp,'_self',false); } ) .error( function(){ alert('Communication error with server.'); window.open('demographics2.html?demog=true&ts='+ timestamp,'_self',false) } ) }; This is the PHP file, with the assoc parameters set to TRUE as AyKay recommended. <?php // decode JSON string to PHP object $timestamp = json_decode($_POST["timestamp"]); $decoded = json_decode($_POST["json"], true); $fp = fopen('PHP_data/'.$timestamp.'_data.csv', 'a'); foreach ($decoded as $fields) { fputcsv($fp, $fields); } fclose($fp); ?> The PHP file now creates the .csv files, but my issue is that the csv files are now empty. It's not posting the values it gets from the HTML file. Here is the error I get from my server: [20-Feb-2013 03:38:10] PHP Warning: Invalid argument supplied for foreach() in /home1/asthmavi/public_html/demogstore.php on line 12 Any ideas? Thank you again, everyone who has been trying to help.
  7. Hi Jazzman, that's a good idea. I don't have access to the .com directory - I'm asking the server owner for permission. I'll move the /study-info folder there and let everyone know what happens. @Dodge The error I posted previously is from the error log on my server but it's old.
  8. re: one layer of difference - that is really strange and I am not sure why - all the files are in the com/leeds/study-info/ directory but for some reason the ftp urls of all the files in that directory give com/study-info/ leaving out one layer. When I want to access the files I use the .....com/leeds/study-info/file.html url and that allows me to access the first html file from which I then move in succession through all the other html files so the server seems to retrieve those without a problem. Even the error that says that the php file isn't found is reporting the correct path to it so it seems that the server is looking in the right location (com/leeds/study-info/). Could it be an ftp issue then and is there something I can do to change what my ftp client thinks is the url-path?
  9. Hi jazzman, these files are not meant to be for the wordpress site - I wrote a couple of html documents linked together that I want people to go through before the last one links them to my wordpress site. That means these are standalone pages.
  10. Hi Jessica, I'm pretty new at this, so if it's a stupid error - fine, I accept that. I have absolutely no idea what's missing - been at this for several days.
  11. ftp://psjtk@measured-response.com@measured-response.com/study-info/demogstore.php
  12. Hi jazzman, the error I'm getting is recording a correct file path. The file path is http://measured-response.com/leeds/study-info/demogstore.php It seems like the error is saying file does not exist in the folder /study-info, but the file is there.
  13. Hi jazzman, demogstore is in the directory. See this:
  14. This is the feedback that I'm getting:
  15. Yes, all the permissions are set to read, write, and execute.
×
×
  • 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.