Web Analytics Made Easy -
StatCounter Can't seem to find the last curly brace? help, please - CodingForum

Announcement

Collapse
No announcement yet.

Can't seem to find the last curly brace? help, please

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Can't seem to find the last curly brace? help, please

    I keep getting an error that saysParse error: syntax error, unexpected T_ENDIF in nbc_uploader.php on line 46

    I have looked at this code repeatedly and I can't find where I'm missing something.

    Code:
    <?php
    /********************************************************
    ***This file is for uploading games
    ***Author: Stuart Altschuler
    ***Created: September 5, 2011
    ********************************************************/
    
    include "inc_dbcnx.php";
    /*include "inc_header.php";*/
    
    if ($_FILES['uploadedfile'] !="") {
    	$fileName = $_FILES['uploadedfile']['name'];
    	if((strlen($fileName) == 11) || (strlen($fileName) == 12)) {
    	$year  = substr($fileName,0,2);
    	$month = substr($fileName,2,2);
    	$day   = substr($fileName,4,2);
    	$start_date = "20";
    	$start_date .= $year;
    	$start_date .="-";
    	$start_date .= $month;
    	$start_date .="-";
    	$start_date .= $day;
    	
    	$end_date = $start_date;
    	
    	$title = $_POST['game_type'];
    	}
    	/*
    	if ($_POST['game_time'] = "9:00 am") {
    		$game_time = "09:00:00";}
    	else 	{
    		if ($_POST['game_time'] = "1:00 pm") {
    			$game_time = "13:00:00";}
    		else {$game_time = "19:00:00";}
    		endif;}
    	endif;
    	*/
    	
    	$session = (strtoupper(substr($filename,7,1)));
    	if ($session = "M") {
    		$game_time = "09:00:00";}
    	else 	{
    		if ($session = "A") 
    		{ $game_time = "13:00:00";}
    		else {$game_time = "19:00:00";}
    		}
    	
    	
    	$recur="s";
    	$repeat=0;
    	$author=1;
    	$category=1;
    	
    	/*Create the Link*/
    	
    	$link="http://naplesbridgeplay.com/wp-content/results/";
    	$link .= ( $_FILES['uploadedfile']['name']);
    
    
    	
    	/*Upload the file*/
    	
    	$target_path = "wp-content/results/";
    	$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 
    
    		if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
        			echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
        				" has been uploaded";
    		} 
    		else{
        			echo "There was an error uploading the file, please try again!";
    		}
    		
    	
    	/*Create the MYSQL Insert*/
    	
    	$caltable = "wp_calendar";
    	$sql = "insert into " ;
    	$sql .= $caltable ;
    	$sql .= " (event_begin, event_end, event_title, event_time, event_recur,event_repeats, event_author, event_category, event_link) VALUES ($start_date, $end_date, $title, $game_time,$recur, $repeat, $author, $category, $link)";
    	$sql_result = mysql_query($sql);
    
    else {
    header("LOCATION: upload.php");
    exit;}
    }
    ?>
    <html>
    <head>
    <title>Results Upload Success</title>
    </head>
    <body>
    <h3> Goody!</h3>
    </body>
    </html>

  • #2
    If I were a betting man, I'd put one right here:
    Code:
    	$sql .= " (event_begin, event_end, event_title, event_time, event_recur,event_repeats, event_author, event_category, event_link) VALUES ($start_date, $end_date, $title, $game_time,$recur, $repeat, $author, $category, $link)";
    	$sql_result = mysql_query($sql);
    	[COLOR="Red"]}[/COLOR]
    else {
    header("LOCATION: upload.php");
    ...but I didn't look at your code, I'm just looking at how you've laid it out. There is a member here, can't remember his name, who has a thing about formatting your code so you can see your braces line up. I agree with him - code is much easier to debug if start and end points of blocks of code are aligned.

    Dave

    Comment


    • #3
      Right before your last else statement

      PHP Code:
      <?php
      /********************************************************
      ***This file is for uploading games
      ***Author: Stuart Altschuler
      ***Created: September 5, 2011
      ********************************************************/

      include "inc_dbcnx.php";
      /*include "inc_header.php";*/

      if ($_FILES['uploadedfile'] !="") {
          
      $fileName $_FILES['uploadedfile']['name'];
          if((
      strlen($fileName) == 11) || (strlen($fileName) == 12)) {
          
      $year  substr($fileName,0,2);
          
      $month substr($fileName,2,2);
          
      $day   substr($fileName,4,2);
          
      $start_date "20";
          
      $start_date .= $year;
          
      $start_date .="-";
          
      $start_date .= $month;
          
      $start_date .="-";
          
      $start_date .= $day;
          
          
      $end_date $start_date;
          
          
      $title $_POST['game_type'];
          }
          
      /*
          if ($_POST['game_time'] = "9:00 am") {
              $game_time = "09:00:00";}
          else     {
              if ($_POST['game_time'] = "1:00 pm") {
                  $game_time = "13:00:00";}
              else {$game_time = "19:00:00";}
              endif;}
          endif;
          */
          
          
      $session = (strtoupper(substr($filename,7,1)));
          if (
      $session "M") {
              
      $game_time "09:00:00";}
          else     {
              if (
      $session "A"
              { 
      $game_time "13:00:00";}
              else {
      $game_time "19:00:00";}
              }
          
          
          
      $recur="s";
          
      $repeat=0;
          
      $author=1;
          
      $category=1;
          
          
      /*Create the Link*/
          
          
      $link="http://naplesbridgeplay.com/wp-content/results/";
          
      $link .= ( $_FILES['uploadedfile']['name']);


          
          
      /*Upload the file*/
          
          
      $target_path "wp-content/results/";
          
      $target_path $target_path basename$_FILES['uploadedfile']['name']); 

              if(
      move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
                      echo 
      "The file ".  basename$_FILES['uploadedfile']['name']). 
                          
      " has been uploaded";
              } 
              else{
                      echo 
      "There was an error uploading the file, please try again!";
              }
              
          
          
      /*Create the MYSQL Insert*/
          
          
      $caltable "wp_calendar";
          
      $sql "insert into " ;
          
      $sql .= $caltable ;
          
      $sql .= " (event_begin, event_end, event_title, event_time, event_recur,event_repeats, event_author, event_category, event_link) VALUES ($start_date$end_date$title$game_time,$recur$repeat$author$category$link)";
          
      $sql_result mysql_query($sql);

      } else {
      header("LOCATION: upload.php");
      exit;}

      ?>
      <html>
      <head>
      <title>Results Upload Success</title>
      </head>
      <body>
      <h3> Goody!</h3>
      </body>
      </html>
      If you can't stand behind your troops, feel free to stand in front of them
      Semper Fidelis

      Comment

      Working...
      X
      😀
      🥰
      🤢
      😎
      😡
      👍
      👎