Unknown column 'template_zip' in 'field list'

Hi all,

I’m not very good with PHP yet and struggling to find the issue here.
I have a custom CMS admin panel where I can upload PDFs to the site and it will detect that specific PDF for a specific product and generate a download button for it.

Why it was programmed specifically to PDFs and exclusive of other file types such as ZIP I do not know.

I’m in need of an option to upload a ZIP file instead of the PDF.
I was not seeing how to program it to do either (though I’m open to that option), so I decide just to copy a different ZIP upload, rename it and use it as an alternative to the PDF upload button in question.

I have the ZIP file actually uploading to where I’m telling it to go.
BUT, the admin page upon upload, instead of going back to that admin page, goes to a white page that reads “Unknown column ‘template_zip’ in ‘field list’”. On the actual webpage the users can see, the button never shows up, though if I type in the path directly to the ZIP file, it does download for me. So, I’m part way there, but something just isn’t firing correctly and I am unable to track it down.

Hope this is all making sense. :slight_smile:

The error msg I get sounds like it is indicating the problem lies where the PHP Initializes the Fields.
I have added the new ZIP to that list. Is the list required to be in any certain order?

Any suggestions as to where to look?
I can post code, but I’m not even sure what to post without just doing the whole big thing.

Hope this makes sense enough to get some feedback.
Thanks for any help!

Start by looking thru the script to find places where “pdf” is found; then post those portions of the script (include about 5 lines before and after)

Hey litebearer, thanks for your response. There are some big chunks split into a few sections, but here it goes.
On the bottom half of this array, you’ll see 2 zips followed by 4 pdfs.
I added in the “template_zip”. Basically, I took “image_zip” and tried to duplicate it and situated it near all the PDF stuff.

/* ---------------------- Initialize Fields ---------------------- */

if(isset($_REQUEST["id"]) && $_REQUEST["id"] > 0)
{
	$id = $_REQUEST["id"];											
	$fetchquery = "select * from products where id= '".$id."'";
	$result = mysql_query($fetchquery) or die(mysql_error());
	if(mysql_num_rows($result) > 0)
	{
		while($row = mysql_fetch_array($result))
		{
				$cid=$row['cid'];
				$sid=$row['sid'];
				$name=$row['name'];
				$image_path=$row['image_path'];
				$pricing=$row['pricing'];
				$overview=$row['overview'];
				$spec=$row['specs'];
				$access=$row['access'];
				$old_access = $row['access'];
				$a_la_carte=$row['a_la_carte'];
				$old_a_la_carte=$row['a_la_carte'];
				$fcontent=$row['full_content'];
				$fullcontent=stripslashes($row['content']);
				$display_order=$row['display_order'];
				$keywords=$row['keywords'];
				$image_zip=$row['image_zip'];
				$template_zip=$row['template_zip'];
				$tpdf=$row['tpdf'];
				$spdf=$row['spdf'];
				$bpdf=$row['bpdf'];
				$ppdf=$row['ppdf'];
				$audio=$row['audio_file'];
				$title=$row['title'];
				$copy_as = $row['copy_as'];
				$a_la_carte_copy_as = $row['a_la_carte_copy_as'];
				$pproduct_list = $row['pproduct_list'];
				$a_la_carte_pproduct_list = $row['a_la_carte_pproduct_list'];
		}
	}
	
}

Skipping down thru the code to the next relevant part there is this section.
The zips and pdfs appear a few times throughout this part of the code.

