Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [MySQL][PHP]right syntax to use near 'Resource id #1' at line 1
Raven1122
post
Post #1





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

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


Ktos pomoze?

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 'Resource id #1' at line 1

  1. <?php
  2. $author = $_POST['author'];
  3. $title = $_POST['title'];
  4. $id = 0;
  5. $votes = 0;
  6.  
  7. $link = mysql_connect('xxx', 'xxx', 'xxx') or die(mysql_error());
  8. $result = mysql_query($link) or die(mysql_error());
  9.  
  10. mysql_select_db("bassplay_web");
  11.  
  12. $sql = "INSERT INTO pool_top10(id, name, glosy) " .
  13. "VALUES ('$id', '$author' . '$title', '$votes')";
  14. $result = mysql_query($sql) or die(mysql_error());
  15. ?>


Ten post edytował Raven1122 4.09.2011, 12:32:59
Go to the top of the page
+Quote Post
Vhaeraun
post
Post #2





Grupa: Zarejestrowani
Postów: 57
Pomógł: 6
Dołączył: 10.01.2011

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


Wydaje mi się, że może się przyczepiać do tej konkatenacji
  1. '$author' . '$title'

Spróbuj wykonywać konkatenację wcześniej i potem do polecenia SQL wstawiać tylko jedną zmienną w stylu:
  1. $name=$_POST['author'] . $_POST['title'];
  2. ...
  3. $sql = "INSERT INTO pool_top10(id, name, glosy) VALUES ('$id', '$name', '$votes')";


--------------------
Pomogłem ? Kliknij pomógł :)
Go to the top of the page
+Quote Post
mortus
post
Post #3





Grupa: Zarejestrowani
Postów: 2 178
Pomógł: 596
Dołączył: 25.09.2009
Skąd: Piwniczna-Zdrój

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


A co to jest (linia 8)?
  1. $result = mysql_query($link) or die(mysql_error());

Do połączenie z mysql wystarczy mysql_connect(), nie trzeba zapytania do tego wykonywać. Wyrzuć tę linię i powinno być OK.

@down:
Teraz linia 7 jest niepotrzebna.

Ten post edytował mortus 4.09.2011, 13:07:40
Go to the top of the page
+Quote Post
Raven1122
post
Post #4





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

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


ciagle to samo:
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 'Resource id #1' at line 1

  1. <?php
  2. $name = $_POST['author'] . $_POST['title'];
  3. $id = 0;
  4. $votes = 0;
  5.  
  6. $link = mysql_connect('localhost', 'bassplay_web', 'ceowwyso1212') or die(mysql_error());
  7. $result = mysql_query($link) or die(mysql_error());
  8.  
  9. mysql_select_db("bassplay_web");
  10.  
  11. $sql = "INSERT INTO pool_top10 (id, name, glosy) " .
  12. "VALUES ('$id', '$name', '$votes')";
  13. $result = mysql_query($sql) or die(mysql_error());
  14. ?>
Go to the top of the page
+Quote Post

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

 



RSS Aktualny czas: 21.08.2025 - 18:46