Question:
Whats wrong with this PHP switch case script?
peter s
2006-11-03 16:26:29 UTC
The problem always seems to come back to this switch statement. Can you see anything wrong with it? all the other cases work in the switch statement i don't understand what the problem is. This is what happens:

Parse error: parse error, unexpected T_VARIABLE in /home/content/Update.php on line 71


case "Contact Seller":
if (!ereg("^[a-zA-Z0-9 :;%*()£$^!]{6,255}$",$_POST['MESSAGE']))
{
$message = "ERROR only text and numbers allowed. Must be between 6 and 20 characters in length";
include("Contact Seller.inc");
exit();
}
else
{

$connection = mysql_connect($host,$user,$password)
or die ("couldnt connect to server");
$db = mysql_select_db($database, $connection)
or die ("couldnt slect database");
$query = "UPDATE traffic1 SET INBOX=\"" . $_POST['MESSAGE'] . "\",SUBJECT=\"" . $_POST['SUBJECT'] . "\"
WHERE SITENAME=\"" . $_GET['account'] . "\"";
$result = mysql_query($query)
$message = "Message Sent";
include("Contact Seller");
break;

Please help, thanx
Three answers:
Ken H
2006-11-03 18:10:23 UTC
I don't see a switch statement in there, and you don't tell us which line is 71 in your program.



I see a couple of problems if you pasted that exactly. The first line in your else clause is missing a closing ')', and there is no closing brace at the end.



When asking for help, it's polite to try to reduce the problem to the fewest possible lines that exhibit the problem, so those trying to help don't have to try to understand the whole thing.
?
2016-10-21 09:32:28 UTC
The final ) yet in addition, a guideline for improving your code. evaluate shifting any duplicated code exterior of the change fact, it may shrink the dimensions of your application. eg.
sekutor4
2006-11-04 11:19:12 UTC
$result = mysql_query($query); you forgot the ';' at the end of the line ;)


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...