1

I'm using CURL to pass an xml string created from the results of a query.

The string is created as follows:

while ($row = mysqli_fetch_assoc($data_to_insert)) {$data[ ] = $row;}

foreach($data as $datapiece)
{
 $data = data.'
 <field>
 <id>'.$datapiece["id"].'</id>
 <value>'.$datapiece["value"].'</value>

Why am I getting Array to string conversion notice?

7
  • Show all of your code related to this and which line the error comes up on. Commented Feb 12, 2015 at 23:46
  • I'm talking about in the while loop and after. You need to say which line is giving the error. Commented Feb 13, 2015 at 0:50
  • Before the while loop there are only DB credentials, the error is on the line inside the foreach loop on <id>'.$datapiece["id"].'</id>, after the while loop I have a $header variable that I insert into the xml to be sent as follows: $xml = $header.$string A var dump for $array shows the following: string(85) "Array 1 2 " Commented Feb 13, 2015 at 0:56
  • Exactly the same as: stackoverflow.com/questions/12959196/… Commented Feb 13, 2015 at 1:10
  • What is $string ? And could print_r($datapiece); please. Commented Feb 13, 2015 at 1:11

1 Answer 1

0
while ($row = mysqli_fetch_assoc($data_to_insert)) {$data[ ] = $row;} --->    $data is array in here

foreach($data as $datapiece)
{
$data = data.' ----> data is a string in here IT SHOULDN'T BE OVERWRITING PREVIOUS VARIABLE, VARIABLE NEEDS TO BE GIVEN A DIFFERNT NAME
<field>
<id>'.$datapiece["id"].'</id>
<value>'.$datapiece["value"].'</value>
Sign up to request clarification or add additional context in comments.

2 Comments

Why did you post this as an answer?.. And why are you overwriting the $data variable?
That was the mistake. I shouldn't have been overwriting $data. The $data = $data. '.... should have a different name. And that solves the problem. I really appreciate you taking the time to help me. It is the same situation as stackoverflow.com/questions/12959196/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.