Jump to content

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


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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
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.