Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Useful: imagepaths after moving server

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 10-26-2003, 11:58 PM
 
mikamedia mikamedia is offline
 

Newbie
  
Join Date: Jul 2003
Posts: 3
 

Default Useful: imagepaths after moving server

Hi,

I had to move one of our X-cart site to a new server. We use the filesystem to store images, not the database. I noticed that X-cart saves the whole path info for every image stored in the database.
I wrote a very small but useful script for anyone that wants to change the path info for all images at one time:

Code:
<? mysql_connect('localhost', '%%username%%', '%%password%%'); $db = "%%dbasename%%"; Echo "Image paths will be changed for all images in X-cart..."; $selectPaths = mysql($db, "select * from xcart_thumbnails order by productid"); while ($rowPaths = mysql_fetch_row($selectPaths)) { $PathData = $rowPaths[2]; echo "Old path: $rowPaths[2] "; $PathData = str_replace ("%%old_path_in_database%%", "%%new_path_in_database%%", $PathData); echo "New path: $PathData "; // write update to database mysql($db, "update xcart_thumbnails set image_path = '$PathData' WHERE productid = '$rowPaths[0]'"); } echo " Done!"; ?>

Replace all the %% %% with your own values.

It's not very handy to store the full path into the database, but it hope it helps for some people!

Good luck.
John.
Reply With Quote
  #2  
Old 10-28-2003, 10:15 PM
 
funkydunk funkydunk is offline
 

X-Man
  
Join Date: Oct 2002
Location: Cambridge, UK
Posts: 2,210
 

Default

Very useful.
__________________
ex x-cart guru
Reply With Quote
  #3  
Old 08-23-2004, 12:53 PM
 
cyberdriveway cyberdriveway is offline
 

Advanced Member
  
Join Date: Aug 2004
Location: California
Posts: 32
 

Default Image path change xcart 4.0.2

I am only a couple of weeks into using x-cart. Tried to move the store to another location, and lost all of the image links. When I used the above code the "\"s were dropped from the path string during the update.

I was however able to make this sql statement work:

Code:
$sql= "UPDATE xcart_thumbnails SET image_path=( REPLACE (image_path,'dirA','dirB'))WHERE productid = '$rowPaths[0]';"; mysql_query($sql, yourconn);


dirA = original directory:
c:\inetpub\wwwroot\xcart\files\images.....

dirB = new directory:
c:\inetpub\wwwroot\backup\files\images....

Only include what needs to be changed:
(image_path, 'xcart', 'backup')


Hope this helps....
__________________
Tyson McPherson
X-Cart version 4.1.8
PHP 4.3.9
MySQL server 4.1.12-log
MySQL client 4.1.12
Web server Apache/2.0.52 (Red Hat)
Operation system Red Hat 3.4.6-2
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 06:48 PM.

   

 
X-Cart forums © 2001-2020