Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 03-31-2008, 01:08 AM Php Upload & Display
RCS
Novice Talker

Posts: 7
Trades: 0
Hi everyone, I'm trying to create a script where I can save form data e.g Make, Description, Price, Picture
after saving data to mysql I want to post it by id to a catalog page. I'm having an issue with getting image from database.
I can't seem to figure it out. If someone could help me it would be greatly appreciated.
Thank you very much in advance.

This is form
<html>
<body><form action="upload_file.php" method="POST"
enctype="multipart/form-data">
<p><label for="file">Filename:</label>
<input type="file" name="file" id="file" />
<input type="hidden" name="MAX_FILE_SIZE" value="100000000000000"></p>
<p><label>Make:</label>
<input type="text" name="make" id="make" /></p>
<p><label>Price:</label>
<input type="text" name="price" id="price" /></p>
<p><label>Category:</label>
<input type="text" name="category" id="category" /></p>
<p><label>Description:</label>
<textarea name="description" id="description" cols="45" rows="5"></textarea /></p>


<input type="submit" name="submit" value="Submit" />
</form></body>
</html>

This is upload page where everything gets saved to database
<?php
include("dbinfo.inc");
include("file_array.inc");
if(isset($_POST['upload']) && $_FILES['file']['size'] > 0)
{
$fp = fopen($tmpName, 'r');
$content = fread($fp, filesize($tmpName));
$content = addslashes($content);
fclose($fp);
if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
}
}
$con = mysqli_connect($db_host, $db_user, $db_passwd, $db_name);
$query = "INSERT INTO upload(name, size, type, content, make, price, description)".
"VALUES ('$fileName', '$fileSize', '$fileType', '$content','$_POST[make]','$_POST[price]','$_POST[description]')";
$result=mysqli_query($con, $query) or die ("Could not complete query.");
mysql_close($con);
?>
<html>
<head><title>CMS</title></head>
<body><center>Information successfuly saved to database.</center></body>
</html>

This is page where data gets posted
<html>
<head>
<title>Download File From MySQL</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
include("dbinfo.inc");
$con = mysqli_connect($db_host, $db_user, $db_passwd, $db_name);
$query = ("SELECT * FROM upload ORDER BY id");
$result = mysqli_query($con, $query) or die('Error, query failed');
echo "<table border='1'>
<tr>
<th>Make</th>
<th>Description</th>
<th>Price</th>
<th>Picture</th>
</tr>";
while($row = mysqli_fetch_array ($result))
{
echo "<tr>";
echo "<td>" . $row['make'] . "</td>";
echo "<td>" . $row['description'] . "</td>";
echo "<td>" . $row['price'] . "</td>";
echo "<td>" . $row['name'] . "</td>";
echo "</tr>";
}
echo "</table>";mysqli_close($con);
?>
<a href="download.php?id=<?php echo $id; ?>"><?php echo $name;?>[/url]

<?php
mysql_close($con);
?>
</body>
</html>

This is file_array
<?php
$fileName = $_FILES['file']['name'];
$tmpName = $_FILES['file']['tmpName'];
$fileSize = $_FILES['file']['size'];
$fileType = $_FILES['file']['type'];
?>

Don't laugh to hard!!
RCS is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-31-2008, 03:29 AM Re: Php Upload & Display
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
What exactly is the problem?
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 03-31-2008, 06:48 AM Re: Php Upload & Display
Novice Talker

Posts: 8
Name: Allan
Trades: 0
i think this is also my problem.. he wants to post the image with the description placed over the sql..
somthing like..

********* make:
*--Image- * price
*-- here-- * category:
********* description:

clear me if im wrong.. i want to know this also.. thanks
__________________
im a noob so pls. help me.. thanks

Last edited by wheay; 03-31-2008 at 06:52 AM..
wheay is offline
Reply With Quote
View Public Profile
 
Old 03-31-2008, 07:12 AM Re: Php Upload & Display
vectorialpx's Avatar
Extreme Talker

Posts: 249
Name: octavian
Location: Bucharest
Trades: 0
does you database have this informations... you have a picture there when you make the insert?
if yes, you have "picture.jpg", you must put into the html the right path... that's all... have a "view Source" and see what is in the code... where is the image located and what is the src
__________________
you can
Please login or register to view this content. Registration is FREE
vectorialpx is offline
Reply With Quote
View Public Profile Visit vectorialpx's homepage!
 
Old 03-31-2008, 01:21 PM Re: Php Upload & Display
RCS
Novice Talker