if($_FILES["izip"]["error"]> 0)
		{
			
		}
		else
		{
			$image_zip=rand(1,999).trim($_FILES["izip"]["name"]);
			move_uploaded_file($_FILES["izip"]["tmp_name"],"../product_pdf/".$image_zip);
		}
		if($_FILES["tzip"]["error"]> 0)
		{
			
		}
		else
		{
			$template_zip=rand(1,999).trim($_FILES["tzip"]["name"]);
			move_uploaded_file($_FILES["tzip"]["tmp_name"],"../product_pdf/".$template_zip);
		}
		$tpdf_path="";
		if($_FILES["tpdf"]["error"]> 0)
		{
		
		}
		else
		{
			$tpdf_path=rand(1,999).trim($_FILES["tpdf"]["name"]);
			move_uploaded_file($_FILES["tpdf"]["tmp_name"],"../product_pdf/template_pdf/".$tpdf_path);
		}
		$spdf_path="";
		if($_FILES["spdf"]["error"]> 0)
		{
		
		}
		else
		{
			$spdf_path=rand(1,999).trim($_FILES["spdf"]["name"]);
			move_uploaded_file($_FILES["spdf"]["tmp_name"],"../product_pdf/setup_pdf/".$spdf_path);
		}
		$bpdf_path="";
		if($_FILES["bpdf"]["error"]> 0)
		{
		
		}
		else
		{
			$bpdf_path=rand(1,999).trim($_FILES["bpdf"]["name"]);
			move_uploaded_file($_FILES["bpdf"]["tmp_name"],"../product_pdf/brochure_pdf/".$bpdf_path);
		}
		$ppdf_path="";
		if($_FILES["ppdf"]["error"]> 0)
		{
		
		}
		else
		{
			$ppdf_path=rand(1,999).trim($_FILES["ppdf"]["name"]);
			move_uploaded_file($_FILES["ppdf"]["tmp_name"],"../product_pdf/".$ppdf_path);
			echo '';
		}
		$audio_path="";
		if($_FILES['audio']['error']>0)
		{
			
		}
		else
		{
			$audio_path=rand(1,999).trim($_FILES["audio"]["name"]);
			move_uploaded_file($_FILES["audio"]["tmp_name"],"../product_pdf/".$audio_path);
			echo '';
		}
		
		$image_path="";
		if($_FILES["image_path"]["error"]> 0)
		{
		
		}
		else
		{
			$image_path=rand(1,999).trim($_FILES["image_path"]["name"]);
			move_uploaded_file($_FILES["image_path"]["tmp_name"],"../product_image/".$image_path);
			
		}
			if(isset($_REQUEST['mode']))
		{
			switch($_REQUEST['mode'])
			{
				case 'add' :
				$query = "insert into products set
				cid='$ncid',
				sid='$nsid',
				name='$nname',
				pricing='$npricing',
				overview='$noverview',
				specs='$nspecs',
				access='$naccess',
				a_la_carte='$na_la_carte',
				copy_as ='$copy_as',
				pproduct_list = '$pproduct_list',
				a_la_carte_copy_as ='$a_la_carte_copy_as',
				a_la_carte_pproduct_list = '$a_la_carte_pproduct_list',
				tpdf='$tpdf_path',
				spdf='$spdf_path',
				bpdf='$bpdf_path',
				ppdf='$ppdf_path',
				image_path='$image_path',
				full_content='$fcontent',
				content='$fullcontent',
				display_order='$display_order',
				image_zip='$image_zip',
				template_zip='$template_zip',
				keywords='$keywords',
				title='$title'";
				
			
					mysql_query($query) or die(mysql_error());
					location("manage_pproduct.php?msg=1");
				break;
				
				case 'edit' :
					
					$change="";
					if($cid!=$ncid)
					{
						$change.=", Category";
					}
					if($sid!=$nsid)
					{
						$change.=", Subcategory";
					}
					if($pricing!=$npricing)
					{
						$change .=", Pricing";
					}
					if($overview!=$noverview)
					{
						$change.=", Overview";
					}
					if($spec!=$nspecs)
					{
						$change.=", Specifications";
					}
					if($access!=$naccess)
					{
						$change.=", Accessories" ;
					}
					if($a_la_carte!=$na_la_carte)
					{
						$change.=", Alacarte" ;
					}
					$query = "update products set
					cid='$ncid',
					sid='$nsid',
					name='$nname',
					pricing='$npricing',
					overview='$noverview',
					specs='$nspecs',
					access='$naccess',
					a_la_carte='$na_la_carte',
					copy_as ='$copy_as',
					pproduct_list = '$pproduct_list',
					a_la_carte_copy_as ='$a_la_carte_copy_as',
					a_la_carte_pproduct_list = '$a_la_carte_pproduct_list',
					full_content='$fcontent',
					content='$fullcontent',
					display_order='$display_order',
					keywords='$keywords',
					title='$title'";
					if($image_zip!='')
					{
						deletefull($id,'image_zip');
						$query.= ", image_zip='$image_zip'";
						$change.=", Image Zip";
					}
					if($template_zip!='')
					{
						deletefull($id,'template_zip');
						$query.= ", template_zip='$template_zip'";
						$change.=", Template Zip";
					}
					if($tpdf_path!='')
					{
						deletefull($id,'tpdf');
						$query .= ", tpdf='$tpdf_path'";
						$change.= ", Template PDF";
					}
					if($spdf_path!='')
					{
						deletefull($id,'spdf');
						$query.= ", spdf='$spdf_path'";
						$change.=", Setup PDF";
					}
					if($bpdf_path!='')
					{	
						deletefull($id,'bpdf');
						$query.= ", bpdf='$bpdf_path'";
						$change.=", Brochure PDF";
					}
					if($ppdf_path!='')
					{
						deletefull($id,'ppdf');
						$query.= ", ppdf='$ppdf_path'";
						$change.=", Page PDF";
					}
					if($audio_path!='')
					{
						$query.= ", audio_file='$audio_path'";
						$change.=", Audio File";
					}
					if($image_path!='')
					{
						deletefull($id,'image_path');
						$query.= ", image_path='$image_path'";
						$change.=", Image";
					}
					$udate=date('Y/m/d');
					$query.=" ,updates='$change',udate='$udate' where id=".$_REQUEST['id'];
				
					mysql_query($query) or die(mysql_error());
					location("manage_pproduct.php?msg=2");
				break;
				
			}	
		}

