邮件脚本 - 解析错误:语法错误,意外'=' [英] Mail Script - Parse error: syntax error, unexpected '='
问题描述
我试图从包含下拉列表的html表单中设置一个简单的邮件脚本,但在我声明所选变量的行上,我收到了一条错误消息:
解析错误:语法错误,意外的' ='........
I am trying to setup a simple mail script from an html form that includes a dropdown list but on the line where I declare the selected variable I am getting an error message: Parse error: syntax error, unexpected '='........
我的html表单包含如下的下拉列表:
My html form includes the dropdown list as follows:
<select name="buying-selling" id="buying-selling">
<option value="none_selected" selected="selected">Please Select</option>
<option value="buying_property">Buying a Property</option>
<option value="selling_property">Selling a Property</option>
<option value="sales_updates">Sales Updates</option>
</select>
在我的电子邮件脚本的顶部,我有:
And at the top of my email script I have:
<?php
if ($_POST['Submit']!="")
{
$name=$_POST['name'];
$emailaddr=$_POST['emailaddr'];
$buying-selling=$_POST['buying-selling'];
$message=$_POST['message'];
.......紧跟所有邮件头数据
.......followed by all the mailheaders data
但是当我尝试处理表单时,我得到了包含POST ['buying-selling']元素的行的Parse error:syntax error,unexpected'='。
But when I try and process the form I am getting the "Parse error: syntax error, unexpected '='" for the line that contains the POST['buying-selling'] element.
是否有不同的语法用于从下拉列表中声明项目?
Is there a different syntax for declaring items from a dropdown list?
我是编写邮件脚本的新手,建议将非常受欢迎。
I am new to coding for mail scripts so any advice would be very welcome.
非常感谢
Many thanks
推荐答案
$买入卖出
不是有效的变量名称。试试 $ buying_selling
。
$buying-selling
is not a valid variable name. Try $buying_selling
instead.
这篇关于邮件脚本 - 解析错误:语法错误,意外'='的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!