1zeus1 Posted July 6, 2015 Share Posted July 6, 2015 Hello I want multiple inserts into a table Without an index, insert works If you created a unique index, the insert does not work $values = array(); foreach ($get->find('h3[class=r] a') as $e) { $sit = strtolower($e -> href); $values[] = "('$sit')"; } mysql_query('INSERT INTO xsit (var) VALUES '.implode(',', $values)); thanks for your help Quote Link to comment https://forums.phpfreaks.com/topic/297201-multiple-inserts/ Share on other sites More sharing options...
dalecosp Posted July 6, 2015 Share Posted July 6, 2015 (edited) Into what table? An HTML table? A Database Table? The Dining Table? Assuming the 2nd option above (DB table), I guess, eh ... don't create a unique index? But seriously, you don't give us your DB structure, and you don't give us sample data or tell us what the data is (it appears to be an array of URLs?) ... How about this? mysql> describe xsit; +-------+---------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+---------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | var | text | YES | | NULL | | +-------+---------+------+-----+---------+----------------+ 2 rows in set (0.00 sec) Seems like it would work with that? [edit]PS: someone will probably say "Stop using the old mysql_* functions. I agree [/edit] Edited July 6, 2015 by dalecosp 1 Quote Link to comment https://forums.phpfreaks.com/topic/297201-multiple-inserts/#findComment-1515724 Share on other sites More sharing options...
cyberRobot Posted July 7, 2015 Share Posted July 7, 2015 Have you tried using mysql_error() to see if MySQL is throwing errors? More more information can be found here: http://php.net/manual/en/function.mysql-error.php 1 Quote Link to comment https://forums.phpfreaks.com/topic/297201-multiple-inserts/#findComment-1515755 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.