Jump to content

multiple inserts


1zeus1

Recommended Posts

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
 

 

Link to comment
https://forums.phpfreaks.com/topic/297201-multiple-inserts/
Share on other sites

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]

Link to comment
https://forums.phpfreaks.com/topic/297201-multiple-inserts/#findComment-1515724
Share on other sites

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.