2014-01-14 69 views
-3
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 

//code for counties in my Registration page  
<?php 

function is_valid_state($county) { 
    $validCounties = array ("Avon","Bedfordshire","Berkshire","Borders","Buckinghamshire","Cambridgeshire","Central","Cheshire","Cleveland","Clwyd","Cornwall","County Antrim","County Armagh","County Down","County Fermanagh","County Londonderry","County Tyrone","Cumbria","Derbyshire","Devon","Dorset","Dumfries and Galloway","Durham","Dyfed","East Sussex","Essex","Fife","Gloucestershire","Grampian","Greater Manchester","Gwent","Gwynedd County","Hampshire","Herefordshire","Hertfordshire","Highlands and Islands","Humberside","Isle of Wight","Kent","Lancashire","Leicestershire","Lincolnshire","Lothian","Merseyside","Mid Glamorgan","Norfolk","North Yorkshire","Northamptonshire","Northumberland","Nottinghamshire","Oxfordshire","Powys","Rutland","Shropshire","Somerset","South Glamorgan","South Yorkshire","Staffordshire","Strathclyde","Suffolk","Surrey","Teesside","Tyne and Wear","Warwickshire","West Glamorgan","West Midlands","West Sussex","West Yorkshire","Wiltshire","Worcestershire",); 
    if (in_array($county,$validCounties)) { 
      return true; 
    } else { 
      return false; 
    } 
} //end function is_valid_county 

// Dreamweaver suggests that the error lies in here? I have been trying for the last few hours to try and locate it to no avail and I would really appreciate some help 

function is_valid_postcode($postcode) { 
     if (preg_match('/^[\d]+$/',$postcode)) { 
       return true; 
     } else is (strlen($postcode) == 5 || strlen($postcode) == 9) { 
       return true; 
     } else { 
       return false; 
     } 
} //end function is_valid_postcode 

?> 

<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
<title>Untitled Document</title> 
</head> 

<body> 
</body> 
</html> 
+0

它只是一个错字。 'else is' – Raptor

+0

如果你没有看DW(只是放弃它,并使用一些体面的PHP IDE) - 但运行你的代码 - 你会确切知道什么是错的 – zerkms

回答

1

误差应else if

.. 
} else is (strlen($postcode) == 5 || strlen($postcode) == 9) { 
1

这是else if误差不else is

这里这里else is

} else is (strlen($postcode) == 5 || strlen($postcode) == 9) { 
-------^^ // Replace that to if 
相关问题