Merhaba im şu anda bir blog oluşturmak, sadece php, veritabanları vb hakkında daha fazla abit öğrenmek için. Mesajlarımı düzenleyebilmek için şimdiye kadar kazandım.Veritabanında php ve Microsoft sql ile güncelleştirme satırı
<?php
error_reporting(E_ALL); ini_set('display_errors', 1);
$head = $_POST['title'];
$short = $_POST['short'];
$bread = $_POST['edit'];
$author = $_POST['author'];
$cat = $_POST['cat'];
$id = $_POST['id'];
$db = new PDO('sqlsrv:server=localhost;Database=blog', '*****', '*********');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = 'UPDATE dbo.blog_posts SET (blog_title, blog_short, blog_post, blog_author, blog_category) VALUES (:head, :short, :bread, :author, :cat) WHERE blogID=$id';
$query = $db->prepare($sql);
$query->execute(array(':head'=>$head, ':short'=>$short, ':bread'=>$bread, ':author'=>$author, ':cat'=>$cat));
header("Location: index.php");
?>
şimdi ben hata msg olsun:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[07002]: [Microsoft][SQL Server Native Client 11.0]COUNT field incorrect or syntax error' in C:\inetpub\wwwroot\dev\ny\post_edit.php:17 Stack trace: #0 C:\inetpub\wwwroot\dev\ny\post_edit.php(17): PDOStatement->execute(Array) #1 {main} thrown in C:\inetpub\wwwroot\dev\ny\post_edit.php on line 17
hattını 17 olduğunu yürütmek dizi ancak ben
bu benim kod şimdiye kadar benzediğini olduğunu ... çalışma almak için mücadele
ben de denedim:
<?php
error_reporting(E_ALL); ini_set('display_errors', 1);
$head = $_POST['title'];
$short = $_POST['short'];
$bread = $_POST['edit'];
$author = $_POST['author'];
$cat = $_POST['cat'];
$id = $_POST['id'];
$db = new PDO('sqlsrv:server=localhost;Database=blog', '*****', '*****');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = 'UPDATE dbo.blog_posts SET blog_title=(:head), blog_short=(:short), blog_post=(:bread), blog_author=(:author), blog_category=(:cat) WHERE blogID=:id';
$query = $db->prepare($sql);
$query->execute(array(':head'=>$head, ':short'=>$short, ':bread'=>$bread, ':author'=>$author, ':cat'=>$cat));
header("Location: index.php");
?>
Aynı hatayı veren
da, yürütme satırının nasıl değiştirileceğini gerçekten bulamıyor.
Düzenleme:
ben sadece tekrar boş bir sayfa almak Aşağıda bu kodu kullanarak ..:/
<?php
error_reporting(E_ALL); ini_set('display_errors', 1);
$head = $_POST['title'];
$short = $_POST['short'];
$bread = $_POST['edit'];
$author = $_POST['author'];
$cat = $_POST['cat'];
$id = $_POST['id'];
$db = new PDO('sqlsrv:server=localhost;Database=blog', '******', '*****');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = UPDATE `blog_posts` SET `blog_title` = :head, `blog_short` = :short, `blog_post` = :bread, `blog_author` = :author, `blog_category` = :cat WHERE `blogID` = :id;
$query = $db->prepare($sql);
$query->execute(array(':id'=>$id, ':head'=>$head, ':short'=>$short, ':bread'=>$bread, ':author'=>$author, ':cat'=>$cat));
header("Location: index.php");
?>
'$ _POST [ 'id']' –
oh şimdi en az ... –
@LPK yazı –