Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Mały Problem
bok
post 10.05.2005, 12:02:28
Post #1





Grupa: Zarejestrowani
Postów: 52
Pomógł: 0
Dołączył: 8.05.2005

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


Witam
mam taki skrypt:

  1. <?php 
  2. require 'config.php';
  3. $conn = mssql_connect(&#092;"$host\",\"$alogin\",\"$apass\"); 
  4. mssql_select_db('MuOnline', $conn); 
  5. $query_reset = mssql_query(&#092;"SELECT * FROM Character WHERE Name = '\".$_POST['name'].\"' AND AccountID = '\".$_POST['login'].\"'\"); 
  6. while($row_reset = mssql_fetch_array($query_reset)) 
  7. { 
  8. $resetcount = $row_reset['Reset']; 
  9. $resetplus = $resetcount + 1; 
  10. $value_points = 350 * $resetplus; 
  11. } 
  12. if (mssql_num_rows(mssql_query(&#092;"SELECT * FROM Character WHERE Name = '\".$_POST['name'].\"' AND AccountID = '\".$_POST['login'].\"'\")) > 0) { 
  13. $row = mssql_fetch_array(mssql_query(&#092;"SELECT * FROM Character WHERE Name = '\".$_POST['name'].\"' AND AccountID = '\".$_POST['login'].\"'\")); 
  14. if ($row['cLevel'] > '349') { 
  15. if ($row['Money'] > $money) { 
  16. $money_total = $row['Money'] - $money ; 
  17. $query = mssql_query(&#092;" 
  18. UPDATE Character SET cLevel = '1' WHERE Name = '\".$_POST['name'].\"' AND AccountID = '\".$_POST['login'].\"' 
  19. UPDATE Character SET Money = Money-50000000 WHERE Name = '\".$_POST['name'].\"' AND AccountID = '\".$_POST['login'].\"' 
  20. UPDATE Character SET Experience = '0' WHERE Name = '\".$_POST['name'].\"' AND AccountID = '\".$_POST['login'].\"' 
  21. UPDATE Character SET LevelUpPoint = Reset*200 WHERE Name = '\".$_POST['name'].\"' AND AccountID = '\".$_POST['login'].\"' 
  22. UPDATE Character SET Strength = '30' WHERE Name = '\".$_POST['name'].\"' AND AccountID = '\".$_POST['login'].\"' 
  23. UPDATE Character SET Dexterity = '30' WHERE Name = '\".$_POST['name'].\"' AND AccountID = '\".$_POST['login'].\"' 
  24. UPDATE Character SET Vitality = '30' WHERE Name = '\".$_POST['name'].\"' AND AccountID = '\".$_POST['login'].\"' 
  25. UPDATE Character SET Energy = '30' WHERE Name = '\".$_POST['name'].\"' AND AccountID = '\".$_POST['login'].\"' 
  26. UPDATE Character SET Reset = Reset+1 WHERE Name = '\".$_POST['name'].\"' AND AccountID = '\".$_POST['login'].\"'&#092;"); 
  27. if (!$query) { 
  28. echo &#092;"<font color='0099FF'><font size='2'>Character Reset could not be properly preformed. Database threw an error.\"; 
  29. } else { 
  30. echo &#092;"<font color='0099FF'><font size='2'>\".$_POST['name'].\" is successfully Reseted..\"; 
  31. } 
  32. } else { 
  33. echo &#092;"<font color='0099FF'><font size='2'>Character Reset could not be preformed. Not enough zen.\"; 
  34. echo &#092;"<br>Actual (\".$row['Money'].\") - Needed ($money)\"; 
  35. } 
  36. } else { 
  37. echo &#092;"<font color='0099FF'><font size='2'>Character Reset could not be preformed. Your not Level 350.\"; 
  38. } 
  39. } else { 
  40. echo &#092;"<font color='0099FF'><font size='2'>Character Reset could not be performed. Character \".$_POST['name'].\" or the Login given do not match.\"; 
  41. } 
  42.  
  43. ?>


ale chciałabym aby on działał dopiero wtedy gdy w kolumnie (rys. poniżej) ConnectStat wartość była 0, a gdy w tej samej kolumnie była wartość 1 to skrypt powyższy niezadziałał by

Go to the top of the page
+Quote Post
nospor
post 10.05.2005, 12:13:17
Post #2





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




To sprawdzaj czy ta wartosc wynosi tyle ile chcesz, apo tem wywoluj skrypt:
  1. <?php
  2.  
  3. $result = mssql_query(&#092;"SELECT * FROM MEMB_STAT WHERE ConnectStat=0 and memb__id=$idGoscia\");
  4. if ($result && mssql_num_rows($result)==1)
  5. {
  6.    //twój skrypt
  7. }
  8.  
  9. ?>


Ten post edytował nospor 10.05.2005, 12:14:09


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post
bok
post 10.05.2005, 12:35:35
Post #3





Grupa: Zarejestrowani
Postów: 52
Pomógł: 0
Dołączył: 8.05.2005

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


Teraz skrypt wygląda tak:
  1. <?php
  2.  
  3. $result = mssql_query(&#092;"SELECT * FROM MEMB_STAT WHERE ConnectStat=0 and memb___id='\".$_POST['login'].\"'\");
  4. if ($result && mssql_num_rows($result))
  5. {
  6.  
  7.  
  8. require 'config.php';
  9. $conn = mssql_connect(&#092;"$host\",\"$alogin\",\"$apass\"); 
  10. mssql_select_db('MuOnline', $conn); 
  11. $query_reset = mssql_query(&#092;"SELECT * FROM Character WHERE Name = '\".$_POST['name'].\"' AND AccountID = '\".$_POST['login'].\"'\"); 
  12. while($row_reset = mssql_fetch_array($query_reset)) 
  13. { 
  14. $resetcount = $row_reset['Reset']; 
  15. $resetplus = $resetcount + 1; 
  16. $value_points = 350 * $resetplus; 
  17. } 
  18. if (mssql_num_rows(mssql_query(&#092;"SELECT * FROM Character WHERE Name = '\".$_POST['name'].\"' AND AccountID = '\".$_POST['login'].\"'\")) > 0) { 
  19. $row = mssql_fetch_array(mssql_query(&#092;"SELECT * FROM Character WHERE Name = '\".$_POST['name'].\"' AND AccountID = '\".$_POST['login'].\"'\")); 
  20. if ($row['cLevel'] > '349') { 
  21. if ($row['Money'] > $money) { 
  22. $money_total = $row['Money'] - $money ; 
  23. $query = mssql_query(&#092;" 
  24. UPDATE Character SET cLevel = '1' WHERE Name = '\".$_POST['name'].\"' AND AccountID = '\".$_POST['login'].\"' 
  25. UPDATE Character SET Money = Money-50000000 WHERE Name = '\".$_POST['name'].\"' AND AccountID = '\".$_POST['login'].\"' 
  26. UPDATE Character SET Experience = '0' WHERE Name = '\".$_POST['name'].\"' AND AccountID = '\".$_POST['login'].\"' 
  27. UPDATE Character SET LevelUpPoint = Reset*200 WHERE Name = '\".$_POST['name'].\"' AND AccountID = '\".$_POST['login'].\"' 
  28. UPDATE Character SET Strength = '30' WHERE Name = '\".$_POST['name'].\"' AND AccountID = '\".$_POST['login'].\"' 
  29. UPDATE Character SET Dexterity = '30' WHERE Name = '\".$_POST['name'].\"' AND AccountID = '\".$_POST['login'].\"' 
  30. UPDATE Character SET Vitality = '30' WHERE Name = '\".$_POST['name'].\"' AND AccountID = '\".$_POST['login'].\"' 
  31. UPDATE Character SET Energy = '30' WHERE Name = '\".$_POST['name'].\"' AND AccountID = '\".$_POST['login'].\"' 
  32. UPDATE Character SET Reset = Reset+1 WHERE Name = '\".$_POST['name'].\"' AND AccountID = '\".$_POST['login'].\"'&#092;"); 
  33. if (!$query) { 
  34. echo &#092;"<font color='0099FF'><font size='2'>Character Reset could not be properly preformed. Database threw an error.\"; 
  35. } else { 
  36. echo &#092;"<font color='0099FF'><font size='2'>\".$_POST['name'].\" is successfully Reseted..\"; 
  37. } 
  38. } else { 
  39. echo &#092;"<font color='0099FF'><font size='2'>Character Reset could not be preformed. Not enough zen.\"; 
  40. echo &#092;"<br>Actual (\".$row['Money'].\") - Needed ($money)\"; 
  41. } 
  42. } else { 
  43. echo &#092;"<font color='0099FF'><font size='2'>Character Reset could not be preformed. Your not Level 350.\"; 
  44. } 
  45. } else { 
  46. echo &#092;"<font color='0099FF'><font size='2'>Character Reset could not be performed. Character \".$_POST['name'].\" or the Login given do not match.\"; 
  47. } 
  48.  
  49.  
  50. }
  51.  
  52. ?>


i wyswietla sie taki blad:


Warning: mssql_query() [function.mssql-query]: message: Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection. (severity 14) in c:\Appserv\www\nowe_konto_launcher\reset_postaci.php on line 2

Warning: mssql_query() [function.mssql-query]: Unable to connect to server: (null) in c:\Appserv\www\nowe_konto_launcher\reset_postaci.php on line 2

Warning: mssql_query() [function.mssql-query]: A link to the server could not be established in c:\Appserv\www\nowe_konto_launcher\reset_postaci.php on line 2
Go to the top of the page
+Quote Post
nospor
post 10.05.2005, 12:39:42
Post #4





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




o rajciu, ja ci podalem tylko zapytanie i rezutat jego wykonania. Ty musisz jeszcze polaczenia z bazą porobic i tym podobne. Trochę logiki


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post
bok
post 10.05.2005, 12:50:57
Post #5





Grupa: Zarejestrowani
Postów: 52
Pomógł: 0
Dołączył: 8.05.2005

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


Wielkie dzienki juz to naprawilem i dziala biggrin.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 Wersja Lo-Fi Aktualny czas: 17.06.2025 - 03:46