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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:25:19+00:00 2026-05-31T18:25:19+00:00

I want to uapdate a table field with an array.That means i have a

  • 0

I want to uapdate a table field with an array.That means i have a table with name test.In that table i inserted some rows first.

After some process i want to update a filed in this table with ana array value.When i inserting rows into this table at that time this filed is set to 0.

After some process some values returned to a variable $var like:

Array
(
    [id] => "http://www.google.com/calendar/"
    [etag] => "GEwNTgxHfip7JGA6WhJV"

    [link] => "http://www.google.com/calendar/"

)

This is the code iam using for updating field:

$idg= json_encode($var);
mysql_query("UPDATE `test` SET `tk` = '$idg' WHERE `TID` =10");

The above code is the edited code .The $idg now have:

{"id":"http:\/\/www.google.com\/calendar\/feeds\/testid%40gmail.com\/events\/64h9vc0qqqtlqeqhudhhdqbsds","etag":"\"GEwCQwxGeSp7JGA6WhJV\"\r","link":"http:\/\/www.google.com\/calendar\/feeds\/testid%40gmail.com\/private\/full\/64h9vc0qqqtlqeqhudhhdqbsds\r"}

After excuting this code the field will updated with null value.This is the problem facing now.

  • 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-05-31T18:25:21+00:00Added an answer on May 31, 2026 at 6:25 pm

    Since your table column can only contain a scalar value you have to convert the array into some string representation, e.g. via json_encode().
    When you fetch the value from the table again you have to convert it back, in this case via json_decode().


    edit: or use a storage mechanism/database that can handle this type of data, e.g. a document based database like mongodb.


    edit2: add parameter encoding, error handling and debug code

    <?php
    echo "start\n";
    
    $tid = 10;
    $idg = json_encode($var);
    $idg_sql = mysql_real_escape_string($idg);
    
    $query = "
        UPDATE
            `test`
        SET
            `tk` = '$idg_sql'
        WHERE
            `TID` = $tid
    ";
    
    $result = mysql_query($query);
    if ( !$result ) {
        die(mysql_error());
    }
    
    if ( 1 < mysql_affected_rows() ) {
        // debugging
        echo "no affected rows\n";
        $result = mysql_query("SELECT Count(*) as c FROM `test` WHERE `TID`=$tid") or die(mysql_error());
        while( false!==($row=mysql_fetch_assoc($result)) ) {
            var_dump($row);
        }
    }
    
    echo "done.\n";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to update a table to indicate that some rows are parents of
I have a database table that i want to allow my friends to update.
Now I want to update table. Assumes that, I have PurchaseOrder and PurchaseOrderDetails. I
I have two tables, and want to update fields in T1 for all rows
I have a Table View Controller with cells. I want to update the text
I want to have an 'updateinfo' table in order to record every update/insert/delete operations
I want to add a value to an array that is inside another array.
I have a html table that I am populating with PHP, now it is
I have a while loop that goes through a table and I echo the
I have an array of folders. Each folder is listed as a table view

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.