How to insert a value with single quote into item field via podio api

Answered

Comments

3 comments

  • Andreas Haugstrup Pedersen

    Can you share your actual code? This should work.

    /Andreas

    0
    Comment actions Permalink
  • ehub workspace

    Hi Andreas,

    I have attached my actual code. I have use the below:

    mysql_real_escape_string($this->agent_details);

     

    Before using either mysql_real_escape_string or addslashes, as long there is a single quote like the below, it will not create or update the item on podio app.

    Example:

    These's are my shoes

     

    But if i use either mysql_real_escape_string or addslashes, it will be able to create and update the item on the app but i will see a forward slashes before all my single quote.

    Please advice

     

    0
    Comment actions Permalink
  • Andreas Haugstrup Pedersen

    Hi,

    I didn't review your code since it's 2500 lines and that would take quite some time. I instead made sure that things work on our end. You can test yourself with this minimal example that updates the value of a text field to one that contains a single quote:

    $item_id = 1234; // Replace with a real item id

    $field_external_id = 'title'; // Replace with external_id of text field on item

    $item = PodioItem::get_basic($item_id);

    $item->field($field_external_id)->set_value("My new value's value");

    $item->field($field_external_id)->save();

    This will correctly update the field's value to a string containing a single quote. My guess would be that you have a problem somewhere else in those 2500 lines which results in the string being different than what you think it is.

    You can kick podio-php into a debug mode which will log all API requests for you. That's a good way to make sure you are sending the data you think you are sending. Details: https://github.com/podio/podio-php#debugging--error-handling

    /Andreas

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk