Text dosyamın içeriği
{
"Alıcının Adı": [
"ad"
],
"Alıcının Firma Adı": [
"firma"
],
"Alıcının Şehri": [
"18"
],
"Alıcının İlçesi": [
"ilçe"
],
"Alıcının Telefon Numarası": [
"999999999"
],
"Alıcının E-Posta Adresi": [
"eposta@eposta.com"
],
"Alıcının Sipariş Notları": [
"siparişler"
],
"Ürünün Stok Kodu": [
"8"
],
"Ürünün Stok Sayısı": [
"8"
],
"Ürünün Adı": [
"Ürün 2"
]
}
Text dosyasını veritabanına aktarmama yarayan sayfa içeriği
include("baglanti.php");
$dosya=new SplFileObject('ornektext.txt');
while(!$dosya->eof()) {
$satir=$dosya->fgets();
list($isim, $firmaadi, $sehir, $ilce, $telefon, $eposta, $siparis, $stokkodu, $stoksayisi, $urunadi)=explode(',',$satir);
$sorgu = $db->prepare('INSERT INTO sepetonaylanan VALUES (NULL,?,?,?,?,?,?,?,?,?,?)');
$sorgu->bindValue(1,$isim,PDO::PARAM_STR);
$sorgu->bindValue(2,$firmaadi,PDO::PARAM_STR);
$sorgu->bindValue(3,$sehir,PDO::PARAM_STR);
$sorgu->bindValue(4,$ilce,PDO::PARAM_STR);
$sorgu->bindValue(5,$telefon,PDO::PARAM_STR);
$sorgu->bindValue(6,$eposta,PDO::PARAM_STR);
$sorgu->bindValue(7,$siparis,PDO::PARAM_STR);
$sorgu->bindValue(8,$stokkodu,PDO::PARAM_INT);
$sorgu->bindValue(9,$stoksayisi,PDO::PARAM_INT);
$sorgu->bindValue(10,$urunadi,PDO::PARAM_STR);
$sorgu->execute();
}
?>
Veritabanına kayıt etmiyor ve verdiği hata
Undefined offset: 9 in C:\\AppServ\\www\\ornek\\kaydett.php on line 7
Yani hatayı şurada buluyor.
ist($isim, $firmaadi, $sehir, $ilce, $telefon, $eposta, $siparis, $stokkodu, $stoksayisi, $urunadi)=explode(',',$satir);