Posts: 7
Trades: 0
You mean like echo "<td><img src='http://www.refinedcomputersolutions.com/php_scripts/tmpName/'" . $row['name'] . "</td>"; and not echo "<td>" . $row['name'] . "</td>";

I tried that and just get a blank icon and yes image is in the directory path.
?????????????????????????????????????????????????? ??????????????????????

If someone could help me that would be great.
RCS is offline
Reply With Quote
View Public Profile
 
Old 03-31-2008, 01:28 PM Re: Php Upload & Display
vectorialpx's Avatar
Extreme Talker

Posts: 249
Name: octavian
Location: Bucharest
Trades: 0
yo man! what does your source code says? what is displayed there?
view source and ... <img src="????????" ......
__________________
you can
Please login or register to view this content. Registration is FREE
vectorialpx is offline
Reply With Quote
View Public Profile Visit vectorialpx's homepage!
 
Old 03-31-2008, 01:58 PM Re: Php Upload & Display
RCS
Novice Talker

Posts: 7
Trades: 0
http://refinedcomputersolutions.com:...nload_file.php

http://refinedcomputersolutions.com:...cript/form.php

Just image info seems to be stored to database so I included a path to a directory where I saved the images.
'http://www.refinedcomputersolutions.com/php_scripts/tmpName/

my database looks like this

CREATE TABLE upload (
id INT NOT NULL AUTO_INCREMENT,
name VARCHAR(30) NOT NULL,
type VARCHAR(30) NOT NULL,
size INT NOT NULL,
description VARCHAR(350) NOT NULL,
price VARCHAR(128) NOT NULL,
make VARCHAR(30) NOT NULL,
category VARCHAR(30) NOT NULL,
content MEDIUMBLOB NOT NULL,
PRIMARY KEY(id)
);

trying to create a script where I can save form data e.g Make, Description, Price, Picture
after saving data to mysql I want to post it by id to a catalog page.

Can you tell me how to do this??

e.g
Make, "Opel"
Description, "4 Wheels, Very Big"
Price, 9995
Picture, 001.jpg the actual picture not the picture name.
RCS is offline
Reply With Quote
View Public Profile
 
Old 03-31-2008, 02:20 PM Re: Php Upload & Display
vectorialpx's Avatar
Extreme Talker

Posts: 249
Name: octavian
Location: Bucharest
Trades: 0
I don't have the time [I don't want] to make your code but I can help to fix it.

citate.txt is my file - you display:
<img src='http://refinedcomputersolutions.com:8080/php_script/tmpName/'citate.txt

corect:

echo "<td><img src='http://www.refinedcomputersolutions.com/php_scripts/tmpName/".$row['name']."' alt='' /></td>";

and... check if you got an image because you can get a "not good file" that will crack your all files... do you need me to do so? )

check $_FILES['file_name']['type'] to be an image type
__________________
you can
Please login or register to view this content. Registration is FREE

Last edited by vectorialpx; 03-31-2008 at 02:28 PM..
vectorialpx is offline
Reply With Quote
View Public Profile Visit vectorialpx's homepage!
 
Old 03-31-2008, 03:18 PM Re: Php Upload & Display
RCS
Novice Talker

Posts: 7
Trades: 0
OK NOT SURE WHAT THAT WAS, BUT I SEE YOU TRIED TO SHOW ME YOU CAN CHANGE MY DATABASE?? I have fixed issue with upload now how do I display the image??
RCS is offline
Reply With Quote
View Public Profile
 
Old 03-31-2008, 04:06 PM Re: Php Upload & Display
RCS
Novice Talker

Posts: 7
Trades: 0
I figured it out
RCS is offline
Reply With Quote
View Public Profile
 
Old 03-31-2008, 04:07 PM Re: Php Upload & Display
RCS
Novice Talker

Posts: 7
Trades: 0
All I hade to do was change code to echo "<td><img src =\"" . $row['name']."\"></td>";
lol so simple.
RCS is offline
Reply With Quote
View Public Profile
 
Old 03-31-2008, 04:09 PM Re: Php Upload & Display
vectorialpx's Avatar
Extreme Talker

Posts: 249
Name: octavian
Location: Bucharest
Trades: 0
great
__________________
you can
Please login or register to view this content. Registration is FREE
vectorialpx is offline
Reply With Quote
View Public Profile Visit vectorialpx's homepage!
 
Reply     « Reply to Php Upload & Display
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.76029 seconds with 12 queries