Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MySQL][PHP] Gdzie robię błąd ?
tofik1778983
post
Post #1





Grupa: Zarejestrowani
Postów: 144
Pomógł: 1
Dołączył: 22.11.2007
Skąd: lbn

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


Witam
Chcę zapisać do bazy wpis ktorego jeszcze nie ma.. jeśli juz jest ma sie wyświetlić komunikat.. oto kod:

  1. $min = 1;
  2. $max = $lvl -> fields['level'] +15;
  3.  
  4. $plan = $db -> Execute("SELECT * FROM `smith` WHERE owner=0 && level between ".$min." and ".$max." && (type='A' || type='S' || type='H' || type='W' || type='L') ORDER BY RAND() LIMIT 1");
  5. echo'wylosowano: '.$plan -> fields['name'];
  6. //$smith = $db -> Execute("SELECT * FROM `smith` where owner>0");
  7. $spr = $db -> Execute("SELECT count(*) as name FROM smith WHERE name=".$plan->fields['name']." && type=".$plan->fields['type']." && level=".$plan->fields['level']." && owner=".$player->id);
  8. //echo'<br><br>'.$spr->fields['name'].'<br><br>';
  9. if($spr->fields['name'] > 0)
  10. {
  11. echo'ten już jest w bzaie';
  12. }
  13. else
  14. {
  15. $db -> Execute("INSERT INTO smith (owner, name, type, cost, amount, level, lang) VALUES(".$player -> id.", '".$plan -> fields['name']."', '".$plan -> fields['type']."', ".$plan -> fields['cost'].", ".$plan -> fields['amount'].", ".$plan -> fields['level'].", '".$plan -> fields['lang']."')");
  16. }


Ten post edytował tofik1778983 1.12.2010, 02:08:49
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: 23.12.2025 - 06:31