如果条件给出错误消息

时间:2013-09-22 07:38:44

标签: php

下面提到的代码在5.3.17上工作正常,我有php 5.3.27,问题是我必须让这段代码在5.3.27上运行

链接到完整代码:http://www.videobluemoon.com/secure/add.txt

$customer_id = (int)$_REQUEST['customer_id'];

if($customer_id  => 0 ) {
           $query = $query.','.$_REQUEST['customer_id'];
   } else {
           die('cust id: '. $_REQUEST['customer_id']);
           die('Please use your browser\'s back button to ensure you have selected a customer');
   }

   if($customer_id => 0 ) {
           $query = $query.', '.$_REQUEST['sysuser_id'];
   else
           die ('There was a problem with the system user');

3 个答案:

答案 0 :(得分:6)

没有像=>

这样的东西

如果要检查大于等于使用>=

if ( $customer_id  >= 0 ){

且小于等于使用>= 并且==等于

检查此Comparison Operators ¶

答案 1 :(得分:1)

使用 == 代替 =>

=> 用于访问数组的键值对,而 == 用于比较操作。

<?php
$customer_id = (int)$_REQUEST['customer_id'];

if ( $customer_id  == 0 ){
$query = $query . ',' . $_REQUEST['customer_id'] . "";
}else{
die( 'cust id: ' . $_REQUEST['customer_id']);
die ( 'Please use your browser\'s back button to ensure you have selected a customer' );
}

if ( $customer_id  > 0 ){
$query = $query . ', ' . $_REQUEST['sysuser_id'] .  "";
}
else
{
die ( 'There was a problem with the system user' );
}

答案 2 :(得分:0)

=>它应该是>=,但您的代码看起来像

    $customer_id = (int)$_REQUEST['customer_id'];

        if ( $customer_id  == 0 ){
                   $query = $query . ',' . $_REQUEST['customer_id'] . "";
           }else{
                   die( 'cust id: ' . $_REQUEST['customer_id']);
                   die ( 'Please use your browser\'s back button to ensure you have selected a customer' );
           }

           if ( $customer_id  > 0 ){
                   $query = $query . ', ' . $_REQUEST['sysuser_id'] .  "";
           } else {
                   die ( 'There was a problem with the system user' );
           }