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 8759113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:43:11+00:00 2026-06-13T14:43:11+00:00

Okay this will be my last post here for today, have asked you guys

  • 0

Okay this will be my last post here for today, have asked you guys enougth questions about why my terrible code dosnt work 🙂

I am trying to run a query to update all values of a column with a text documents contents. My database looks like follows:

Attribute_id | value
64 | Data.txt
109 | other data
64 | Data2.txt
109 | other data

If you look at my script you can see what I am trying to do, for now I am echoing the query the end result is here: http://dev.central-pet-supplies.co.uk/test.php

it is returning
UPDATE mage_catalog_product_entity_text SET value= ‘Array’ WHERE value = ‘13685.txt’
however array should be the text files contents

Here is the script:

<?php

mysql_connect ("localhost","cpsdev_mage1","********"); 
mysql_select_db ("cpsdev_mage1"); 

$sql = "select value from mage_catalog_product_entity_text WHERE Attribute_id = 64"; 
$result = mysql_query ($sql) or die($myQuery."<br/><br/>".mysql_error()); 

while($row = mysql_fetch_array($result,MYSQL_ASSOC))
{
$lines = file('http://dev.central-pet-supplies.co.uk/media/import/' . $row['value']);
$query3 = "UPDATE mage_catalog_product_entity_text " . " SET value= '" . $lines .  "'         WHERE value = '" . $row['value'] . "'";
echo $query3 ."<br>";
}

?>

Edit: changed file to file_get_contents and now working.

  • 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-13T14:43:12+00:00Added an answer on June 13, 2026 at 2:43 pm

    file() reads in the entire file with each line as a new entry in an array. Since you don’t want that, you can either join the lines together using implode() by putting

    $lines = implode( "\n", $lines);
    

    After:

    $lines = file('http://dev.central-pet-supplies.co.uk/media/import/' . $row['value']);
    

    Or, by using file_get_contents() instead of file(), which will return the entire file’s contents as a string, instead of an array:

    $lines = file_get_contents( 'http://dev.central-pet-supplies.co.uk/media/import/' . $row['value']);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, I'll simplify this post. I have a table tasks containing, for example, a
Okay, I have this simplified code to plot a simple contour map: try: header
Okay I have spent the last 2 days trying to sort this one out.
Okay, this scenario is a little complicated, but I will try to explain it
Okay, so this one may be difficult but I will do my best to
Okay this question is very simple: I have a facebook page, and a website.
Okay this is definitely a n00b question but here goes. The way I understand
Okay this may be a simple question but I have yet to come with
Okay this is my 4th question today on Scheme, still pretty new to Scheme,
Okay - this is the dumbest glitch I have seen in a while: <!DOCTYPE

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.