Ik heb een probleem met een tutorial die ik aan het doen ben. Dit script zou ervoor moeten zorgen dat er op de pagina een link verschijnt en het aantal keer dat daarom gedrukt is. De naam van de link, de link zelf, en de teller komen uit de database...

Dit is mn database:
CREATE TABLE tutorials (
id int(5) DEFAULT '0' NOT NULL auto_increment,
FileName varchar(50) NOT NULL,
FileURL varchar(255) NOT NULL,
Count smallint(5) NOT NULL,
PRIMARY KEY (id)
);


Dit is view.php
<?
include "connect.php";

$x ="SELECT * from tutorials order by FileName";
$result = mysql_query($x) or die
("Could not execute query : $x." . mysql_error());

echo "<p align=center><b>File Download</b></p>";

while ($row=mysql_fetch_array($result))
{
$id = $row["id"];
$FileName = $row["FileName"];
$FileURL = $row["FileURL"];
$Count =$row["Count"];


echo "<a href=download.php?id=$id target=blank>$FileName</a></br>";
}
echo "visited: $Count";

?>

en dit is download.php
<?php

include "connect.php";

$x ="SELECT * from tutorials where id='$id'";
$result = mysql_query($x) or die
("Could not execute query : $x." . mysql_error());

while ($row = mysql_fetch_array($result))
{
$id = $row["id"];
$FileName = $row["FileName"];
$FileURL = $row["FileURL"];
$Count = $row["Count"];

header('Location: '.$FileURL);

$x ="update tutorials set Count=Count+1 where id='$id'";
$result = mysql_query($x) or die
("Could not execute query : $x." . mysql_error());

}

?>

nou is het probleem dat de link niet verwijst naar de in de database genoemte link ...

http://test.scratch-design.nl/view.php is de link

alvast bedankt
[offtopic]De [ code] tags zijn niet bedoeld voor PHP code.
Die wordt automatisch gehighlight, code kan voor database gegevens of andere troep dat je in fixed font wilt zien.[/offtopic]
probeer eerst eens je resultaten the echoen

$id $filename $fileurl en $count, kijken of je uberhaupt iets terugkrijgt


*ik zou je connectiebestand even anders zetten daar, onverlaten kunnen er zo bij
Kijk.. daar heb ik nog eens niet aan :)
hij echot de FileURL idd niet :S

en ik heb ondertussen ook gevonden waarom. Bedankt wes! wat in het script FileURL heet, hete in de db FileUrl... en daar had ik totaal overheen gekeken. (k ben niet voor niks newbie he :P)

bedankt ;)
Hey kars....

Ja ik dus ook haha...

(voor de anderen): ik had al gekeken voor hem

Is het ondertussen wel al gelukt?
jaja... hij doet t :)

Edit:
maar nadat ik een aantal aanpassingen had gedaan doet de helft het niet meer... :S

view.php
<?
include "connect.php";

$x ="SELECT * from tutorials order by id";
$result = mysql_query($x) or die
("Could not execute query : $x." . mysql_error());

while ($row=mysql_fetch_array($result))
{
$id = $row["id"];
$filename = $row["$filename"];
$pic = $row["pic"];
$author = $row["author"];
$descrip = $row["descrip"];
$Count = $row["Count"];
$url = $row["url"];

echo "<p align=center>$filename<br>";
echo "<img src=$pic ><br>
Author: $author<br>
$descrip<br>
Visited: $Count<br>
<a href=$url target=blank>View</a><br></p>";

}
?>

download.php
<?php

include "connect.php";

$x ="SELECT * from tutorials where id='$id'";
$result = mysql_query($x) or die
("Could not execute query : $x." . mysql_error());

while ($row=mysql_fetch_object($result))
{
$id = "$row->id";
$filename = "$row->$filename";
$pic = "$row->pic";
$author = "$row->author";
$descrip = "$row->descrip";
$Count = "$row->Count";
$url = "$row->url";

echo "<script> self.location(\"$url\");</script>";

$x ="update tutorials set Count=Count+1 where id='$id'";
$result = mysql_query($x) or die
("Could not execute query : $x." . mysql_error());

}

?>

de filename wil niet verschijnen (maar dit keer ligt het niet aan hoofdletters :P)
en de count werkt niet meer (hij laat nog wel het getal zien :S)
niemand??
(jah... edit was niet t handigste..)

Reageren