Warning: Cannot use a scalar value as an array in /home/admin/public_html/forum/include/fm.class.php on line 757

Warning: Invalid argument supplied for foreach() in /home/admin/public_html/forum/include/fm.class.php on line 770
Форумы портала PHP.SU :: Версия для печати :: Мистика, не работает
Форумы портала PHP.SU » » Вопросы новичков » Мистика, не работает

Страниц (1): [1]
 

1. event - 06 Февраля, 2012 - 15:45:37 - перейти к сообщению
Привет.
Есть такой код:
PHP:
скопировать код в буфер обмена
  1. elseif ($action == 'saveeditnew') {
  2.  
  3. $id = (int)$_GET['id'];
  4.  
  5. $subject = htmlspecialchars(unesc($_POST["subject"]));
  6. $text = htmlspecialchars(unesc($_POST['text']));
  7.  
  8. if (!$subject){
  9. bark("You did not enter a title, please <a href=\"javascript:history.go(-1);\">go back</a>...");
  10. }
  11.  
  12. if (!$text){
  13. bark("You have not entered (the message), please <a href=\"javascript:history.go(-1);\">go back</a>...");
  14. }
  15.  
  16. if (strlen($subject) < 3){
  17. bark("The title should be prepared with 3 characters or more, please <a href=\"javascript:history.go(-1);\">go back</a>...");
  18. }
  19.  
  20. if (strlen($text) < 50){
  21. bark("The text (message) must be drawn up with 50 characters or more, please <a href=\"javascript:history.go(-1);\">go back</a>...");
  22. }
  23.  
  24. if (strlen($subject) > 150){
  25. bark("The title has a lot of characters, the maximum allowed 150 characters, please <a href=\"javascript:history.go(-1);\">go back</a>...");
  26. }
  27.  
  28. if (strlen($text) > 5000){
  29. bark("The text (message) has so many characters, the maximum allowed 5000 characters, please <a href=\"javascript:history.go(-1);\">go back</a>...");
  30. }
  31.  
  32. $updateset[] = "subject = " . sqlesc($subject);
  33. $updateset[] = "body = " . sqlesc($text);
  34.  
  35. $result = sql_query("UPDATE news SET " . implode(",", $updateset) . " WHERE id = " . $id) or sqlerr(__FILE__,__LINE__);
  36.  
  37. if ($result){
  38. stdhead("The process of saving the edited data"); begin_frame("The process of saving the edited data"); stdmsg("Successfully","Your news has been successfully added, now you will be redirected to the page with your news... <META HTTP-EQUIV='refresh' CONTENT='2; url=?action=details&id=".$id."'>"); end_frame(); stdfoot();
  39. }else{
  40. stdhead("The process of saving the edited data"); begin_frame("The process of saving the edited data"); stdmsg("Error", "An unknown error occurred...", "error"); end_frame(); stdfoot();
  41.  
  42.      }
  43.  
  44.   }


Как видите, пере адресация делается через <META>, ну вот она делается, но меня перенаправляет на ?action=details&id=0, а почему там 0, я же вставляю туда айдишник через переменную $id, где мой косяк что править?
2. EuGen - 06 Февраля, 2012 - 15:55:13 - перейти к сообщению
var_dump($id, $_GET);

http://phpfaq[dot]ru/debug
3. event - 06 Февраля, 2012 - 16:07:00 - перейти к сообщению
EuGen не, там все четко int(0) array(1) { ["action"]=> string(11) "saveeditnew" }
4. Panoptik - 06 Февраля, 2012 - 16:21:06 - перейти к сообщению
и что же четко если вы достаете значение

а оно к вам не приходит вообще?
5. EuGen - 06 Февраля, 2012 - 16:23:17 - перейти к сообщению
event пишет:
int(0) array(1) { ["action"]=> string(11) "saveeditnew" }

Ну так какие еще вопросы? Первый дамп сообщает о том, что (int)$_GET['id'] есть 0, а второй сообщает причину, по которой это так - а именно то, что ключа id вообще не пришло в $_GET

 

Powered by ExBB FM 1.0 RC1