Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > MySQL
|
MySQL General discussion about the MySQL database.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the MySQL section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 27th, 2009, 01:41 AM
Authorized User
 
Join Date: Jul 2006
Posts: 73
Thanks: 11
Thanked 1 Time in 1 Post
Default how to put or get pictures to web MYSQL database

Hi
I have a problem rigarding on how to put or get pictures to web MYSQL database from PC

Thanks
sabra
 
Old January 28th, 2009, 12:03 PM
jminatel's Avatar
Wrox Staff
Points: 18,059, Level: 58
Points: 18,059, Level: 58 Points: 18,059, Level: 58 Points: 18,059, Level: 58
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2003
Posts: 1,906
Thanks: 62
Thanked 139 Times in 101 Posts
Default

Sabra: I've moved your post to a new thread in a more appropriate forum. Also, it's more likely to get help from a forum member with a more descriptive subject like this than a post addressed to just one member.
__________________
Jim Minatel
Associate Publisher, WROX - A Wiley Brand
Did someone here help you? Click on their post!
 
Old January 29th, 2009, 05:07 AM
Authorized User
 
Join Date: Jul 2006
Posts: 73
Thanks: 11
Thanked 1 Time in 1 Post
Question Dear RIchard York

I am beginer in PHP and I have a problem regarding on how put or get pictures to Web MYSQL database from my PC.
Thanks.
sabra
 
Old January 30th, 2009, 11:00 PM
Authorized User
 
Join Date: Jul 2006
Posts: 73
Thanks: 11
Thanked 1 Time in 1 Post
Unhappy pictures problem

Hi
anybody help me, i am beginer in PHP and I have a problem regarding on how put or get pictures to Web MYSQL database from my PC.
Thanks.
sabra
 
Old February 1st, 2009, 12:56 PM
jminatel's Avatar
Wrox Staff
Points: 18,059, Level: 58
Points: 18,059, Level: 58 Points: 18,059, Level: 58 Points: 18,059, Level: 58
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2003
Posts: 1,906
Thanks: 62
Thanked 139 Times in 101 Posts
Default

Sabra: You might take a look at this book Beginning PHP 5, Apache, and MySQL Web Development, where chapter 7 is "Manipulating and Creating Images with PHP." The full table of contents for that chapter shows this:
Chapter 7: Manipulating and Creating Images with PHP 193
Working with the GD Library 193
What File Types Can I Use with GD and PHP? 194
Compiling PHP with GD 194
Allowing Users to Upload Images 19
Converting Image File Types 203
Black and White 208
Adding Captions 214
Adding Watermarks and Merging Images 218
Creating Thumbnails 220
Summary 225
Exercises 225

I don't think it's a much different process but if you need PHP 6/MySQL 6 look instead at Beginning PHP 6, Apache MySQL 6 Web Development.

If these don't answer your question, try clarifying what it is you need to do in your question in the forum.
__________________
Jim Minatel
Associate Publisher, WROX - A Wiley Brand
Did someone here help you? Click on their post!
The Following User Says Thank You to jminatel For This Useful Post:
sabra (February 1st, 2009)
 
Old March 6th, 2009, 07:17 AM
Authorized User
 
Join Date: Feb 2009
Posts: 16
Thanks: 0
Thanked 1 Time in 1 Post
Default

The normal (may be the best and easiest) way to manipulate pictures is to store not in Database but in Hard disk as normal files
and keep the file names in Db tables.
So that it will not take much resources of DB and can do normal file operation to get back

Still, if you want to go with database you can go for BLOB data type.


Regards
Anees
 
Old March 6th, 2009, 09:16 AM
Authorized User
 
Join Date: Jul 2006
Posts: 73
Thanks: 11
Thanked 1 Time in 1 Post
Default

Hi Anees,
that is good Idea, but Ineed code for this
 
Old March 7th, 2009, 12:05 AM
Authorized User
 
Join Date: Feb 2009
Posts: 16
Thanks: 0
Thanked 1 Time in 1 Post
Default

HTML Form

HTML Code:
<form name="frmPic" action="actions/upload_picture.php" method="post" enctype="multipart/form-data">
<input type="file" name="picture" size="40" id="picture">
<input type="submit" value="Upload">
upload_picture.php


PHP Code:
$tmp_name    =  $_FILES['picture']['tmp_name'];
$files            =  $_FILES['picture']['name'];
$filesize         =  $_FILES['picture']['size'];

if(
$filesize>0)
    {
           
//Check Extension if you want to restrict the type of files
           
$ext strrchr($files,".");
           
$ext strtolower($ext);
            if(
$ext=='.jpg'|| $ext=='.jpeg'||$ext=='.gif'|| $ext=='.png')
            {
                   
$upload_path    "http://p2p.wrox.com/images/".$files;
                  
copy($tmp_name,$upload_path) or die ("Could not store file");
                  
$sql      "INSERT INTO  `pictures` SET ";
                  
$sql     .= " `pic_name`      = '".addslashes($files)."'";
                  
mysql_query($sql) or die(mysql_error());
            }
    } 
So that you can retrieve the images as

PHP Code:
$get_image "SELECT `pic_name` FROM `pictures` WHERE `id`=124";
$get_image_qr mysql_query($get_image);
if(
$get_image_obj mysql_fetch_array($get_image_qr))
          
$img $get_image_obj['pic_name'];
echo 
'<img src="http://p2p.wrox.com/images/'.$img.'"/>"; 
Hope this will be helpful

Regards
Anees

Last edited by anees_muhd; March 7th, 2009 at 01:34 AM..
The Following User Says Thank You to anees_muhd For This Useful Post:
sabra (March 7th, 2009)
 
Old March 7th, 2009, 01:24 AM
Authorized User
 
Join Date: Jul 2006
Posts: 73
Thanks: 11
Thanked 1 Time in 1 Post
Default

Hi Anees, Great Thenks
 
Old March 21st, 2009, 07:18 PM
Authorized User
 
Join Date: Jul 2006
Posts: 73
Thanks: 11
Thanked 1 Time in 1 Post
Default

Hi all, I have problems to find instalation on web:
apache_2.2.9-win32-x86-no_ssl-r2.msi.





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make a pictures gallery with php & MySql Paul Weinstock Pro PHP 2 May 8th, 2009 02:50 PM
Php code to put&get images from mysql not working! angelbeans PHP Databases 1 September 8th, 2006 12:44 PM
Put a Video Clip on Web phungleon Flash (all versions) 3 September 6th, 2006 05:33 AM
Store Pictures on SQL Database fmo_82 C# 1 February 17th, 2005 11:47 PM
Need for Asp with Mysql Database,web stats karib Classic ASP Databases 13 March 26th, 2004 07:55 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.