/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Problems moving images based on an update to the database

Hi,

I’m creating a product database, and each product has a [B]Designer, Category [/B]and [B]SubCategory[/B].

When the admin uploads an image, it’ll just put the image filename in the database because it’ll determine the location based on the Designer and the Category.

I ran into a snag while trying to create an [B]if statement [/B]in that, if the Designer or the Category is changed, the image will need to moved to the new folder. So I passed 4 hidden values with the update form [B]olddesignerid, olddesigner, oldcategoryid [/B]and [B]oldcategory. [/B]To make it easier to grab where the image was..

Here’s my code that totally does nothing ?

[code=php] if (($_POST[‘olddesignerid’] != $_POST[‘DesignerID’]) || ($_POST[‘oldcategoryid’] != $_POST[‘CategoryID’])) {
$OldDesignerFolder = strtolower(preg_replace(‘/W/’, ”, $_POST[‘olddesigner’]));
$OldCategoryFolder = strtolower(preg_replace(‘/W/’, ”, $_POST[‘oldcategory’]));
$Image = $row_Product[‘Image’];
rename(“../store-images/products/” . $OldDesignerFolder . “/” . $OldCategoryFolder . “/” . $Image, “../store-images/products/” . $DesignerFolder . “/” . $CategoryFolder . “/” . $Image);
}
[/code]

Let me know if you see what I’m doing wrong.

Thanks,
Jesi

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@cinematic_jesiauthorDec 11.2008 — NEVERMIND! I figured it out, human error. Forgot that I added the product id to the image name =/.
×

Success!

Help @cinematic_jesi spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...