Anyone see the error of my ways?

I know this isn't c++ but I was wondering if someone can help me with this. I am working towards a degree in CIS with a focus on development. I am just starting with a programming structure class, and I turned in a project a few days ago. The idea was to write a program that takes input from the user of: Order number, Item number, qty requested, and qty on hand. It was then to write to a shipping list, a backorder list, or both. I got it to work except, for some reason, it won't write to the files. The headers show up, but no data. It is driving me crazy as to where I went wrong. Any hint would be appreciated. Thank you very much


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
 // main 
 
   // input vars
   $orderNum = "";
   $itemNum="";
   $qtyReq=0;
   $qtyOnHand=0;
   
  
  prepFiles($fileOuta,$fileOutb);
  
   printf("\n Enter the order number or (0) to exit the program: " );
   fscanf(STDIN,"%s",$orderNum);
   
   while($orderNum != "0")
   {
	  	  calcQtys($qtyReq,$qtyOnHand,$ship,$backorder);
	      writeResults($fileOuta,$fileOutb,$orderNum,$itemNum,$ship,$backorder,$msg);
	      printf("\n Enter the order number or (0) to exit the program: " );
          fscanf(STDIN,"%s",$orderNum);
   }
   fclose ($fileOuta);
   fclose ($fileOutb);
   //end Main
   
   function prepFiles(&$fileOuta,&$fileOutb)
   {
	 //open output files 
     $fileOuta=fopen("ShippingReport.txt", "w")or die("Negative GhostRider!");
	 fprintf($fileOuta,"\n Tooth & Nail Hardware - Shipping Report");
	 fprintf($fileOuta,"\n\n Order Number    Item Number     Shipped    Message\n");
	 
	 $fileOutb=fopen("BackOrderReport.txt", "w")or die("Negative GhostRider!");
	 fprintf($fileOutb,"\n Tooth & Nail Hardware - BackOrder Report");
	 fprintf($fileOutb,"\n\n Order Number    Item Number     Backorder Qty\n");

   }
      
   
   function calcQtys(&$qtyReq,&$qtyOnHand,&$ship,&$backorder)
   {
	    $itemNum = "";
        $qtyReq = 0;
        $qtyOnHand = 0;
        $ship=0;
	    printf("\n Enter the item number or (0) to exit order %s: ", $orderNum );
        fscanf(STDIN,"%s",$itemNum);
        while($itemNum != "0")
        {
	        printf("\n Enter the Quantity Requested:");
            fscanf(STDIN,"%d",$qtyReq);
            printf("\n Enter the Quantity On Hand:");
            fscanf(STDIN,"%d",$qtyOnHand);
	        if($qtyOnHand!=0)
	        {
		        $ship=$qtyOnHand-$qtyReq;
	        }
		        else
		        {
			        $ship=0;
			        $backOrder=1;
		        }
		        printf("\n Enter the item number or (0) to exit order %s: ", $orderNum);
                fscanf(STDIN,"%s",$itemNum);
	     }
	       
	       
	     	   
	      
       
	   
   }
   
   function writeResults(&$fileOuta,&$fileOutb,&$orderNum,&$itemNum,&$ship,&$backorder,&$msg)
   {
	   $msg="";
	   $backorder=$qtyReq-$qtyOnHand;
	   $ship=$qtyOnHand-$qtyReq;
	   while($ship!=0)
	   {
	   	  if($qtyOnHand==0)
	       {
		   $msg="Out of Stock";
		   fprintf($fileOuta, "\n%s  %s  %d  %s",$orderNum,$itemNum,$ship,$msg);
		   fprintf($fileOutb, "\n%s  %s  %d",$orderNum,$itemNum,$backorder);
	       }
		     if($qtyOnHand<$qtyReq)
		      {
			    $msg="Partially Filled";
			    fprintf($fileOuta, "\n%s  %s  %d  %s",$orderNum,$itemNum,$ship,$msg);
		        fprintf($fileOutb, "\n%s  %s  %d",$orderNum,$itemNum,$backorder);
		      }
		    else
		      {
	       
		        $msg="Quantity Fulfilled";
			    fprintf($fileOuta, "\n%s  %s  %d  %s",$orderNum,$itemNum,$ship,$msg);
		      }
		  		   		      
	     }
	  
    }

 
   
 
//fscanf(STDIN, "%s", $intrinsic);
?>
Topic archived. No new replies allowed.