Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Błąd w kodzie (konstrukcja if).
kiepski96
post
Post #1





Grupa: Zarejestrowani
Postów: 233
Pomógł: 0
Dołączył: 22.02.2010

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


Witam, mam kod i coś nie działa (IMG:style_emoticons/default/biggrin.gif)
Mógłbym prosić o poprawę albo chociaż podpowiedzi ?

  1. <?php
  2. $unlock1 = true;
  3. $unlock2 = true;
  4. $name = "Test skryptu Heheszki.pl";
  5. $url = "http://4rapiddev.com/facebook-graph-api/facebook-publish-to-wall-with-popup-or-dialog-and-call-back/";
  6. $obrazek = "http://4rapiddev.com/wp-content/uploads/2011/09/Example-Publish-To-Wall-With-Popup-Windows.jpg";
  7. $opis = "I have experienced with Share On Wall with Popup windows and would like to share with you. Check it now.";
  8.  
  9. if $unlock1 = true and unlock2 = true
  10. echo "Witaj Świecie";
  11. // Drukujemy początek skryptu
  12. print "<script type='text/javascript'><!--\n";
  13. print "FB.init({\n";
  14. print "appId:'XXX',\n";
  15. print "status : true,\n";
  16. print "cookie : true,\n";
  17. print "xfbml : true\n";
  18. print "});\n";
  19. print "</script>\n";
  20. print "<script type='text/javascript'>\n";
  21. // skrypt łączenia share
  22. print "window.fbAsyncInit = function() {\n";
  23. print "FB.init({\n";
  24. print "appId:'XXX',\n";
  25. print "status : true,\n";
  26. print "cookie : true,\n";
  27. print "xfbml : true\n";
  28. print "});\n";
  29. print "};\n";
  30. print "</script>\n";
  31. print "<script type='text/javascript'>\n";
  32. print "$(document).ready(function(){\n";
  33. print "FB.getLoginStatus(function(response) {\n";
  34. print "if (response.status == 'connected') {\n";
  35. print "var user_id = response.authResponse.userID;\n";
  36. print "var page_id = 'XXX';\n";
  37. print "var fql_query = 'SELECT uid FROM page_fan WHERE page_id =' + page_id + ' and uid=' + user_id;\n";
  38. print "var the_query = FB.Data.query(fql_query);\n";
  39. print "the_query.wait(function(rows) {\n";
  40. print "if (rows.length == 1 && rows[0].uid == user_id) {\n";
  41. print "$unlock1\n";
  42. print "} else {\n";
  43. print "$('#blokada').show();\n";
  44. print "}\n";
  45. print "});\n";
  46. print "} else {\n";
  47. print "}\n";
  48. print "});\n";
  49. print "});\n";
  50. print "</script>\n";
  51. print "<script type='text/javascript'>\n";
  52. print "function streampublish_popup(){\n";
  53. print "FB.ui(\n";
  54. print "{\n";
  55. print "method: 'stream.publish',\n";
  56. print "attachment: {\n";
  57. print "name: '$name',\n";
  58. print "description: ('$opis'\n";
  59. print "),\n";
  60. print "href:'$url'\n";
  61. print "media: [\n";
  62. print "{\n";
  63. print "'type':'image',\n";
  64. print "'src':'$obrazek',\n";
  65. print "'href':'$url'\n";
  66. print "}\n";
  67. print "]\n";
  68. print "},\n";
  69. print "display: 'popup'\n";
  70. print "},\n";
  71. print "function(response) {\n";
  72. print "if (response && response.post_id) {\n";
  73. print "$unlock2\n";
  74. print "} else {\n";
  75. print "$('#blokada').show();\n";;
  76. print "}\n";
  77. print "});\n";
  78. print "}\n";
  79. print "</script>\n";
  80. ?>


Ten post edytował kiepski96 6.06.2012, 18:54:37
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
IProSoft
post
Post #2





Grupa: Zarejestrowani
Postów: 479
Pomógł: 97
Dołączył: 6.09.2011
Skąd: php.net :)

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


Nie sprawdzałem działania, poprawiłem Ci tylko formę abyś nie tworzył czegoś takiego jak linia print poganiający printa, poza tym masz problem z kodowaniem.
Wklej i sprawdź, nie czekaj na gotowce i opisuje błędy jeśli takie się pojawiają.
  1. <?php
  2. $unlock1 = true;
  3. $unlock2 = true;
  4. $name = "Test skryptu Heheszki.pl";
  5. $url = "http://4rapiddev.com/facebook-graph-api/facebook-publish-to-wall-with-popup-or-dialog-and-call-back/";
  6. $obrazek = "http://4rapiddev.com/wp-content/uploads/2011/09/Example-Publish-To-Wall-With-Popup-Windows.jpg";
  7. $opis = "I have experienced with Share On Wall with Popup windows and would like to share with you. Check it now.";
  8.  
  9. echo "Witaj Świecie";
  10. // Drukujemy początek skryptu
  11. echo "<script type='text/javascript'>
  12. FB.init({
  13. appId:'XXX',
  14. status : true,
  15. cookie : true,
  16. xfbml : true
  17. });
  18. </script>
  19. <script type='text/javascript'>
  20. // skrypt łączenia share
  21. window.fbAsyncInit = function() {
  22. FB.init({
  23. appId:'XXX',
  24. status : true,
  25. cookie : true,
  26. xfbml : true
  27. });
  28. };
  29. </script>
  30. <script type='text/javascript'>
  31. $(document).ready(function(){
  32. FB.getLoginStatus(function(response) {
  33. if (response.status == 'connected') {
  34. var user_id = response.authResponse.userID;
  35. var page_id = 'XXX';
  36. var fql_query = 'SELECT uid FROM page_fan WHERE page_id =' + page_id + ' and uid=' + user_id;
  37. var the_query = FB.Data.query(fql_query);
  38. the_query.wait(function(rows) {
  39. if (rows.length == 1 && rows[0].uid == user_id) {
  40. $unlock1
  41. } else {
  42. $('#blokada').show();
  43. }
  44. });
  45. } else {
  46. }
  47. });
  48. });
  49. </script>
  50. <script type='text/javascript'>
  51. function streampublish_popup(){
  52. FB.ui({
  53. method: 'stream.publish',
  54. attachment: {
  55. name: '$name',
  56. description: ('$opis'),
  57. href:'$url'
  58. media: [{
  59. 'type':'image',
  60. 'src':'$obrazek',
  61. 'href':'$url'}
  62. ]
  63. },
  64. display: 'popup'
  65. },
  66. function(response) {
  67. if (response && response.post_id) {
  68. $unlock2
  69. } else {
  70. $('#blokada').show();;
  71. }
  72. });
  73. }
  74. </script>";
  75. ?>
