Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][MySQL]Problem z bindValue podczas dodawania rekordów do MySQL z użyciem PDO
Raven1122
post
Post #1





Grupa: Zarejestrowani
Postów: 369
Pomógł: 2
Dołączył: 1.11.2010

Ostrzeżenie: (0%)
-----


Witam, otoz mam taki problem, że podczas dodawania rekordów mam taki błąd:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1' in /home/radiolev/public_html/top/index.php:122 Stack trace: #0 /home/radiolev/public_html/top/index.php(122): PDOStatement->execute() #1 {main} thrown in /home/radiolev/public_html/top/index.php on line 122

Kod wygląda następująco:

  1. $author = $_POST['author'];
  2. $title = $_POST['title'];
  3. $link = $_POST['link'];
  4. $addedby = $_POST['addedby'];
  5.  
  6. $stmt = $db->prepare("INSERT INTO radiocms_toplistsongs(`sid`, `author`, `title`, `user`, `ytlink`, `votes`)VALUES('', ?, ?, ?, ?, 0");
  7. $stmt->bindValue(1, $author);
  8. $stmt->bindValue(2, $title);
  9. $stmt->bindValue(3, $addedby);
  10. $stmt->bindValue(4, $ytlink);
  11. $stmt->execute();
  12. header("Location:index.php?action=manage&show=addtomysql&state=success");


oczywiscie polaczenie jest gdzies tam u gory sobie, wiec polaczenie na pewno jest nawiazane.

Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 24.08.2025 - 00:41