2016-03-21 71 views
-5

我想从http://mywebsite1.com/register.php?log=firstname=Yoga&lastname=Galih

收集信息,但我想这些信息对我的使用PHP $ _GET第二的网站,并把它保存到reg.log

<?php 
$txt = "reg.log"; 
if (isset($_GET["log"]) && isset($_GET["firstname"]) && isset($_GET["lastname"]) && isset($_GET["address"]) && isset($_GET["city"]) && isset($_GET["state"]) && isset($_GET["zip"]) && isset($_GET["country"]) && isset($_GET["phone"]) $$ isset($_GET["gender"]) && isset($_GET["haircolor"]) && isset($_GET["eyecolor"]) && isset($_GET["high"]) isset($_GET["weight"])) { 
    $firstname = $_GET["fname"]; 
    $lastname = $_GET["lname"]; 
    $address = $_GET["address"]; 
    $city = $_GET["city"]; 
    $state = $_GET["state"]; 
    $zip = $_GET["zip"]; 
    $country = $_GET["country"]; 
    $gender = $_GET["gender"]; 
    $haircolor = $_GET["hcolor"]; 
    $eyecolor = $_GET["ecolor"]; 
    $high = $_GET["high"]; 
    $weight = $_GET["weight"]; 
    $phone = $_GET["phone"]; 
    echo $firstname .PHP_EOL. $lastname .PHP_EOL. $address .PHP_EOL. $city .PHP_EOL. $state .PHP_EOL. $zip .PHP_EOL. $country .PHP_EOL. $phone .PHP_EOL. $hcolor .PHP_EOL. $ecolor .PHP_EOL. $high .PHP_EOL. weigh .PHP_EOL. gender; 
    $fh = fopen($txt, 'a'); 
fwrite($fh,$txt); // Write information to the file 
fclose($fh); // Close the fil 
} 
?> 

,但我得到的错误[ 3月21日-2016 15时17分09秒美国/纽约] PHP解析错误:语法错误,意想不到的 '$' 在/home/my2ndweb/public_html/includes/register.php上线3

我需要帮助

谢谢

+1

在isset之前忘了&&($ _ GET [“weight”] – frosty

+1

将它们全部放在一个'isset'中。 http://php.net/manual/en/function.isset.php'如果提供了多个参数,则只有在设置了所有参数的情况下,isset()才会返回TRUE。评估从左到右,遇到未设置的变量时立即停止。“# – chris85

+0

**语法错误:**使用适当的IDE,如Netbeans或PHPStorm – CodeGodie

回答

3

哇问题是很长的。我不是一个坚持80个字符的人,但那是不可读的。

问题是在第3行,您有$$而不是&&。您也在线附近错过了另一个&&

3

第3行:

$$ isset($_GET["gender"]) 

应该是:

&& isset($_GET["gender"]) 

也在到底应该是

&& isset($_GET["weight"]) 

看起来你也会有你的回音问题因为你调用的变量不存在,即$ ecolor应该是$ eyecolor,因为这是你的变量名称

+0

他也忘了在isset之前加上&&($ _ GET [“weight”] – frosty

+0

是的,刚看到那个,长长的一行去看 –

0

线应"&&isset($_GET["gender"])"上线3

+0

怎么做它简单吗? –

-2

您需要& & isset来代替双$$($ _ GET [ “性别”]),你忘了& & isset之前($ _GET [“weight”]

+0

但reg.log仍然empaty –