Jump to content

[SOLVED] Inserting multiple rows within one query...


forumnz

Recommended Posts

Why does this not work? It just doesn't insert anything..

 

mysql_query("INSERT INTO chart_of_accs (hash_key, acc_hash, type, code, name, description, tax, show_exp_claims, sys_locked) 
VALUES ('$demo_hash', '" . md5(rand() . rand() . rand()) . "', 'r_r', '200', 'Sales', 'Income', 'gst_n', '0', '0'),
('$demo_hash', '" . md5(rand() . rand() . rand()) . "', 'e_o', '400', 'Advertising', 'Advertising', 'gst_n', '0', '0')");

 

Thanks

Sam

Probably due to type being in art of the columns. Add this to see the error:

 

mysql_query("INSERT INTO chart_of_accs (`hash_key`, `acc_hash`, `type`, `code`, `name`, `description`, `tax`, `show_exp_claims`, `sys_locked`)
VALUES ('$demo_hash', '" . md5(rand() . rand() . rand()) . "', 'r_r', '200', 'Sales', 'Income', 'gst_n', '0', '0'),
('$demo_hash', '" . md5(rand() . rand() . rand()) . "', 'e_o', '400', 'Advertising', 'Advertising', 'gst_n', '0', '0')") or die(mysql_error());

 

Give that a try and see what it returns.

 

It just comes up with:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'assets', 'gst_n', '0', '0'), ('4dee86e7c8696a5e41d71ef9a31c3682', '68317fcd9aec' at line 9

 

What does this mean?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.