User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 423,305 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 5,344 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 492 | Replies: 11
Reply
Join Date: Feb 2008
Posts: 298
Reputation: kevin wood is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
kevin wood's Avatar
kevin wood kevin wood is offline Offline
Posting Whiz in Training

Help displaying images

  #1  
Mar 14th, 2008
I have created a image upload for the site i am working on i now want the uer to be able to click on a preview button and this takes them to a separate page where they can see the images that have been uploaded.

for this to happen would i have to send a query to the database to retrieve the information or can i simply display them using the variable name which was set for the images.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Mar 2008
Location: Praha, Czech Republic, Europe
Posts: 99
Reputation: petr.pavel is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 14
petr.pavel's Avatar
petr.pavel petr.pavel is offline Offline
Junior Poster in Training

Re: displaying images

  #2  
Mar 14th, 2008
Hi Kevin,
the basic question: do you store the images in a database or as files in a file system.

Also, what should I imagine when you say "the variable name which was set for the images"?
Petr 'PePa' Pavel

The more information you give the more relevant answer you get.
Please consider using "Add to ... Reputation" and mark your thread as Solved if you found what you were looking for. By giving feedback you help others.
Reply With Quote  
Join Date: Dec 2007
Posts: 52
Reputation: kishou is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
kishou kishou is offline Offline
Junior Poster in Training

Re: displaying images

  #3  
Mar 15th, 2008
so you want to make a thumbnail? also you can make a field called "id" and match the id with the image location. and then select like that.
Reply With Quote  
Join Date: Jul 2007
Posts: 106
Reputation: Designer_101 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 2
Designer_101 Designer_101 is offline Offline
Junior Poster

Re: displaying images

  #4  
Mar 15th, 2008
best way to store an image is to upload it. Store its directory as a varchar in a database then simply echo it back when you need it
there are better and more complicated but this is by far the easiest method


hope this helps
Reply With Quote  
Join Date: Jul 2007
Posts: 106
Reputation: Designer_101 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 2
Designer_101 Designer_101 is offline Offline
Junior Poster

Re: displaying images

  #5  
Mar 15th, 2008
i think what you need is this:

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
$_FILES['uploadedfile']['tmp_name'];

all this does is make a variable that holds the directory (ex: "uploads/filename.extension" )
and that you can store in the database as a varchar

if you want me to make you a script just ask, np lol im bored.

hope this helps
Reply With Quote  
Join Date: Feb 2008
Posts: 298
Reputation: kevin wood is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
kevin wood's Avatar
kevin wood kevin wood is offline Offline
Posting Whiz in Training

Re: displaying images

  #6  
Mar 17th, 2008
i have now tried to connect to my database which is set up on the server and i keep getting could not connect. i have db.php page which sets up the database and recall this by using include db.php
Reply With Quote  
Join Date: Mar 2008
Location: Praha, Czech Republic, Europe
Posts: 99
Reputation: petr.pavel is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 14
petr.pavel's Avatar
petr.pavel petr.pavel is offline Offline
Junior Poster in Training

Re: displaying images

  #7  
Mar 17th, 2008
Hi Kevin,
there's no way we could check the problem remotely.
Either you have the login data wrong (server name, username, password, db name) or the script doesn't connect or I don't know. Can you attach both db.php and the main script?
Petr 'PePa' Pavel

The more information you give the more relevant answer you get.
Please consider using "Add to ... Reputation" and mark your thread as Solved if you found what you were looking for. By giving feedback you help others.
Reply With Quote  
Join Date: Feb 2008
Posts: 298
Reputation: kevin wood is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
kevin wood's Avatar
kevin wood kevin wood is offline Offline
Posting Whiz in Training

Re: displaying images

  #8  
Mar 17th, 2008
here is the db.php code
<?php

$dbhost = 'www.acmeart.co.uk';
$dbusername = 'acmeart';
$dbpasswd = 'all0wn01';
$database_name = 'acmeartdb';
$sitepath = "http://www.acmeart.co.uk/mercury/";
$sitename = "Mercury Email Distribution System";
$adminemail = "mercury@acmeart.co.uk";

$connection = mysql_pconnect("$dbhost","$dbusername","$dbpasswd")
or die ("Couldn't connect to server.");

$db = mysql_select_db("$database_name", $connection)
or die("Couldn't select database.");
?>

here is the code i am using to connect to the db.

<?php

include "db.php";

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die line 168
("QUERY ERROR: ".mysql_error());

$db = mysql_select_db("$database_name", $connection)
or die("QUERY ERROR: ".mysql_error());

// Create table in my_db database
mysql_select_db("$database_name", $connection);
$sql = "CREATE TABLE images
(
imageID int NOT NULL AUTO_INCREMENT,
Broad1 varchar(50),
Broad2 varchar(50),
Broad3 varhar(50)
)";



if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("$database_name", $con);

mysql_query("INSERT INTO image (Broad1)
VALUES ('$thumb_name')");

mysql_query($sql,$con);

mysql_close($con);

?>

i keep getting the error

(Using password: NO) in /home/acmeart/public_html/mercury/upload.php on line 168 QUERY ERROR: i have labelled line 168 for you
Reply With Quote  
Join Date: Feb 2008
Posts: 298
Reputation: kevin wood is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
kevin wood's Avatar
kevin wood kevin wood is offline Offline
Posting Whiz in Training

Re: displaying images

  #9  
Mar 17th, 2008
i have just spotted a typo and i am just getting could not connect now
Reply With Quote  
Join Date: Feb 2008
Posts: 298
Reputation: kevin wood is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
kevin wood's Avatar
kevin wood kevin wood is offline Offline
Posting Whiz in Training

Re: displaying images

  #10  
Mar 17th, 2008
i have changed 2 typo's in the code in the $conn = mysql_connect($dbhost, $dbuser, $dbpass)

$dbuser= $dbusername

$dbpass= $dbpasswd
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 11:06 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC