A simple image question ... could use some help
Posted: Thu Sep 12, 2002 5:06 pm
Hi,
I've been trying for about ten hours to get the sipmlest thing to work (trying different things, reading manuals and book), but somehow I'm not able to make it work.
What I want to do:
a) entering data into a table containing 3 fields:
logo_id | logo_name | logo_image
int (auto-increment) | varchar | varchar
Ok, I know you have 2 ways of storing images: blob and varchar.
Blob would be fantastic for me because the table would only contain 10 images of each 1 kb. I tried the thing with blob but didn't came anywhere nere. So I'll focussed on the varchar - variant.
I used the following form : (left out the excessive html-stuff)
In the php-file where variables are posted to I used following code
I get following error message in line 26 (= in bold in the previous code):
I dont' get any error message from the bool-thingy, so when I check each time I update a record there is an entry for the image logo (f.e. 1031842707C:\Documents and Settings\Administrator\My Documents\beelden TTOO\vegetarian.gif ==> this is the timestamp and the location I browsed the file from)
Questions:
1) Can anybody clearify me where I got wrong ?
2) Is there a tutorial or article or anything I can read more on uploading and displaying images with php and mysql ? If possible something comprehensive.
I've been trying for about ten hours to get the sipmlest thing to work (trying different things, reading manuals and book), but somehow I'm not able to make it work.
What I want to do:
a) entering data into a table containing 3 fields:
logo_id | logo_name | logo_image
int (auto-increment) | varchar | varchar
Ok, I know you have 2 ways of storing images: blob and varchar.
Blob would be fantastic for me because the table would only contain 10 images of each 1 kb. I tried the thing with blob but didn't came anywhere nere. So I'll focussed on the varchar - variant.
I used the following form : (left out the excessive html-stuff)
Code: Select all
...
// Query all facility logos
$logo_SQL = "SELECT * FROM general_facility_logo WHERE logo_id='".$_GETї'logo_id']."'";
$logo_result = mysql_query($logo_SQL);
$logo = mysql_fetch_array($logo_result);
...
<table width="90%" cellspacing="2" cellpadding="2" border="0">
<form method="POST" action="facility_logo_options.php">
<input type="hidden" name="action" value="update">
<input type="hidden" name="logo_id" value="<?php echo $logoї'logo_id'] ?>">
<tr>
<td bgcolor="#C0C0C0" width="100">Logo Name: </td>
<td bgcolor="#C0C0C0" width="100"><input type="text" name="logo_name" value="<?php echo $logoї'logo_name'] ?>" size="58" maxlength="100"></td>
</tr>
<tr>
<td bgcolor="#C0C0C0" width="100">Logo Image: </td>
<td bgcolor="#C0C0C0"><input type="file" name="logo_image" value="<?php echo $logoї'logo_image'] ?>">
</td>
</tr>
<tr>
<td bgcolor="#C0C0C0" colspan="2"><center><input type="submit" name="submit" value="OK"></center></td>
</tr>
</form>
</table>Code: Select all
// to check that action is actually set before trying to do anything with it
if (isset($_POSTї'action'])) {
switch ($_POSTї'action']) {
case 'update':
// Checking if the varaibles from form are set
if (isset($_POSTї'logo_id']) && isset($_POSTї'logo_name']) && isset($_POSTї'logo_image'])) {
// Checking the image
if($_POSTї'logo_image'] !="none") {
// if there has been a new image to upload
$source = $_POSTї'logo_image'];
$image_name = time() . $_POSTї'logo_image'];
// making the url
$dest = "C:/www/TTOO/admin/general/facility_logo/" . $image_name;
їb]$check1 = copy($source,$dest); ї/b] }
// Updating the record in the database
$logo_update_SQL = "UPDATE general_facility_logo SET logo_name='".$_POSTї'logo_name']."', logo_image='$image_name' WHERE logo_id='".$_POSTї'logo_id']."'";
// Displaying a message depending on the outcome of the query
$bool = mysql_query($logo_update_SQL);
if($bool == 1) echo "<SCRIPT LANGUAGE=Javascript>window.alert('The Facility Logo has been updated.')</script>";
if($bool <> 1) echo "<SCRIPT LANGUAGE=Javascript>window.alert('There has been an error.')</script>";
// Performing a a refresh of the facility logo list
$logo_SQL = "SELECT * FROM general_facility_logo";
$logo_result = mysql_query($logo_SQL);
// Kicking out the variable
unset($_POSTї'action']);
} else {
// actions when $_POSTї'action'] not set
echo "The variables for the form in facility_logo_edit.php are not set";
}
// Stopping the switch statement
break;
default :
echo "The Switch Case: Update has not been performed";
}
} else {
// actions when $_GETї'action'] or $_POSTї'action'] are not set
// none defined for the moment !!!!
}Code: Select all
Warning: Unable to create 'C:/www/TTOO/admin/general/facility_logo/1031865865C:\\Documents and Settings\\Administrator\\My Documents\\beelden TTOO\\solarium.gif': Invalid argument in C:\www\TTOO\admin\general\facility_logo_options.php on line 26Questions:
1) Can anybody clearify me where I got wrong ?
2) Is there a tutorial or article or anything I can read more on uploading and displaying images with php and mysql ? If possible something comprehensive.