0

I recently had to move from one hosting provider to another (if you're in the UK don't use Easyspace for your VPS!) as my previous host dumped my server without warning.

Fortunately I had remote backups in place and I've been able to restore almost all of my client sites and databases without a hitch. Except this one.

Since I restored my databases, some of them are exhibiting very unusual behaviour, specifically NULLing out rows of data or certain fields across multiple rows.

Has anyone experienced this before/know what the cause is? It only seems to occur when records are updated.

My backups consisted of a

mysqldump --all-databases

I restored to my new MySQL server using phpMyAdmin initially. Then I tried again, importing directly into MySQL from the command line and the same thing is happening.

2 Answers 2

0

Were the databases you are importing to, created with a different default character set to your database export/source databases? Differences between iso-8859-1 and UTF-8 will often cause data to be lost as you are reporting.

1
  • The character sets are the same. The data wasn't lost on backup, but rather on update of the data once it's in place!
    – simonhamp
    Jan 16, 2010 at 14:14
0

Turns out the problem is that I'm using mysql_real_escape string. My script is throwing me this:

Warning: [2] mysql_real_escape_string(): "Access denied for user 'www-data'@'localhost' (using password: NO)"

I'm using mysqli. So the function/method should be

mysqli_real_escape_string($link, $str);
// OR
mysqli::escape_string($str);

Seems really stupid, but it was working on my other server, even though there is no default setup for using mysql at all... it just seemed to get on with it. So I'm guessing it was shonky permissions and that my new server is exhibiting the correct behaviour.

Problem solved.

1
  • 1
    using mysqli_real_escape_string implies that you are not using bind parameters, which means it is almost a given that your site is vulnerable to SQL injection attacks. use bind parameters.
    – Justin
    Jan 16, 2010 at 20:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .