Re: Frustrated, puzzled and confused: outputting images from a database
| From: | Jon Rosenberg | Date: | Wed, 13 Dec 2000 04:54:01 +0000 |
| Subject: | Re: Frustrated, puzzled and confused: outputting images from a database | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-30020@lists.php.net to get a copy of this message | ||
$form_data_name and $form_data_type are generated for you by PHP, so that's
easy. It might be easier to just show you the function I made. It's for a
personals program..so it's got alot of data...but you get the idea. If you
want to see the script in action..goto http://www.politics2004.com/personals
beware, the user interface is very rudimentary right now.
Here it is:
function add_to_db( $_fname, $_lname, $_email, $_uname, $_pword, $_sex,
$_age, $_city, $_state, $_orientation, $_status, $_race, $_religion,
$_height, $_weight, $_hair, $_eyes, $_education, $_occupation, $_interests,
$_match, $_other, $_date, $bin_pic, $form_data_name, $form_data_type,
&$dberror )
{
global $user, $pass, $db, $db_table, $db_connect, $home_url, $admin_email,
$reg_subject, $reg_message;
if ( $_uname == "" || $_pword == "" )
{
print "<br /><br /><center><font color=\"red\">You must
enter both a
username and password.<br /><br /></center></font>";
print_form_full_reg( $_fname, $_lname, $_email, $_uname, $_pword, $_sex,
$_age, $_city, $_state, $_orientation, $_status, $_race, $_religion,
$_height, $_weight, $_hair, $_eyes, $_education, $_occupation, $_interests,
$_match, $_other, $_date );
exit;
}
if ( ! $db_connect )
{
$dberror = "Couldn't connect";
return false;
}
if ( ! mysql_select_db( $db, $db_connect) )
{
$dberror = mysql_error();
return false;
}
$db_query = "INSERT INTO $db_table ( _fname, _lname, _email, _uname,
_pword, _sex, _age, _city, _state, _orientation, _status, _race, _religion,
_height, _weight, _hair, _eyes, _education, _occupation, _interests, _match,
_other, _date, bin_pic, filename, filetype ) values ( '$_fname', '$_lname',
'$_email', '$_uname', '$_pword', '$_sex', '$_age',
'$_city', '$_state',
'$_orientation', '$_status', '$_race', '$_religion',
'$_height', '$_weight',
'$_hair', '$_eyes', '$_education', '$_occupation',
'$_interests', '$_match',
'$_other', '$_date', '$bin_pic', '$form_data_name',
'$form_data_type' )";
//query for db into a variable
if ( ! mysql_query( $db_query, $db_connect ) ) //'execute' the variable
using mysql_query function
{
$dberror = mysql_error();
return false;
}
else //sends email to user when their info is entered into the db
{
mail( "$_email","$reg_subject","$reg_message", "Content-Type:
text/html;
charset=\"iso-8859-1\"\nFrom:$admin_email\nReply-To:$admin_email\nX-Mailer:P
HP/" . phpversion() );
}
mysql_close ( $db_connect );
return true;
}
----- Original Message -----
From: "Jason Murray" <Jason.Murray@melbourneit.com.au>
To: "'Jon Rosenberg'" <php@columbusinteractive.com>
Sent: Tuesday, December 12, 2000 8:45 PM
Subject: RE: [PHP] Frustrated, puzzled and confused: outputting images from
a database
> Hiya Jon,
>
> Everything's much appreciated, thanks :)
>
> > $add_to_db = add_to_db( $_fname, $_lname, $_email,
> > $_uname, $_pword,
> > $_sex, $_age, $_city, $_state, $_orientation, $_status,
> > $_race, $_religion,
> > $_height, $_weight, $_hair, $_eyes, $_education,
> > $_occupation, $_interests,
> > $_match, $_other, $_date, $bin_pic, $form_data_name, $form_data_type,
> > $dberror );
>
> With that add_to_db being a custom function, do I need to put the binary
> data inside the usual ' quote marks...?
>
> Jason
>