Jump to content

Parse error 2


3raser

Recommended Posts

I'm just laughing at my dumbness......I seriously just need to stop working with PHP. I KEEP GETTING THESE PARSE ERRORS EVERYTIME I DO SOMETHING?!

 

Parse error: parse error in C:\wamp\www\project11\join.php on line 32

 

<?php
session_start();
$session = $_SESSION['user'];

$mysql_host = "localhost";
$mysql_username = "root";
$mysql_password = "";
$mysql_database = "project11";

mysql_connect($mysql_host, $mysql_username, $mysql_password);
mysql_select_db($mysql_database);

$id = $_GET['id'];

   if(!$id) {
     echo "You must select a clan to join first! <a href='index.php'>Home</a>";
   } else {
     $extract = mysql_query("SELECT clan FROM users WHERE username='$session'");
 while ($row = mysql_fetch_assoc($extract)) {
      $exist = $row['clan'];
   }
   
   if (!$clan) {
  
   if($does_it_exist = mysql_query("SELECT clan_name FROM clans WHERE clan='$id'")) {
     $check = mysql_num_rows($does_it_exist);
	  if(!$check) {
	    echo "Sorry, but no clan exists with the ID code of ". $id ."! <a href='index.php'>Home</a>";
	  } else {
	  mysql_query("INSERT INTO requests VALUES ('', '$session', '$id')");
	  echo "Your request has been sent to the clan leader. Please wait for it to be approved!";
   } else {
     echo "Sorry, an error occured.";
   } else {
    echo "Sorry, your already in a clan! <a href='index.php'>Home</a>";
   }
   }

?>

Link to comment
https://forums.phpfreaks.com/topic/205001-parse-error-2/
Share on other sites

Fixed a few of the brackets.

 

<?php
session_start();
$session = $_SESSION['user'];

$mysql_host = "localhost";
$mysql_username = "root";
$mysql_password = "";
$mysql_database = "project11";

mysql_connect($mysql_host, $mysql_username, $mysql_password);
mysql_select_db($mysql_database);

$id = $_GET['id'];

   if(!$id) {
     echo "You must select a clan to join first! <a href='index.php'>Home</a>";
   } else {
     $extract = mysql_query("SELECT clan FROM users WHERE username='$session'");
 while ($row = mysql_fetch_assoc($extract)) {
      $exist = $row['clan'];
   }
   
   if (!$clan) {
  
   if($does_it_exist = mysql_query("SELECT clan_name FROM clans WHERE clan='$id'")) {
     $check = mysql_num_rows($does_it_exist);
	  if(!$check) {
	    echo "Sorry, but no clan exists with the ID code of ". $id ."! <a href='index.php'>Home</a>";
	  } else {
	  mysql_query("INSERT INTO requests VALUES ('', '$session', '$id')");
	  echo "Your request has been sent to the clan leader. Please wait for it to be approved!";
   } else {
     echo "Sorry, an error occured.";
   } else {
    echo "Sorry, your already in a clan! <a href='index.php'>Home</a>";
   }
   }
   }
   }
?>

 

But still get

 

Parse error: parse error in C:\wamp\www\project11\join.php on line 32

Link to comment
https://forums.phpfreaks.com/topic/205001-parse-error-2/#findComment-1073227
Share on other sites

I don't see how you fixed anything. 

 

You need to make sure that when you do if - else that you end the block.

 



if ()  {
} else {
}

 

You can't have:

 

if () {
} else {
} else {

 

You can have elseif or else if ().

 

http://www.php.net/elseif

Link to comment
https://forums.phpfreaks.com/topic/205001-parse-error-2/#findComment-1073228
Share on other sites

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.