garethhall Posted June 28, 2008 Share Posted June 28, 2008 Can someone please tell me what I am missing? This script was working then I did something and now it doesnt want to work. All I want is when the file is downloaded from the database till must be updated to. Please help Thanks G <?php require_once('../Connections/updateContent.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $maxRows_resumes = 20; $pageNum_resumes = 0; if (isset($_GET['pageNum_resumes'])) { $pageNum_resumes = $_GET['pageNum_resumes']; } $startRow_resumes = $pageNum_resumes * $maxRows_resumes; mysql_select_db($database_updateContent, $updateContent); $query_resumes = "SELECT * FROM Resumes ORDER BY applicantName ASC"; $query_limit_resumes = sprintf("%s LIMIT %d, %d", $query_resumes, $startRow_resumes, $maxRows_resumes); $resumes = mysql_query($query_limit_resumes, $updateContent) or die(mysql_error()); $row_resumes = mysql_fetch_assoc($resumes); if (isset($_GET['totalRows_resumes'])) { $totalRows_resumes = $_GET['totalRows_resumes']; } else { $all_resumes = mysql_query($query_resumes); $totalRows_resumes = mysql_num_rows($all_resumes); } $totalPages_resumes = ceil($totalRows_resumes/$maxRows_resumes)-1; $jobTbBg = " bgcolor='#E0EBED'"; $jobTbBgOther = " bgcolor='#C3D9DD'"; if(isset($_GET['id'])){ $id = $_GET['id']; $query = "SELECT fileName, fileType, fileSize, content FROM Resumes WHERE id = '$id'"; $result = mysql_query($query) or die('Error, query failed'); list($fileName, $fileType, $fileSize, $content) = mysql_fetch_array($result); header("Content-Disposition: attachment; filename=$fileName.doc"); header("Content-length: $fileSize"); //header("Content-type: $fileType"); application/msword header("Content-type: application/doc "); //echo $content; $queryUp = "UPDATE `NKR`.`Resumes` SET `downloaded` = 'Yes' WHERE `Resumes`.`id` = '$id' "; mysql_query($queryUp) or die ('Error connecting to Database please try again'); mysql_close($conn); exit; }; ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> <link href="adminStyle.css" rel="stylesheet" type="text/css" /> </head> <body><!-- #BeginLibraryItem "/Library/AdminTable.lbi" --><table width="100%" border="0" cellpadding="0" cellspacing="0" id="adminTbl"> <tr> <td colspan="6"><img src="../img/mainLogo.gif" alt="" width="487" height="129" /></td> </tr> <tr> <td colspan="6" align="right" ><div align="right"><span class="style1">NKR Administration </span></div></td> </tr> <tr > <td width="18%" height="10" align="center"><a href="index.php">Admin home</a></td> <td width="18%" height="10" align="center" ><a href="newJobs.php">New Job Applications</a></td> <td width="18%" height="10" align="center" ><a href="allJobs.php">All Jobs Applications</a></td> <td width="18%" height="10" align="center" ><a href="content.php">Edit Content</a></td> <td width="23%" align="center" > </td> <td width="5%" height="25" > </td> </tr> </table> <!-- #EndLibraryItem --><p>All Jobs Applications:</p> <p><?php while($i < $totalPages_resumes){ $i++; echo "<a href='newJobs.php?pageNum_resumes=$i'>$i</a> "; }; ?></p> <table width="100%"> <tr bgcolor="#4A898F"> <td class="tableHeader">Applicant Details</td> <td class="tableHeader">Addresses</td> <td class="tableHeader">Phone Numbers</td> <td class="tableHeader">Other Info</td> <td class="tableHeader">Resume & CV</td> <td class="tableHeader">Condition & Records</td> </tr> <?php do { $i++ ?> <tr valign="top" <?php if($i % 2){echo $jobTbBg; }else{echo $jobTbBgOther;};?>> <td><span class="resumeTiltles">Name:</span><?php echo $row_resumes['applicantName']; ?><br /> <span class="resumeTiltles">DOB:</span><?php echo $row_resumes['dateOfBirth']; ?><br /> <span class="resumeTiltles">Gender:</span><?php echo $row_resumes['gender']; ?><br /> <span class="resumeTiltles">Ethnicity:</span><?php echo $row_resumes['ethnicGroup'];?><br /> <span class="resumeTiltles">Citizen of:</span><?php echo $row_resumes['citizenship']; ?><br /> <span class="resumeTiltles">Marital status:</span><?php echo $row_resumes['maritalStatus']; ?></td> <td><span class="resumeTiltles">Work:</span><br /> <?php echo $row_resumes['workAddress'];?><br /> <span class="resumeTiltles">Home:</span><br /> <?php echo $row_resumes['homeAddress'];?><br /> <span class="resumeTiltles">Email Addess: </span><a href="mailto:<?php echo $row_resumes['emailAddress']; ?>"><?php echo $row_resumes['emailAddress']; ?></a></td> <td><span class="resumeTiltles">Work: </span><?php echo $row_resumes['workPhoneNumber']; ?><br /> <span class="resumeTiltles">Home: </span><?php echo $row_resumes['homePhoneNumber']; ?><br /> <span class="resumeTiltles">Mobile: </span><?php echo $row_resumes['mobilePhoneNumber']; ?><br /> <span class="resumeTiltles">Fax: </span><?php echo $row_resumes['faxPhoneNumber']; ?></td> <td><span class="resumeTiltles">Applcation date: </span><br /> <?php echo $row_resumes['dateUploaded']; ?><br /> <span class="resumeTiltles">Police Clearance: </span><?php echo $row_resumes['policeClearance']; ?><br /> <span class="resumeTiltles">Applied for: </span><br /> <?php echo $row_resumes['applicationSection']; ?></td> <td><span class="resumeTiltles">Been downloaded? :</span><br /> <?php echo $row_resumes['downloaded']; ?><br /> <br /> <span class="resumeTiltles">Download here: <br /> </span><div align="center"> <h3><a href="newJobs.php?id=<?php echo $row_resumes['id']; ?>"><img src="../img/downloadImg.jpg" width="73" height="20" align="middle" /></a></h3> </div></td> <td><span class="resumeTiltles">Medical condition: </span><?php echo $row_resumes['medical']; ?><br /> <span class="resumeTiltles">What: </span><?php echo $row_resumes['medicalCondition']; ?><br /> <br /> <span class="resumeTiltles">Criminal record: </span><?php echo $row_resumes['criminal']; ?><br /> <span class="resumeTiltles">What: </span><?php echo $row_resumes['criminalRecord']; ?></td> </tr> <?php } while ($row_resumes = mysql_fetch_assoc($resumes)); ?> </table> </body> </html> <?php mysql_free_result($resumes); ?> Quote Link to comment Share on other sites More sharing options...
garethhall Posted June 28, 2008 Author Share Posted June 28, 2008 Please help Quote Link to comment Share on other sites More sharing options...
thatsgreat2345 Posted June 28, 2008 Share Posted June 28, 2008 You will most likely get more help if you refine your problem, explain it, and post LESS code as most people don't feel like looking through all of your code Quote Link to comment Share on other sites More sharing options...
garethhall Posted June 28, 2008 Author Share Posted June 28, 2008 Ok so here is a more refined version. The code below downloads a word document from the mysql database to the client computer. When file example id=5 is downloaded i want the field "downloaded" in the Resumes table to be updated to "Yes". I want to do this so I can filter what has been downloaded and what not. <?php require_once('../Connections/updateContent.php'); ?> <?php $maxRows_resumes = 20; $pageNum_resumes = 0; if (isset($_GET['pageNum_resumes'])) { $pageNum_resumes = $_GET['pageNum_resumes']; } $startRow_resumes = $pageNum_resumes * $maxRows_resumes; mysql_select_db($database_updateContent, $updateContent); $query_resumes = "SELECT * FROM Resumes ORDER BY applicantName ASC"; $query_limit_resumes = sprintf("%s LIMIT %d, %d", $query_resumes, $startRow_resumes, $maxRows_resumes); $resumes = mysql_query($query_limit_resumes, $updateContent) or die(mysql_error()); $row_resumes = mysql_fetch_assoc($resumes); if (isset($_GET['totalRows_resumes'])) { $totalRows_resumes = $_GET['totalRows_resumes']; } else { $all_resumes = mysql_query($query_resumes); $totalRows_resumes = mysql_num_rows($all_resumes); } $totalPages_resumes = ceil($totalRows_resumes/$maxRows_resumes)-1; $jobTbBg = " bgcolor='#E0EBED'"; $jobTbBgOther = " bgcolor='#C3D9DD'"; if(isset($_GET['id'])){ $id = $_GET['id']; $query = "SELECT fileName, fileType, fileSize, content FROM Resumes WHERE id = '$id'"; $result = mysql_query($query) or die('Error, query failed'); list($fileName, $fileType, $fileSize, $content) = mysql_fetch_array($result); header("Content-Disposition: attachment; filename=$fileName.doc"); header("Content-length: $fileSize"); //header("Content-type: $fileType"); application/msword header("Content-type: application/doc "); echo $content; //////////////////// THIS IS WHAT I WANT TO UPDATE $queryUp = "UPDATE `NKR`.`Resumes` SET `downloaded` = 'Yes' WHERE `Resumes`.`id` = '$id' "; mysql_query($queryUp) or die ('Error connecting to Database please try again'); mysql_close($conn); /////////////////////////////// exit; }; ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> <link href="adminStyle.css" rel="stylesheet" type="text/css" /> </head> <body> <p><?php while($i < $totalPages_resumes){ $i++; echo "<a href='newJobs.php?pageNum_resumes=$i'>$i</a> "; }; ?></p> <table width="100%"> <tr bgcolor="#4A898F"> <td class="tableHeader">Resume & CV</td> </tr> <?php do { $i++ ?> <tr valign="top" <?php if($i % 2){echo $jobTbBg; }else{echo $jobTbBgOther;};?>> <td><span class="resumeTiltles">Been downloaded? :</span><br /> <?php echo $row_resumes['downloaded']; ?><br /> <br /> <span class="resumeTiltles">Download here: <br /> </span><div align="center"> <h3><a href="newJobs.php?id=<?php echo $row_resumes['id']; ?>"><img src="../img/downloadImg.jpg" width="73" height="20" align="middle" /></a></h3> </div></td> </tr> <?php } while ($row_resumes = mysql_fetch_assoc($resumes)); ?> </table> </body> </html> <?php mysql_free_result($resumes); ?> Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted June 28, 2008 Share Posted June 28, 2008 is it throwing any of your 'die()'s ? Error connecting to Database please try again Quote Link to comment Share on other sites More sharing options...
garethhall Posted June 29, 2008 Author Share Posted June 29, 2008 No i get no error messages as a second note when i echo $queryUp I get nothing? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.