Go to the top of the page
+Quote Post
kiepski96
post
Post #3





Grupa: Zarejestrowani
Postów: 233
Pomógł: 0
Dołączył: 22.02.2010

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


Cytat(IProSoft @ 6.06.2012, 00:43:20 ) *
Nie sprawdzałem działania, poprawiłem Ci tylko formę abyś nie tworzył czegoś takiego jak linia print poganiający printa, poza tym masz problem z kodowaniem.
Wklej i sprawdź, nie czekaj na gotowce i opisuje błędy jeśli takie się pojawiają.
  1. <?php
  2. $unlock1 = true;
  3. $unlock2 = true;
  4. $name = "Test skryptu Heheszki.pl";
  5. $url = "http://4rapiddev.com/facebook-graph-api/facebook-publish-to-wall-with-popup-or-dialog-and-call-back/";
  6. $obrazek = "http://4rapiddev.com/wp-content/uploads/2011/09/Example-Publish-To-Wall-With-Popup-Windows.jpg";
  7. $opis = "I have experienced with Share On Wall with Popup windows and would like to share with you. Check it now.";
  8.  
  9. echo "Witaj ?wiecie";
  10. // Drukujemy początek skryptu
  11. echo "<script type='text/javascript'>
  12. FB.init({
  13. appId:'XXX',
  14. status : true,
  15. cookie : true,
  16. xfbml : true
  17. });
  18. </script>
  19. <script type='text/javascript'>
  20. // skrypt łączenia share
  21. window.fbAsyncInit = function() {
  22. FB.init({
  23. appId:'XXX',
  24. status : true,
  25. cookie : true,
  26. xfbml : true
  27. });
  28. };
  29. </script>
  30. <script type='text/javascript'>
  31. $(document).ready(function(){
  32. FB.getLoginStatus(function(response) {
  33. if (response.status == 'connected') {
  34. var user_id = response.authResponse.userID;
  35. var page_id = 'XXX';
  36. var fql_query = 'SELECT uid FROM page_fan WHERE page_id =' + page_id + ' and uid=' + user_id;
  37. var the_query = FB.Data.query(fql_query);
  38. the_query.wait(function(rows) {
  39. if (rows.length == 1 && rows[0].uid == user_id) {
  40. $unlock1
  41. } else {
  42. $('#blokada').show();
  43. }
  44. });
  45. } else {
  46. }
  47. });
  48. });
  49. </script>
  50. <script type='text/javascript'>
  51. function streampublish_popup(){
  52. FB.ui({
  53. method: 'stream.publish',
  54. attachment: {
  55. name: '$name',
  56. description: ('$opis'),
  57. href:'$url'
  58. media: [{
  59. 'type':'image',
  60. 'src':'$obrazek',
  61. 'href':'$url'}
  62. ]
  63. },
  64. display: 'popup'
  65. },
  66. function(response) {
  67. if (response && response.post_id) {
  68. $unlock2
  69. } else {
  70. $('#blokada').show();;
  71. }
  72. });
  73. }
  74. </script>";
  75. ?>



Chodzi mi o to, że jeśli użytkownik wykona warunki skryptu 1 w js i skryptu 2 w js to wtedy wywali echo "witaj świecie".
Niestety na tąchwilę w tym skrypcie witaj świecie jest cały czs, nawet jeśli nie wykonają warunków (IMG:style_emoticons/default/sad.gif)
Jb co to usunąłem pytajniki i /// koło echo (IMG:style_emoticons/default/smile.gif)

Drugą sprawą jest to, że chyba nie mogę dać tak:
Kod
if (rows.length == 1 && rows[0].uid == user_id) {
                    $unlock1


Chyba muszę na razie dać zmienną w js, a potem zdefiniować, że var zmiennajs = $zmiennaphp
Czy mam rację?

Wtedy wyglądałoby to tak:

Kod
if (rows.length == 1 && rows[0].uid == user_id) {
                    var unlock1 }
$unlock1= var unlock1


Ten post edytował kiepski96 6.06.2012, 19:06:23
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: 15.10.2025 - 07:24