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
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]

Edited by dalecosp
  • Like 1
Link to comment
Share on other sites

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.