close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Download Count update always the same ID

Thread began 10/03/2012 6:03 pm by Vinicios Nussemeyer | Last modified 10/09/2012 10:27 am by Jason Byrnes | 3955 views | 5 replies |

Vinicios Nussemeyer

Download Count update always the same ID

Hello
I applied the download count on the download page. When the user downloads the system increases and records in mysql. The problem is that the increment is always saved in the same file ID. If I have 10 files for download, the system updates ArquivoID always the same in mysql. For example: If I download the file once with ID 1 and ID 2 to 10 times, the system always update the ID 1.
The column in the table is CountDownload files and defaults ZERO.
key column: ArquivoID and value: $ row_rsArquivos ['ArquivoID']

Tanks

Sign in to reply to this post

Jason ByrnesWebAssist

it's because you are using the ID from the recordset as the key column value

that recordset will always be at record 1 when the download is executed.

you don't include a lot of detail on how the page is set up, but i'm assuming you have a repeat region on the page? in the repeat region you have a form that sends the download file name using a hidden form element? if that is correct, you need another hidden form element that passes the ID and use that hidden form element as the key column value

Sign in to reply to this post

Vinicios Nussemeyer

Hello Jason.
Yes, the page is set up like you said. I applied another hidden element on the form but still did not work.
Follows the code of the page:
<?php
session_start(); // Inicia a session
include "functions.php"; // arquivo de funções.
session_checker(); // chama a função que verifica se a session iniciada da acesso à página.
?>
<?php require_once('Connections/conn.php'); ?>
<?php require_once("WA_DigitalFilePro/HelperPHP.php"); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$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_rsArquivos = 15;
$pageNum_rsArquivos = 0;
if (isset($_GET['pageNum_rsArquivos'])) {
$pageNum_rsArquivos = $_GET['pageNum_rsArquivos'];
}
$startRow_rsArquivos = $pageNum_rsArquivos * $maxRows_rsArquivos;

mysql_select_db($database_conn, $conn);
$query_rsArquivos = "SELECT `arquivos`.*, `users`.*, `users`.`UserFirstName` AS Professor FROM `arquivos` LEFT JOIN `users` ON `arquivos`.`Professor` = `users`.`UserID` WHERE arquivos.Serie = 3 AND arquivos.Ativo = 1";
$query_limit_rsArquivos = sprintf("%s LIMIT %d, %d", $query_rsArquivos, $startRow_rsArquivos, $maxRows_rsArquivos);
$rsArquivos = mysql_query($query_limit_rsArquivos, $conn) or die(mysql_error());
$row_rsArquivos = mysql_fetch_assoc($rsArquivos);

