如何修复未定义的变量?

时间:2014-05-09 14:33:20

标签: php variables

我不断收到此通知:未定义的变量:此行代码第7行/var/www/html/ies.aacrao.org/apply/copies.php中的上一页:

if ($previouspage == "copies.php") {
    // _s2 variables are the shipping address for the included copy
    $first_s2 = $_SESSION['first_s2'] =  $_POST['first_s2'];
    $last_s2 = $_SESSION['last_s2'] =  $_POST['last_s2'];
    $email_s2 = $_SESSION['email_s2'] =  $_POST['email_s2'];
    $phone_s2 = $_SESSION['phone_s2'] =  $_POST['phone_s2'];
    $title_s2 = $_SESSION['title_s2'] =  $_POST['title_s2'];
    $office_s2 = $_SESSION['office_s2'] =  $_POST['office_s2']; 
    $institution_s2 = $_SESSION['institution_s2'] =  $_POST['institution_s2'];      
    }

任何人都可以给我一些关于如何解决这个问题的建议。所有这些变量都应该插入到数据库表中,并且目前它们没有被插入。

1 个答案:

答案 0 :(得分:0)

if(!empty($previouspage) && $previouspage == "copies.php")

if(isset($previouspage) && $previouspage == "copies.php")

我会选择!empty()

顺便说一句,看看这些功能。

空:http://tr2.php.net/empty

Isset:http://tr2.php.net/isset

快速解释:

清空检查变量是否已定义且具有值, isset只检查变量是否已定义。