Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> query jest błędne a jednak wyświetla że pomyślnie usunięto...
mathevs
post
Post #1





Grupa: Zarejestrowani
Postów: 39
Pomógł: 0
Dołączył: 5.11.2012

Ostrzeżenie: (10%)
X----


Witam napisałem funkcje na usuwanie eventów funkcja działa poprawnie ale ... jesli w get id wpisze błędne id to i tak wywala że dodało pomyślnie ... nie wiem o co chodzi ..


Proszę o pomoc!


  1.  
  2.  
  3. $id = clearstr($_GET['id']);
  4.  
  5. $query = safe_sql("DELETE FROM ".$c['site'].".eventy WHERE id='".$id."'");
  6.  
  7. if(!$query) { echo'<script>alertify.error("Błąd w usuwaniu eventu!");</script>'; }
  8. else { echo'<script>alertify.success("Pomyślnie usunięto event!");</script>'; }
  9.  
  10.  


Ten post edytował mathevs 13.04.2013, 09:10:05
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 3)
r4xz
post
Post #2





Grupa: Zarejestrowani
Postów: 673
Pomógł: 106
Dołączył: 31.12.2008

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


google, google, google...

http://stackoverflow.com/questions/922398/...e-was-successfu
Cytat
For other type of SQL statements, INSERT, UPDATE, DELETE, DROP, etc, mysql_query() returns TRUE on success or FALSE on error

Cytat
PDO::exec() returns the number of rows that were modified or deleted by the SQL statement you issued. If no rows were affected, PDO::exec() returns 0


wniosek: skorzystaj z PDO

---edit---
no zawsze też można użyć jak piszą mysql_affected_rows, ale lepiej skorzystać z PDO

Ten post edytował r4xz 13.04.2013, 09:16:26


--------------------
Go to the top of the page
+Quote Post
mathevs
post
Post #3





Grupa: Zarejestrowani
Postów: 39
Pomógł: 0
Dołączył: 5.11.2012

Ostrzeżenie: (10%)
X----


Cytat(r4xz @ 13.04.2013, 10:13:53 ) *
google, google, google...

http://stackoverflow.com/questions/922398/...e-was-successfu



wniosek: skorzystaj z PDO

---edit---
no zawsze też można użyć jak piszą mysql_affected_rows, ale lepiej skorzystać z PDO



nie da się zrobić tego jakoś prosciej bo PDO nie obczajam .. :/
Go to the top of the page
+Quote Post
r4xz
post
Post #4





Grupa: Zarejestrowani
Postów: 673
Pomógł: 106
Dołączył: 31.12.2008

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


http://pl1.php.net/mysql_affected_rows
  1. <?php
  2. $link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
  3. if (!$link) {
  4. die('Could not connect: ' . mysql_error());
  5. }
  6.  
  7. /* this should return the correct numbers of deleted records */
  8. mysql_query('DELETE FROM mytable WHERE id < 10');
  9. printf("Records deleted: %d\n", mysql_affected_rows());
  10.  
  11. /* with a where clause that is never true, it should return 0 */
  12. mysql_query('DELETE FROM mytable WHERE 0');
  13. printf("Records deleted: %d\n", mysql_affected_rows());
  14. ?>


czytaj przykłady i komentarze smile.gif


--------------------
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: 20.08.2025 - 18:47