if (isset($_GET['totalRows_rsArquivos'])) {
$totalRows_rsArquivos = $_GET['totalRows_rsArquivos'];
} else {
$all_rsArquivos = mysql_query($query_rsArquivos);
$totalRows_rsArquivos = mysql_num_rows($all_rsArquivos);
}
$totalPages_rsArquivos = ceil($totalRows_rsArquivos/$maxRows_rsArquivos)-1;?>
<?php
WA_DFP_SetupDownloadStatusStruct("WA_DownloadResult1");
if($_SERVER["REQUEST_METHOD"] == "POST"){
WA_DFP_DownloadFile("WA_DownloadResult1", "../../downloads", "".((isset($_POST["hiddenField"]))?$_POST["hiddenField"]:"") ."", "[FileName]", 1, $database_conn, $conn, "arquivos", "ArquivoID", "".$row_rsArquivos['ArquivoID'] ."", "CountDownload");
}
?>
<!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>Downloads 8 Série</title>
<link href="css/styles_downloads_arquivos.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.Spacious {
padding-top: 3px;
padding-right: 7px;
padding-bottom: 3px;
padding-left: 7px;
text-transform: uppercase;
background-image: -moz-linear-gradient(top, #18536b, #1c5a73);
background-image: -o-linear-gradient(top, #18536b, #1c5a73);
background-image: -webkit-linear-gradient(#18536b, #1c5a73);
background-image: -webkit-gradient(linear,left top, left bottom, color-stop(0, #18536b), color-stop(1, #1c5a73));
background-image: linear-gradient(top, #18536b, #1c5a73);
filter: progid:DXImageTransform.Microsoft.Gradient(StartColorStr='#18536b', EndColorStr='#1c5a73', GradientType=0);
-ms-filter: progid:DXImageTransform.Microsoft.Gradient(StartColorStr='#18536b', EndColorStr='#1c5a73', GradientType=0);
background-position: 0 16px;
border-style: solid;
color: #cccccc;
background-color: #1c5a73;
border-color: #636668;
font-family: Arial, Verdana, sans-serif;
font-size: 0.6em;
border-width: 1px;
}
.Spacious:hover {
background: none;
color: #ffffff;
background-color: #18536b;
}
</style>
</head>

<body>
<div id="BannerTopoInst">
<table width="940" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="4"><img src="assets/images/clearpixel.gif" width="806" height="45" border="0" /></td>
</tr>
<tr>
<td width="150">&nbsp;</td>
<td width="616"><span class="BannerTopoInstTitulo">Download</span><span class="BannerTopoInstTituloActive">Material Acadêmico</span></td></td>
<td width="23"><img src="assets/images/clearpixel.gif" width="20" height="45" border="0" /></td>
</tr>
</table>
</div>
<span class="Texto1"><?php echo "Bem vindo <strong>". $_SESSION['nome'] ." ". $_SESSION['sobrenome'] . "</strong>!<br />
Você está acessando a área restrita de downloads para os alunos cadastrados no Sistema de Ensino Universo!<br />
Seu último login foi em: ". date('d/m/Y', strtotime($_SESSION['data_ultimo_login'])) . '-' . date('H:i:s', strtotime($_SESSION['data_ultimo_login'])) ." <br />";
?></span><br />
<p>
<p class="ArquivosTitulo2">Material acadêmico / 3º Ano</span> - <a href="logout.php">SAIR</a><br /></p>
<?php if ($totalRows_rsArquivos == 0) { // Show if recordset empty ?>
<p class="FormCampoObrigatorio">No momento, não existem materiais acadêmicos para download para esta série.</p>
<?php } // Show if recordset empty ?>
<?php if ($totalRows_rsArquivos > 0) { // Show if recordset not empty ?>
<table width="940" border="0" cellspacing="2" cellpadding="0">
<tr>
<td width="228" height="25" bgcolor="#EBEBEB" class="ArquivosTitulo1">Disciplina</td>
<td width="301" bgcolor="#EBEBEB" class="ArquivosTitulo1">Título</td>
<td width="293" height="25" bgcolor="#EBEBEB" class="ArquivosTitulo1">Professor</td>
<td width="108" height="25" align="center" bgcolor="#EBEBEB" class="ArquivosTitulo1">Ação</td>
</tr>
<tr>
<td height="10" colspan="4"><img src="assets/images/clearpixel.gif" width="10" height="10" border="0" /></td>
</tr>
<?php do { ?>
<tr>
<td class="Texto1"><?php echo $row_rsArquivos['Disciplina']; ?></td>
<td class="Texto1"><?php echo $row_rsArquivos['Titulo']; ?></td>
<td class="Texto1"><?php echo $row_rsArquivos['Professor']; ?></td>
<td><form id="form1" name="form1" method="post" action="">
<input type="submit" value="Download" class="Spacious" id="Spacious" name="Spacious" />
<input name="hiddenField" type="hidden" id="hiddenField" value="<?php echo $row_rsArquivos['ProductLocation']; ?>" />
<input name="hiddenField2" type="hidden" id="hiddenField2" value="<?php echo((isset($_POST["hiddenField"]))?$_POST["hiddenField"]:"") ?>" />
</form></td>
</tr>
<?php } while ($row_rsArquivos = mysql_fetch_assoc($rsArquivos)); ?>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
<?php } // Show if recordset not empty ?>
</body>
</html>
<?php
mysql_free_result($rsArquivos);
?>

Thank you.

Sign in to reply to this post

Jason ByrnesWebAssist

2 problems:

1) In the download behavior, it is still set to use the ArquivoID column from the recordset for the key column value

2) the hidden form elment you added is set to use the value from the first hidden field:

<input name="hiddenField2" type="hidden" id="hiddenField2" value="<?php echo((isset($_POST["hiddenField"]))?$_POST["hiddenField"]:"") ?>" />


it should be set to use the ArquivoID column from the recordset.


the idea is to bind the hidden field to the ID column from the recordset,

and in the Download server behavior bind the key column value to the hidden field.


NOTE: instead of pasting the code for the page, please compress the page to a zip archive and attach the zip file to your response.

Sign in to reply to this post

Vinicios Nussemeyer

Hello Jason.
I applied the changes and now gives this error:
You have an error in your SQL syntax near 'Etnicos_Oriente Medio.pdf' at line 1

Attached Files
download_center_3ano.zip
Sign in to reply to this post

Jason ByrnesWebAssist

for the key column value in the download behavior, you are using the ProductLocation column of the rsArquivos recordset.

This is not what I have been telling you to do.

bind the Key Column Value setting to the hiddenField2 form element.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...