Jump to content

[SOLVED] help with unexpected T_CASE error


cs1h

Recommended Posts

Hi,

 

I have a script with a switch in it and its coming up with the error

 

Parse error: syntax error, unexpected T_CASE in /home/xxx/public_html/friend_accept.php on line 34

 

The script is,

 

<?php 

switch ($_GET["friends"]) 
{
case 'accept':

$username = $_COOKIE['loggedin'];
$code1 = $_GET["c1"];
$code2 = $_GET["c2"];

mysql_connect("localhost","xxx","xxx");
	mysql_select_db("xxx") or die("Unable to select database");

$sql = "SELECT * FROM xxx WHERE code1='$code1' AND code2='$code2' AND nameb='$username'";
$result = mysql_query($sql);
$num_rows = mysql_num_rows($result);
if($num_rows == 0) {
echo "aa";
} else {
while($row = mysql_fetch_array($result)) {
$name = $row['name']; 
$code1 = $row['code1'];
$code2 = $row['code2'];
$nameb1 = $row['nameb1'];
$codeb1 = $row['codeb1'];
$codeb2 = $row['codeb2'];

mysql_query($sql = "insert into `xxx` (`friendname`, `code1`, `code2`, `username`, `codeb1`, `codeb2`) values ('$name', '$code1', '$code2', '$nameb', '$codeb1', '$codeb2'), ('$nameb', '$codeb1', '$codeb2', '$name', '$code1', '$code2')");

$sql = "DELETE FROM xxx WHERE code1='$code1' AND code2='$code2' AND nameb='$username'";
}
break;

case 'deny':

$username = $_COOKIE['loggedin'];
$code1 = $_GET["c1"];
$code2 = $_GET["c2"];

mysql_connect("localhost","xxx","xxx");
	mysql_select_db("xxx") or die("Unable to select database");

$sql = "DELETE FROM xxx WHERE code1='$code1' AND code2='$code2' AND nameb='$username'";

break;

default:
echo "";
}


?>

<?php 

$username = $_COOKIE['loggedin'];

$db=mysql_connect("localhost","xxx","xxx");
mysql_select_db("xxx") or die("Unable to select database");
$result=mysql_query("SELECT Code_1,Code_2 FROM xxx WHERE username='$username'") or "ERROR: ".mysql_error();

if(!$result || strstr($result, "ERROR: "))
{
$sw=0;$error="No results";
}
else
{
$sw=1;
$row=mysql_fetch_array($result);
$code1=$row["Code_1"];
$code2=$row["Code_2"];
mysql_close($db);
$db=mysql_connect("localhost","xxx","xxx");
mysql_select_db("xxx") or die("Unable to select database");
$result=mysql_query("SELECT name,code1,code2 FROM `xxx` WHERE codeb1='$code1' AND codeb2='$code2' ORDER BY id") or "ERROR: ".mysql_error();
if(!$result || strstr($result, "ERROR: ")){
	$sw=0;
	$error="You have no friend requests at the moment";
}
else
	{
	$sw=1;
	$asker=array();
	$asker_code1=array();
	$asker_code2=array();
	while($row=mysql_fetch_array($result))
	{
		$asker[]=$row["name"];
		$asker_code1[]=$row["code1"];
		$asker_code2[]=$row["code2"];
	}
	mysql_close($db);
	  $db=mysql_connect("localhost","xxx","xxx");
  mysql_select_db("xxx") or die("Unable to select database");
	for($i=0;$i<count($asker);$i++)
	{
		$result=mysql_query("SELECT avatar,name1 FROM xxx WHERE username='".$asker[$i]."'")or "ERROR: ".mysql_error();
		if(!$result || strstr($result, "ERROR: ")){
			$sw=0;
			$error="No results 2</a>.";
		}
		else
		{
		$sw=1;
		$row=mysql_fetch_array($result);
		print "<div id='comment'>
		<img src='/avatar/".$row["avatar"]."' width='56' height='56' class='comment_photo' />
		<div id='comment_header'><span class='comment_author'> ".$row["name1"]." </span><span class='comment_wrote'>wants to be friends</span><span class='comment_stars'></span></div>
		<div class='comment_text'></div>
		<div id='comment_footer'><span class='comment_delete'><a href='ssi_css_my_profile.php?c1={$asker_code1[$i]}&c2={$asker_code2[$i]}'>View Profile</a> | <a href='friend_accepter.php?c1={$asker_code1[$i]}&c2={$asker_code2[$i]}&friends=accept'>Accept</a> | <a href='friend_deny.php?c1={$asker_code1[$i]}&c2={$asker_code2[$i]}&friends=deny'>Deny</a></span></div>
		</div>";
		}
	}
}
}
if($sw==0){
echo $error;
}
if($db){
mysql_close($db);
}
?>

 

Does anyone know what the problem is?

 

All help is very much appreciated.

 

Thanks,

COlin

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.