UPDATE statement doesn't get triggered on new server

53 views Asked by At
foreach($article AS $key => $value)
{
    mysql_query("UPDATE articles SET description = '".mysql_real_escape_string($value)."' WHERE id = '".$key."'");
}

Hi guys,

I have this very simple foreach loop where I run an UPDATE query. Yeah, I know that I should use PDO but I'm just testing it so don't worry. $key and $value are not null. I've already verified that their values are the expected ones. $value contains a string with multiple \n (new line).

Now the script is working on my server but as soon as I try it on another server the UPDATE statement doesn't get triggered. No errors or warning. It seems that the other server doesn't like the content of $value. In fact if I replace $value for example with "abc" it works. So I'm here trying to understand what the problem. The \n? The mysql_real_escape_string? What should I do to debug this issue?

2

There are 2 answers

0
Meldiron On
foreach($article AS $key => $value)
{
    mysql_query("UPDATE articles SET description='{mysql_real_escape_string($value)}' WHERE id='{$key}'");
}

Try this

0
user1274113 On

Sorry, it was my bad. The script works. It was due to an incredibly complicated and long to explain thing related to a CDN cache of my cloud instance. What the hell! Sorry.