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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:17:32+00:00 2026-05-22T01:17:32+00:00

I am getting a string using curl: $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch,

  • 0

I am getting a string using curl:

$ch = curl_init();    
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_URL,"https://$URL");  
curl_setopt($ch, CURLOPT_POST, 1); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $arr);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
$result = curl_exec($ch);    
curl_close ($ch);

and then I am updating a table in mySQL with that string:

$query = "UPDATE $table SET code='$result' WHERE id=$id";
$result = mysql_query($query)or die("Update query failed : " . mysql_error());

problem is the column is blank after the update. If I echo $result I see the string in the browser so I know it is arriving from curl and if I type the string in myself (instead of using the curl $result) then it inserts fine as well. I’ve tried every combo of string cleaning I can think of:

mysql_real_escape_string(htmlentities($result));

But still no dice. Is there anything special about the string curl returns that would prevent it from being inserted into mySQL?

btw, the string it returns looks like this: ABC*DEF*12345ABC

SOLUTION

Following the advice given it turned out the curl $result had a \n at the head which I was not able to see until I echo’d the $query. I was able to quickly fix it with a str_replace() to remove the \n.

  • 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-22T01:17:32+00:00Added an answer on May 22, 2026 at 1:17 am

    I would modify the code slightly to the following to add some debug:

    $query = "UPDATE $table SET code='$result' WHERE id=$id";
    echo "query='{$query}'<br>\n";
    
    $result = mysql_query($query)or die("Update query failed : " . mysql_error());
    
    echo "rows=". mysql_affected_rows() ."<br>\n";
    

    Make sure that the query looks correct and attempt to run it from the MySQL console or phpmyadmin, workbench, etc and check to see if you get any errors when running it that way. When you run it from the console look very carefully to see if any warnings are generated on update.

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

Sidebar

Related Questions

Needing a bit help getting multiple values from a string using Regex. I am
I'm having trouble getting the XML from a file using the simplexml_load_file function. I
I'm getting a datetime string in a format like 2009-05-28T16:15:00 (this is ISO 8601,
I'm getting the current date/time using [NSDate date] . The value returned is an
I'm using the following code to find all properties for a user and in
I was using basic auth to send tweets from a server every time a
I am having trouble getting a success: function(){} working - the ajax code I
I am retrieving a value that is set by another application from memcached using
I have some PHP code that was at one point WORKING FINE. It makes
I'm working on an application in C++ that threads and hands a bunch of

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.