[ boba.gacas @ 09.02.2010. 11:18 ] @
Pocetnik sam u radu sa bazama i imam problem!!! Pri insertovanju podataka u bazu dobijam error:

Duplicate entry '1' for key 'PRIMARY'

Kod je sledeci:

<?php

//connect to MySQL
$connect = mysql_connect("localhost", "root", "root")
or die ("Hey, check your server connection");

//make sure we’re using the right database
mysql_select_db("moviesite");

//insert data into "movie" table
$insert = "INSERT INTO movie (movie_id, movie_name, movie_type, " .
"movie_year, movie_leadactor, movie_director) " .
"VALUES (1, 'Bruce Almighty', 5, 2003, 1, 2), " .
"(2, 'Office Space', 5, 1999, 5, 6), " .
"(3, 'Grand Canyon', 2, 1991, 4, 3)";
$results = mysql_query($insert)
or die(mysql_error());

//insert data into “movietype” table
$type = "INSERT INTO movietype (movietype_id, movietype_label) " .
"VALUES (1,'Sci Fi'), " .
"(2, 'Drama'), " .
"(3, 'Adventure'), " .
"(4, 'War'), " .
"(5, 'Comedy'), " .
"(6, 'Horror'), " .
"(7, 'Action'), " .
"(8, 'Kids')" ;
$results = mysql_query($type)
or die(mysql_error());

//insert data into “people” table
$people = "INSERT INTO people (people_id, people_fullname, " .
"people_isactor, people_isdirector) " .
"VALUES (1, 'Jim Carrey', 1, 0), " .
"(2, 'Tom Shadyac', 0, 1), " .
"(3, 'Lawrence Kasdan', 0, 1), " .
"(4, 'Kevin Kline', 1, 0), " .
"(5, 'Ron Livingston', 1, 0), " .
"(6, 'Mike Judge', 0, 1)";
$results = mysql_query($people)
or die(mysql_error());

echo "Data inserted successfully!";
?>


Hvala!!!
[ bogdan.kecman @ 09.02.2010. 11:24 ] @
primarni kljuc je unique - znaci moze da ima samo jedan slog sa tom vrednoscu. kada si prvi put izvrsio upit uneo si u bazu vrednost 1 za pk, sledeci put kada probas on ti kaze "imas duplikad za vrednost 1 za primarni kljuc"
[ boba.gacas @ 09.02.2010. 12:03 ] @
Shvatio sam i radi!!!

Hvala puno!!!!!
[ boba.gacas @ 09.02.2010. 12:14 ] @
>

Shvatio sam i radi!!!

Hvala puno!!!!! [?]

--0016e644b91aef3209047f29de0e
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<br><br><div class="gmail_quote">2010/2/9 bogdan.kecman <span dir="ltr">&lt;<a href="mailto:[email protected]">[email protected]</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
primarni kljuc je unique - znaci moze da ima samo jedan slog sa tom vrednoscu. kada si prvi put izvrsio upit uneo si u bazu vrednost 1 za pk, sledeci put kada probas on ti kaze &quot;imas duplikad za vrednost 1 za primarni kljuc&quot;<br>

<font color="#888888"><br>
--<br>
<a href="http://www.elitesecurity.org/p2517265" target="_blank">http://www.elitesecurity.org/p2517265</a><br>
</font><div><div></div><div class="h5"><br>
Prijave/odjave: <a href="http://www.elitesecurity.org/pracenje#390881" target="_blank">http://www.elitesecurity.org/pracenje#390881</a><br>
<br>
Ne menjajte sledece dve linije ukoliko odgovarate putem emaila!<br>
esauth:390881:5b1c30545c7bfee054f66cfd3f7ecfbf<br>