小编Joe*_*ssi的帖子

刷新时,停止$ _POST从具有相同的值

更改投票值后,表单将更改POST,然后刷新页面.这在加载时在页面顶部调用:

  if (isset($_POST['q'.$question_id]))
    {
    $user->updateQuestionVotes($question_id, $_POST['q'.$question_id]);
    }
Run Code Online (Sandbox Code Playgroud)

为什么每次我第一次刷新后都会更新?我需要以某种方式取消它吗?

php post

1
推荐指数
1
解决办法
354
查看次数

!is_null()无法按预期工作

dispatch_address_postcode

不是强制性的,即使它是空白的,它仍然会运行:

if (!is_null($_POST['personal_info_first_name']) && 
    !is_null($_POST['personal_info_surname']) && 
    !is_null($_POST['personal_info_email']) && 
    !is_null($_POST['personal_info_telephone']) && 
    !is_null($_POST['dispatch_address_country']) && 
    !is_null($_POST['dispatch_address_first_name']) &&
    !is_null($_POST['dispatch_address_surname']) && 
    !is_null($_POST['dispatch_address_address']) && 
    !is_null($_POST['dispatch_address_town']) && 
    !is_null($_POST['dispatch_address_postcode']) && 
    !is_null($_POST['dispatch_address_county']) && 
    (   ($_POST['payment_method'] == "Pay by credit card.") ||
        (
            ($_POST['payment_method'] == "Pay by new credit card.") && 
            !is_null($_POST['card_number']) && 
            !is_null($_POST['expiration_date']) && 
            !is_null($_POST['security_code'])
        )
    )
)
Run Code Online (Sandbox Code Playgroud)

是什么赋予了?

php post isnull

1
推荐指数
2
解决办法
6190
查看次数

Kohana 3在验证时抛出致命错误

试着在这里按照wiki上的示例:扩展模型Auth用户类,并且当它进行验证时我遇到致命错误.

ErrorException [ Fatal Error ]: Class 'Validate' not found
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?这是它失败的代码片段:

class Model_User extends Model_Auth_User
  {
    public function validate_create(& $array) 
    {
        // Initialise the validation library and setup some rules       
        $array = Validate::factory($array)
                        ->rules('password', $this->_rules['password'])
                        ->rules('username', $this->_rules['username'])
                        ->rules('email', $this->_rules['email'])
                        ->rules('password_confirm', $this->_rules['password_confirm'])
                        ->filter('username', 'trim')
Run Code Online (Sandbox Code Playgroud)

php validation kohana-3 kohana-auth

1
推荐指数
1
解决办法
1593
查看次数

使用PHP从mySQL表返回列名

无法想象我的生活.尝试从客户端证券表中返回列名,然后将结果作为数组返回.谁能指出我离开的地方?

mysql_select_db("HandlerProject", $con);        //Selects database
  $selectcols = "SELECT * FROM ".$clientname."securitiestable";     //selects all     columns from clients security table
  $tempcols = mysql_query($selectcols) or die(mysql_error());
  $returnedcols = $mysql_fetch_array($tempcols);
  $tempsymbol = mysql_query("SHOW COLUMNS FROM".$clientname."securitiestable");
  $symbol = $mysql_fetch_array($tempsymbol);
Run Code Online (Sandbox Code Playgroud)

php mysql arrays

0
推荐指数
1
解决办法
1826
查看次数

PHP准备好的声明:为什么这会抛出一个致命的错误?

不知道这里出了什么问题.继续投掷......

致命错误:在非对象上调用成员函数prepare()

......每次到达$select = $dbcon->prepare('SELECT * FROM tester1');零件.有人可以说明我做错了什么吗?

function selectall()            //returns array $client[][]. first brace indicates the row. second indicates the field
  {
  global $dbcon;

  $select = $dbcon->prepare('SELECT * FROM tester1');
  if ($select->execute(array()))
    {
    $query = $select->fetchall();

    $i = 0;

    foreach ($query as $row)
      {
      $client[$i][0] = $row['id'];
      $client[$i][1] = $row['name'];
      $client[$i][2] = $row['age'];
      $i++;
      }
    }
  return $client;
  } 
$client = selectall();
echo $client[0][0];
Run Code Online (Sandbox Code Playgroud)

php mysql pdo prepared-statement

0
推荐指数
1
解决办法
184
查看次数

使用$ .post进行简单的ajax测试,我错过了什么?

第一次玩jquery,我正在努力让一个简单的AJAX设置工作,这样我就能更好地理解它是如何工作的.不幸的是,我不知道很多.这是带脚本的HTML:

<html>
<head>
 <title>AJAX attempt with jQuery</title>
 <script type="text/javascript" src="jquery.js"></script>
 <script type="text/javascript">
   function ajax(str){
   $("document").ready(function(){
     $.post("ajaxjquerytest.php",str,function(){
       $("p").html(response);
       });
     });
 </script> 
</head>  
<body>
 <input type="text" onchange="ajax(this.value)"></input> 
 <p>Age?</p>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

这是它正在谈论的PHP:

<?php
$age = $_POST['age'];

if ($age < 30)
  {
  echo "Young";
  }
else if ($age > 30)
  {
  echo "Old";
  }
else
  {
  echo "you're 30";
  }
?>
Run Code Online (Sandbox Code Playgroud)

php ajax jquery

0
推荐指数
1
解决办法
377
查看次数

jQuery没有选择div类

试图做一个简单的切换菜单,我似乎无法使用这个jQuery隐藏/显示子菜单:

$(".topic news").mouseup(function(){
    $(".feed groups").hide("fast", function(){
      $(".feed messages").hide("fast");
      $("ul.feed news").toggle("fast");
    });
  });
Run Code Online (Sandbox Code Playgroud)

这是相应的HTML:

<div class="topic news">
  <span>News Feed</span>
 </div>
 <ul class="feed news">
  <li>News item #1</li>
  <li>News item #1</li>
  <li>News item #1</li>
  <li>News item #1</li>
  <li>News item #1</li>
 </ul>
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

html javascript css jquery

0
推荐指数
1
解决办法
569
查看次数

Cookie没有在PHP中设置

认为这非常简单,但我花了半个小时试图弄明白无济于事.

$unique_id = uniqid(microtime(),1);

if (is_null($_COOKIE['client_id']))
  {
  setcookie("client_id", $unique_id);
  }
Run Code Online (Sandbox Code Playgroud)

但是当我通过$ _COOKIE ['client_id']检查cookie时,我得到一个空值.有什么想法吗?

php cookies

0
推荐指数
1
解决办法
4765
查看次数