Help
Search
Login
Register
Home
Forum: web design and graphics community
Celestial Star Forum
>
Web Development
>
Coding
>
Preview It (32) PHP help...?
Pages:
1
[
2
]
« previous
next »
Print
Author
Topic: Preview It (32) PHP help...? (Read 6895 times)
puretaurus21
Guest
Preview It (32) PHP help...?
«
Reply #15 on:
January 22, 2005, 04:49:17 PM »
Okay, I don't really get it :S. I tried experimenting and I made this
Code:
$id = trim($_GET['id']);
$mode = mysql_escape_string($_GET['type']);
if (!isset($type) || empty($type))
{ $type = 'index'; }
switch($type)
{
case 'templates';
$q="SELECT download from templates where id='$id'";
$result= mysql_query($q) or die
("Could not execute query : $q." . mysql_error());
while ($row=mysql_fetch_array($result))
{
$download = $row['download'];
$q2="update templates set counter=counter+1 where id='$id'";
$result2= mysql_query($q2) or die
("Could not execute query : $q2." . mysql_error());
if ($result2) // updated counter so let user download file
{
header('Location: '.$download );
} #end result2
} #end while
break;
case 'avatars';
$q="SELECT download from avatars where id='$id'";
$result= mysql_query($q) or die
("Could not execute query : $q." . mysql_error());
while ($row=mysql_fetch_array($result))
{
$download = $row['download'];
$q2="update avatars set counter=counter+1 where id='$id'";
$result2= mysql_query($q2) or die
("Could not execute query : $q2." . mysql_error());
if ($result2) // updated counter so let user download file
{
header('Location: '.$download );
} #end result2
} #end while
break;
}
I uploaded that code but it didn't work. I really didn't get you about what it say on the code you told before about the update query thing because theres two :S
Logged
Melfina
Administrator
Valkyrie Randgris
Posts: 1289
Preview It (32) PHP help...?
«
Reply #16 on:
January 22, 2005, 06:35:42 PM »
You only need to add the connection stuff there. I really don't think you need to add the $id = trim($_GET['id']); thing there. Try first with it and remove it if it doesn't work well:
Code:
<?php
$id
=
trim
&
#40;$_GET['id']);
$type
=
mysql_escape_string
&
#40;$_GET['type']);
if &
#40;!isset($type) || empty($type))
&
#123; $type = 'index'; }
switch&
#40;$type)
&
#123;
case
'templates'
;
$hostname
=
"localhost"
;
$user
=
"yourusernamehere"
;
$pass
=
"yourpasshere"
;
$dbase
=
"yourdatabasenamehere"
;
$connection
=
mysql_connect
&
#40;"$hostname" , "$user" , "$pass");
$db
=
mysql_select_db
&
#40;$dbase , $connection);
$q
=
"SELECT download from templates where id='$id'"
;
$result
=
mysql_query
&
#40;$q) or die
&
#40;"Could not execute query : $q." . mysql_error());
while &
#40;$row=mysql_fetch_array($result))
&
#123;
$download
=
$row
[
'download'
&
#93;;
$q2
=
"update templates set counter=counter+1 where id='$id'"
;
$result2
=
mysql_query
&
#40;$q2) or die
&
#40;"Could not execute query : $q2." . mysql_error());
if &
#40;$result2) // updated counter so let user download file
&
#123;
header
&
#40;'Location: '.$download );
&
#125; #end result2
&
#125; #end while
break;
case
'avatars'
;
$hostname
=
"localhost"
;
$user
=
"yourusernamehere"
;
$pass
=
"yourpasshere"
;
$dbase
=
"yourdatabasenamehere"
;
$connection
=
mysql_connect
&
#40;"$hostname" , "$user" , "$pass");
$db
=
mysql_select_db
&
#40;$dbase , $connection);
$q
=
"SELECT download from avatars where id='$id'"
;
$result
=
mysql_query
&
#40;$q) or die
&
#40;"Could not execute query : $q." . mysql_error());
while &
#40;$row=mysql_fetch_array($result))
&
#123;
$download
=
$row
[
'download'
&
#93;;
$q2
=
"update avatars set counter=counter+1 where id='$id'"
;
$result2
=
mysql_query
&
#40;$q2) or die
&
#40;"Could not execute query : $q2." . mysql_error());
if &
#40;$result2) // updated counter so let user download file
&
#123;
header
&
#40;'Location: '.$download );
&
#125; #end result2
&
#125; #end while
break;
&
#125;
?>
Logged
MySpace
~
MySpace Codex
~
Rune Nifelheim
puretaurus21
Guest
Preview It (32) PHP help...?
«
Reply #17 on:
January 23, 2005, 02:55:54 AM »
Oh thanks, Melfina! It worked very well. Thank you for helping me, I'll make sure to credit you :D
Logged
Arwen
Incubus
Posts: 60
Preview It (32) PHP help...?
«
Reply #18 on:
July 18, 2006, 09:11:57 AM »
Thanks for posting the tutorial, BUT I think I'm stuck! I created a table in my MySQL database made two files (view.php and download.php), uploaded them to my server AND now I'm stuck! What do I do next? Please, help!!!!!!!!!!!!
Logged
Free Wordpress Themes
Blackstone
Administrator
Valkyrie Randgris
Posts: 821
Oh look! People!
Preview It (32) PHP help...?
«
Reply #19 on:
July 18, 2006, 01:58:53 PM »
Erm, how are you stuck? Can you give us some more details?
Logged
Arwen
Incubus
Posts: 60
Preview It (32) PHP help...?
«
Reply #20 on:
July 18, 2006, 03:11:43 PM »
Well, just like I said, I created a table in my MySQL database, created two files (view.php and download.php), uploaded them to my server and I don't know what to do next. Do I need to add my .zip files to the database or something...? :?
Logged
Free Wordpress Themes
Blackstone
Administrator
Valkyrie Randgris
Posts: 821
Oh look! People!
Preview It (32) PHP help...?
«
Reply #21 on:
July 18, 2006, 03:20:01 PM »
You need to enter information into your database. It all really depends on how you've set up the databases and the PHP files.
Logged
Pages:
1
[
2
]
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
General
-----------------------------
=> General
=> New Members
=> Announcements
=> Support / Suggestions
-----------------------------
Contests
-----------------------------
=> Archive
===> Contests
===> Blend Challenges
===> SOTW
-----------------------------
Art Boards
-----------------------------
=> Creative mediums
=> Requests & offers
=> Tutorials
===> Celestial Star Tutorials
-----------------------------
Web Development
-----------------------------
=> Coding
=> Web Design
=> Advertisements / Affiliation
-----------------------------
Off-topic
-----------------------------
=> Entertainment
-----------------------------
Español (Spanish Only)
-----------------------------
=> General / Bienvenida
=> Anuncios / Ayuda
=> Código / Desarrollo web
Welcome,
Guest
Members login
Register for free
General
General
New members
Announcements
Support / Suggestions
Art boards
Creative mediums
Requests and offers
Tutorials
Celestial Star tutorials
Web development
Coding
Web design
Advertisements / affiliation
Off-topic
The non-sense
Ententainment
Loading...