473,394 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

printing $_POST data to text file

anfetienne
424 256MB
hi i've got this code that writes data to a text file. When i test it with a standard array eg array(1,2,3) it works perfectly fine but when i try it with $_POST['myData'] i get the error message

Warning: Invalid argument supplied for foreach() in /home/theau10/public_html/resources/captionSaveB.php on line 23

Warning: Invalid argument supplied for foreach() in /home/theau10/public_html/resources/captionSaveB.php on line 38

Warning: Invalid argument supplied for foreach() in /home/theau10/public_html/resources/captionSaveB.php on line 53

here is my code.....can someone point me to the incorrect code....i cant see where its going wrong

Expand|Select|Wrap|Line Numbers
  1. $file = "upload/$random_digit/gallery.txt";
  2. $imgHandle = fopen($file, 'w+') or die("can't open file");
  3.  
  4.     $iv= 1;
  5.     $lQ = ',';
  6.     $imgAry = $_POST['imageT'];
  7.  
  8.     $stringData = "&imgLoc=";
  9.     fwrite($imgHandle, $stringData);
  10.  
  11.         foreach($imgAry as $key => $value){
  12.             fwrite($imgHandle,$value .$lQ);
  13.         }
  14.  
  15. fclose($imgHandle);
  16.  
  17. $tmbHandle = fopen($file, 'a+') or die("can't open file");
  18.  
  19.     $iv= 1;
  20.     $tQ = ',';
  21.     $tmbAry = $_POST['thumbnailT'];
  22.  
  23.     $stringData = "&tmbLoc=";
  24.     fwrite($tmbHandle, $stringData);
  25.  
  26.         foreach($tmbAry as $key => $value){
  27.             fwrite($tmbHandle,$value .$tQ);
  28.         }
  29.  
  30. fclose($tmbHandle);
  31.  
  32. $capHandle = fopen($file, 'a+') or die("can't open file");
  33.  
  34.     $iv= 1;
  35.     $cQ = ',';
  36.     $capAry = $_POST['captionT'];
  37.  
  38.     $stringData = "&imgCap=";
  39.     fwrite($capHandle, $stringData);
  40.  
  41.         foreach($capAry as $key => $value){
  42.             fwrite($capHandle,$value .$cQ);
  43.         }
  44.  
  45. fclose($capHandle);
  46.  
Aug 24 '09 #1
4 2991
Dormilich
8,658 Expert Mod 8TB
it seems that the input values ($_POST['…']) are not arrays. you can check with var_dump().
Aug 24 '09 #2
anfetienne
424 256MB
on the form the names are set on imageT[], thumbnailT[] and captionT[].

once submitted i test to make sure that they are arrays and use print_r and they show as an array perfectly fine
Aug 25 '09 #3
Dormilich
8,658 Expert Mod 8TB
@anfetienne
even when you test it before the foreach loop?
Aug 25 '09 #4
anfetienne
424 256MB
yup even when i test it before the loop it shows that they are all arrays with all the values i enter from my form
Aug 25 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: billy.becker | last post by:
I need to save a wav file that is HTTP POSTed to a php page. What does PHP5 do automatically to a POSTed variable when it puts it in the $_POST superglobal array? I haven't been able to find any...
4
by: google | last post by:
I would like to print a table, using a while loop to insert as many blank text fields as players specified by the user. How do I put html inside a php loop. This is what I have.... <body>...
5
by: Tom | last post by:
I am converting an old application that was printing directly to a specialized printer device (i.e. a special label printer). It was doing this by opening a file with the file path of 'LPT1:' and...
1
by: hamil | last post by:
I am trying to print a graphic file (tif) and also use the PrintPreview control, the PageSetup control, and the Print dialog control. The code attached is a concatination of two examples taken out...
2
by: lisha | last post by:
I have code which generates html table on the fly and fills it up with data. i have to add a print button so that i am able to print the output in html table to the printer. Also, is it possible to...
10
by: sufian | last post by:
I am new to the world of PHP. Below is my simple PHP file "invite.php" with a form having an image send button (I have to use the image send button because it is the requirement, may be this is...
12
by: Todd Michels | last post by:
Hi all, I am trying to send data from a form and insert it into a MSSQL DB. When I submit the data I get: Warning: mssql_query() : message: The name "Todd" is not permitted in this context....
9
by: shreedhan | last post by:
Hi I'm recenlty studying PHP myself and I have got a problem in passing variables to one php script from another i have following code as index.php <?php $name=HREEDN ?> <html> <head>
2
by: keeps21 | last post by:
I have a script that recieves an id number via the address bar when a link is clicked. ie . index.php?id=1 if the link was for the story whose ID is 1. My script checks if a user is logged in,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.