Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Nie wiem co jest źle z tym skryptem
VanPersie
post 5.01.2008, 21:39:04
Post #1





Grupa: Zarejestrowani
Postów: 14
Pomógł: 0
Dołączył: 3.07.2006

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


Skrypt nie pobiera ID z bazy danych jesli nie został podany w QueryString

  1. <?
  2.  
  3. If (isset ( $_GET['myid'] ))
  4. {
  5. $_SESSION['myid']=$_GET['myid'];
  6. $selected_id=$myid;
  7. $_SESSION['myname']=$_GET['myname'];
  8. $name_id=$myname;
  9. }
  10. else
  11. {
  12.  
  13. if (isset($_SESSION['myid']))
  14. {
  15. $selected_id=$myid;
  16. $name_id=$myname;
  17. }
  18. else
  19. {
  20. require('admin/config.php');
  21. require('admin/mysql.php');
  22.  
  23. $db = new sql_db();
  24. $db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname);
  25.  
  26. // sprawdzenie czy kazdy id osiagnal limit wyswietlen
  27. $sql = 'SELECT count(*) as ile FROM user_links WHERE max - act > 0';
  28. $result = $db->sql_query($sql);
  29. $row = $db->sql_fetchrow($result);
  30. if($row['ile'] == 0)
  31. {
  32. //wyzerowanie licznikow
  33. $sql = 'UPDATE user_links SET act = 0';
  34. $db->sql_query($sql);
  35. }
  36.  
  37. //losowy wybor identyfikatora
  38. $sql = 'SELECT * FROM user_links WHERE max - act > 0 ORDER BY RAND() LIMIT 0,1';
  39. $result = $db->sql_query($sql);
  40. $row = $db->sql_fetchrow($result);
  41. $selected_id = $row['user_id'];
  42. $name_id = $row['name'];
  43.  
  44. //aktualizacja licznika wyswietlen dla tego identyfikatora
  45. $sql = 'UPDATE user_links SET act = act + 1, total = total + 1 WHERE id = '.$row['id'];
  46. $db->sql_query($sql);; 
  47. $myid=$selected_id;
  48. $myname=$name_id;
  49. $_SESSION['arch_myid'] = $myid;
  50. session_register("myname");
  51. $_SESSION['arch_name'] = $myname;
  52. }
  53. }
  54.  
  55.  
  56. if( isset( $_GET['myid'] ) )
  57. {
  58. $_SESSION['arch_myid'] = $_GET['myid'];
  59. }
  60. else
  61. {
  62. $_GET['name_id'] = $_SESSION['arch_myid'];
  63. }
  64. if( isset( $_GET['name_id'] ) )
  65. {
  66. $_SESSION['arch_name'] = $_GET['name_id'];
  67. }
  68. else
  69. {
  70. $_GET['name_id'] = $_SESSION['arch_name'];
  71. }
  72.  
  73. ?>
Go to the top of the page
+Quote Post
aiv
post 5.01.2008, 21:50:29
Post #2





Grupa: Zarejestrowani
Postów: 93
Pomógł: 13
Dołączył: 7.09.2006

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


Nie za bardzo rozumiem jak to ma działać ale może początek powinien wyglądać tak:
  1. <?
  2.  
  3. if (isset ($_GET['myid'])) {
  4. $_SESSION['myid'] = $_GET['myid'];
  5. $selected_id = $_GET['myid'];
  6. $_SESSION['myname'] = $_GET['myname'];
  7. $name_id = $_GET['myname'];
  8. } else {
  9. if (isset($_SESSION['myid'])) {
  10. $selected_id=$_SESSION['myid'];
  11. $name_id=$_SESSION['myname'];
  12. } else {
  13. ?>


--------------------
Mariusz Dalewski
Aiv's dev blog
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: 18.07.2025 - 01:38