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
Save Images to mySQL database???
Old 01-25-2009, 12:09 AM Save Images to mySQL database???
Experienced Talker

Posts: 38
Name: carl
Trades: 0
ok, I have a script that allows a user to input information into an html form which submits that info to a php script which then puts that info into my mySQL database.

Currently it only allows the fields of: last name, first name,city, state, country, gender

I want to all ow the upload of images as well, one which will be displayed in the search results, i.e. Myspace when you search for people.

Also, how exactly should I set up the field in my database to allow this?


Here is the script:

HTML PART


Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="content-type">
  <title></title>
</head>
<body>
<form action="http://ex-brief.com/insert/" method="post">
<table style="text-align: left; width: 70%;" border="0"
 cellpadding="0" cellspacing="5">
  <tbody>
    <tr>
      <td>First Name:</td><td><input
 tabindex="1" name="first"></td>
      <td>City</td><td><input tabindex="3" name="city"><br>
      </td>
    </tr>
    <tr>
      <td>Last Name:</td><td><input
 tabindex="2" name="last"></td>
      <td>State/Province:</td><td>
      <select name="state">
      <option>IL</option>
      </select>
      </td>
    </tr>
    <tr>
      <td>Gender:</td><td><input name="gender"
 value="Male" type="radio">Male&nbsp;&nbsp;
&nbsp;&nbsp;<input name="gender" value="Female"
 type="radio">Female</td>
      <td>Country:
</td><td>
      <select name="country">
      <option>IL</option>
      </select>
      </td>
    </tr>
    <tr>
      <td><input name="searching" value="yes"
 type="hidden">
      </td>
      <td></td>
    </tr>
  </tbody>
</table><P><input type="submit"></P>
</form>
</body>
</html>
PHP PART
Code:
<?php


$first=$_POST['first'];
$last=$_POST['last'];
$city=$_POST['city'];
$state=$_POST['state'];
$country=$_POST['country'];
$gender=$_POST['gender'];


mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query = "INSERT INTO contacts VALUES ('','$first','$last','$city','$state','$country','$gender')";
mysql_query($query);

if($query) {
echo "You have successfully created an ExBrief!";
} else {
echo "Your Ex Brief was not created.  Please review the information you entered for accuracy.";
}

mysql_close();


?>
thanks!
Exbrief is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-25-2009, 10:20 AM Re: Save Images to mySQL database???
stoot98's Avatar
Ultra Talker

Posts: 427
Name: Stuart
Location: Glasgow, Scotland
Trades: 0
There are lots of arguments for and against storing files in databases, personally I would just upload the file to the file system and then store the path to the image in the table.

If you want to go down the other path you can store it as a BLOB type.
stoot98 is offline
Reply With Quote
View Public Profile
 
Old 01-25-2009, 11:32 AM Re: Save Images to mySQL database???
Defies a Status

Posts: 1,605
Trades: 0
I agree 100% with what stoot98 said above. I always store the link to the image in the DB.

Also be sure to use some form of renaming to insure each has a unique name.
__________________
Colbyt

Please login or register to view this content. Registration is FREE
colbyt is offline
Reply With Quote
View Public Profile
 
Old 01-25-2009, 03:48 PM Re: Save Images to mySQL database???
Experienced Talker

Posts: 38
Name: carl
Trades: 0
i understand all that. I need to know how to do it exactly. People will be uploading the pics when they create profiles, I will not be uploading them. My scripts already allow them to upload information, but no images. Anyone know a good way to do this?
Exbrief is offline
Reply With Quote
View Public Profile
 
Old 01-25-2009, 05:37 PM Re: Save Images to mySQL database???
Decaf's Avatar
Ultra Talker

Posts: 489
Name: Adam
Trades: 0
I love google: Image Databasing
__________________

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

Decaf is offline
Reply With Quote
View Public Profile Visit Decaf's homepage!
 
Old 01-25-2009, 05:49 PM Re: Save Images to mySQL database???
Experienced Talker

Posts: 38
Name: carl
Trades: 0
thanks, but that has me starting from scratch....I just want to add the image upload to an EXISTING form which I already have created and posted above!
Exbrief is offline
Reply With Quote
View Public Profile
 
Old 01-25-2009, 05:58 PM Re: Save Images to mySQL database???
Decaf's Avatar
Ultra Talker

Posts: 489
Name: Adam
Trades: 0
Quote:
Originally Posted by Exbrief View Post
thanks, but that has me starting from scratch....I just want to add the image upload to an EXISTING form which I already have created and posted above!
I'm pretty sure that you can read that guide and copy/implement the same ideas into your own code, I doubt that people will have made code that fits your form exactly.
__________________

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

Decaf is offline
Reply With Quote
View Public Profile Visit Decaf's homepage!
 
Old 01-25-2009, 09:30 PM Re: Save Images to mySQL database???
anderswc's Avatar
Super Talker

Posts: 132
Name: Will Anderson
Location: Terre Haute, IN
Trades: 0
You're not going to find someone who has the same code as what you already have, but simply added the image upload. That's an unreasonable expectation.

You're going to have to do the integration to your current form yourself, unless you find someone who you can pay to do it.
__________________
Will Anderson

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
anderswc is offline
Reply With Quote
View Public Profile Visit anderswc's homepage!
 
Old 01-25-2009, 10:38 PM Re: Save Images to mySQL database???
Experienced Talker

Posts: 38
Name: carl
Trades: 0
i know nobody has my exact script....except for those who are reading my original post above. I guess I will figure out how to add the image upload to this script. thanks.
Exbrief is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Save Images to mySQL database???
 

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.28114 seconds with 12 queries