Jump to content

Insert ignore into error


Recommended Posts

Having a problem with that "insert ignore into".

If it is a new record, it works, when it is a excisting record that needs to be updated, it is giving me this error:

Cannot execute query: INSERT IGNORE INTO (gedcom,kennel) VALUES ("World","Avongara")


What or where is it going wrong? This message is for me not enough to find the problem.


$kennels = array();
if( !in_array( $kennel, $kennels ) ) array_push( $kennels, $kennel );
foreach( $kennels as $kennel ) {
$query = "INSERT IGNORE INTO $kennels_table (gedcom,kennel) VALUES (\"$tree\",\"$kennel\")";
$result = @mysql_query( $query ) or die ("$admtext[cannotexecutequery]: $query");


Thanks for helping :shy:

Link to comment
Share on other sites

Hi there,


I wonder what other error messages you are masking by using the error suppressor on the beginning of the mysql_query() function, I would have thought that the more info you got from the function the better?


And personally (shouldn't affect the running) I would do my sql statement like this:-


$query = "INSERT IGNORE INTO `".$kennels_table."` (`gedcom`,`kennel`) VALUES ('".$tree."','".$kennel."') ";


That at least now has single quotes around the string values, you don't need single quotes around numerical values (ints) as this will cause error's or at least make them harder to find in the longrun.


Hope that makes sense anyway.




Link to comment
Share on other sites

Thanks for the fast reply.


When changing it to your version it is still giving me the same error but with ``after the INTO:

Cannot execute query: INSERT IGNORE INTO `` (`gedcom`,`kennel`) VALUES ('World','Avongara')

before it was:

Cannot execute query: INSERT IGNORE INTO (gedcom,kennel) VALUES ("World","Avongara")


Not enough for me to find the problem.

Link to comment
Share on other sites

If you ask, the server will tell you what is wrong.  Add mysql_error() to your "error handler".

$result = @mysql_query( $query ) or die ("$admtext[cannotexecutequery]: $query\n" . mysql_error());

I do not use nor recommend the error suppression operator (@) and I do not use nor recommend "or die()" -- I just copied your code and added a little bit to it.


Note: You do not need the backticks ( ` ) around column names unless they are reserved words.


Oh, wait a minute: look at your query, there is no way that query is working at all:

INSERT IGNORE INTO (gedcom,kennel) VALUES ("World","Avongara")


There is no table name there.  It needs to be

INSERT IGNORE INTO tablename (gedcom,kennel) VALUES ("World","Avongara")


It looks like $kennels_table does not have a value.

Link to comment
Share on other sites



Yes i saw that also at 03.00AM but did go to sleep. Todayy I truncate all tables and the strange thing is that when adding a record, it is doing what it needs to do. If i echo the query it gives me:

INSERT IGNORE INTO tng_breeders (gedcom,breeder) VALUES ("World","Unknown Breeder")

You see there is a table name. Is there a reason why it fails when adding a lot of records? I start putting back data in the tables and see when it starts to fail again.

Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.