Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8050473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:05:53+00:00 2026-06-05T07:05:53+00:00

I am working with a portal, where there is content type. The front end

  • 0

I am working with a portal, where there is content type. The front end developer who made this portal added a CCK field for file attachment & there is already File attachment field given by core.
Now we won’t go to discuss why did he do that as I also don’t know.

Now I have to removed that CCK field & if I remove directly, I will loose all the data uploaded by this field as it will remove the table of it.

So now I am trying to replace the value from this CCK field table to default upload table & update the filepath in files table..so that it would come in view for attached files.

Because I am not very good at PHP or MySQL I am seeking some help from you guys..

Here is the basic code, which I have written…please suggest the correction & please tell me will I be able to connect remote server DB in doing it so –

<?php

mysql_connect("http://edlabs.in/connect:22","connect","");
mysql_select_db("connect");

for($i=0; $i<=1; $i++){

    $fid_cck = array(mysql_query("SELECT field_upload_doc_fid FROM content_field_upload_doc WHERE field_upload_doc_list > 0"));
    $fid_core = array(mysql_query("SELECT fid FROM upload"));

    foreach($fid_cck as $fid_cck_value){

        foreach($fid_core as $fid_core_value)
        {
            if($fid_cck_value != $fid_core_value){

                $file_name = mysql_query("SELECT filename FROM files WHERE fid = $fid_cck");
                $nid_cck = mysql_query("SELECT nid FROM field_upload_doc_fid WHERE fid = $fid_cck");
                $vid_cck = mysql_query("SELECT vid FROM field_upload_doc_fid WHERE fid = $fid_cck");

                mysql_query("INSERT INTO upload VALUES('$fid_cck', '$nid_cck', '$vid_cck', '$file_name', 1, 0)");

                $filepath = array(mysql_query("SELECT filepath FROM files WHERE fid = $fid_cck"));

                $new_filepath = str_replace("/background_docs", "", $filepath);

                mysql_query("UPDATE files SET filepath=$new_filepath WHERE fid = $fid_cck");

            }
        }
    }


}
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T07:05:54+00:00Added an answer on June 5, 2026 at 7:05 am

    I have solved this problem by following these steps-

    1. Created a DB with the same name as my portal at my local phpmyadmin.
    2. Exported three table named content_field_upload_doc, files & upload from DB of my portal.
    3. Wrote a custom PHP code with some MySQL query to make query and find DIFF of those files which are in content_field_upload_doc but not in upload table & picked the name of that from table files.(I am giving the code below).
    4. Ran the code on my wamp and echoed the INSERT query.
    5. Copied all the query & executed that with SQL on my phpmyadmin at portal DB.
    6. Copied all the files from previous used folder inside public folder & pasted that to default public folder.
    7. Removed the CCK field from content type…and it’s DONE..!

      die('Could not connect: ' . mysql_error());

      }
      else{

      mysql_select_db("connect");
      
      $rs_fudl = mysql_query("SELECT vid, nid, field_upload_doc_fid FROM content_field_upload_doc WHERE field_upload_doc_list > '0'");
      while($rs_fudl_row = mysql_fetch_array($rs_fudl))
      {
      
          $fid_fudl = $rs_fudl_row['field_upload_doc_fid'];
      
          $rs_file = mysql_query("SELECT filename,filepath FROM files WHERE fid = '$fid_fudl'");
      
          //echo mysql_num_rows($rs_file)."<br />";
      
          while($rs_file_row = mysql_fetch_array($rs_file)){
      
                  $rs_upload = mysql_query("SELECT * FROM upload where fid='".$fid_fudl."'");
      
                  if ( mysql_num_rows($rs_upload) == 0) {
      
                  /*  $new_filepath = str_replace("/background_docs", "", $rs_file_row['filepath']);
      
                      $filepath = $new_filepath;
                  */
                      $filename = $rs_file_row['filename'];
                      $vid_fudl = $rs_fudl_row['vid'];
                      echo "<br />";
      
                      $nid_fudl = $rs_fudl_row['nid'];
                      echo "<br />";
      
                      echo "INSERT INTO upload VALUES ('$fid_fudl','$nid_fudl', '$vid_fudl', '$filename','1', '0');" ;
                      echo "<br />";
                  //  echo "UPDATE files SET filepath= '$filepath' WHERE fid = '$fid_fudl';";     
      
                  }
          }
      }
      mysql_close($con);
      

      }

      ?>

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have been working with dotnetnuke portal and there i have created a module
I'm a web developer who's working in a new shop with developers from a
Currently I'm working on this project to create a SharePoint projects portal, but the
I'm working with Websphere Portal and Oracle. On two occasions last week, I found
I am working in Liferay Portal. I have created my custom work flow and
I am working on a vendor portal. An owner of a shop will login
I am working on a web based penny auction portal. I am using PetaPoco
I have been working on some games in Silverlight. However, the community and portal
I am working on SSRS 2008 and was wondering that if there is a
I am currently working on a portal and I need to use Liferay as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.