Following that part, there is a section of the code for Deleting the uploaded files. Doesn’t seem relevant so I’m leaving it out. If you want to see it I can add it on later.

And then down in the Body, there is a Form that contains this part of the mark-up:

<tr>
								<td align="right" class="f-c"><span style="color:#FF0000">*</span>Template PDF: </td>
								<td width="71%" class="f-c"><input type="file" name="tpdf" id="tpdf" />
								<?php if($tpdf!='')
								{
									echo $tpdf;
								?>
								&nbsp;&nbsp;<a href="delete_image1.php?id=<?php echo $id; ?>&type=tpdf">Delete Template PDF </a>
								<?php } ?>
								 </td>
								</tr>


                                <!--  Template ZIP Addition  -->
                                <tr>
                                  <td align="right" class="f-c">Template ZIP Option:</td>
							<td width="71%" class="f-c"><input type="file" name="tzip" id="tzip" />
							<?php if($template_zip!='')
							{ echo $template_zip;
							?>&nbsp;&nbsp;<a href="delete_image1.php?id=<?php echo $id; ?>&type=templatezip">Delete Template Zip</a>
							<?php } ?>
							</td>
							</tr>
                                <!--  END Template ZIP Addition  -->

							<tr>
								<td align="right" class="f-c"><span style="color:#FF0000">*</span>Set-Up PDF: </td>
								<td width="71%" class="f-c"><input type="file" name="spdf" id="spdf" />
								<?php if($spdf!='')
								{
									echo $spdf;
								?>&nbsp;&nbsp;<a href="delete_image1.php?id=<?php echo $id; ?>&type=spdf">Delete Set-Up PDF</a>
								<?php } ?>
								</td>
								</tr>
							<tr>
								<td align="right" class="f-c"><span style="color:#FF0000">*</span>Brochure PDF: </td>
								<td width="71%" class="f-c"><input type="file" name="bpdf" id="bpdf" />
								<?php if($bpdf!='')
								{ echo $bpdf;
								?>&nbsp;&nbsp;<a href="delete_image1.php?id=<?php echo $id; ?>&type=bpdf">Delete Brochure PDF</a>
								<?php } ?>
								</td>
								</tr>
								
								<tr>
								<td align="right" class="f-c"><span style="color:#FF0000">*</span>Price Page PDF: </td>
								<td width="71%" class="f-c"><input type="file" name="ppdf" id="ppdf" />
								<?php if($ppdf!='')
								{ echo $ppdf;
								?>&nbsp;&nbsp;<a href="delete_image1.php?id=<?php echo $id;?>&type=ppdf">Delete Pricebook Page PDF</a>
								<?php } ?>								
								</td>
								</tr>
						<tr><td align="right" class="f-c">Image Zip:</td>
							<td width="71%" class="f-c"><input type="file" name="izip" id="izip" />
							<?php if($image_zip!='')
							{ echo $image_zip;
							?>&nbsp;&nbsp;<a href="delete_image1.php?id=<?php echo $id; ?>&type=imagezip">Delete Image Zip</a>
							<?php } ?>
							</td>
							</tr>
				 			<tr><td align="right" class="f-c">Upload Audio:</td>
							<td width="71%" class="f-c"><input type="file" name="audio" id="audio" />
							<?php if($audio!='')
							{
								echo $audio;
							?>&nbsp;&nbsp;<a href="delete_image1.php?id=<?php echo $id; ?>&type=audio">Delele Audio</a>
							<?php } ?>
							</td>
							</tr>