Jeff
Jeff

Reputation: 23

Is there a limit to MySQL queries?

I am trying to insert 10,000+ fields into my database? Is there a limit?

$sql = 'INSERT INTO `_'.$test.'` (`user`, `pass`) VALUES ' . preg_replace($test, $replace, $final_check) . ';';
mysql_query($sql) or die(mysql_error());

Every time I try to insert the data, it fails.

Upvotes: 2

Views: 201

Answers (2)

staticsan
staticsan

Reputation: 30555

There is a packet size limit in the MySQL protocol. If your SQL statement exceeds that, it can't send it to the server. The limit was for a very long time 16Mb, but fairly recent versions have raised it higher.

Also, check that you are enclosing each row's worth of data in it's own parentheses.

Upvotes: 0

homework
homework

Reputation: 5087

I believe it's your query. Make sure you are importing the right data, and it shouldn't fail.
Echo the $sql to test it.

echo $sql

Upvotes: 1

Related Questions