jjack46
-
Posts
2 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by jjack46
-
-
I'm attempting to pass a text string from a javascript process to a php process, using XMLHttprequest, and am getting an 'undefined array key' error. The php process should save the string to a file. It appears to pass the string to the php code okay as it returns the message 'File saved', but it also gives the error message 'undefined array key' on 'data' on line 2 of the php code. I appears to be saving a blank string to the text file as it overwrites any previous saved text in the file. So it looks like no data is being passed to the php codebut it is still try to save it. I'm no sure whether the problem is on the javascript side or the php side. The attached files are test code which reproduces the error. Clicking on the button in 'TestProgram.php will attempt to pass the test string to 'saveGame.php which should save the text string to 'test26.txt :-
Any help would be much appreciated.
Getting 'undefined array key' error passing data to PHP process thro XMLHttprequest
in JavaScript
Posted
I made a mistake when I submitted the topic. The variable in the $_POST(......) should have been "data" not "d" but it still has the same error. I didn't submit the code correctly I hope this is better . I am using $_POST as the string that gets passed can be quite long, up to 56 names.
This is a correct submission of the "TestProgram.php"
This is then supposed to pass the data to the "saveGame.php
The error occurs at line 6 ($outputString = $_POST["data"];) . It states that "data" is an 'undefined array key'. Screen shot of error attached.
Is it possible to edit a topic once it's been submitted. I couldn't find any help on it.
jjack46