Jump to content

[SOLVED] } help


alemapo

Recommended Posts

I had this code working great and then took out one of the "else" because I didn't need it anymore.  Now I can't get the } right at the end. I keep getting this error.

 

Parse error: syntax error, unexpected $end in /home6/carroll7/public_html/upload_functions_magick.php on line 45

 

Then if I move it I get another. Can anyone see it right off?  Many thanks in advance.

 

if (isset($_POST['submitted'])) {

$image_type = upload_image();

//check to see if image type returned ok

if ($image_type == 'ok')  {

//call move image function

$full_path = "/home6/carroll7/public_html/classified_images/";

$short_path = "/classified_images/";

$stored_name = move_image($full_path, $short_path); 

$_POST['hiddenField'] = $stored_name;

echo "Image upload success!"; }

    else

  { echo "image wrong type";  }

}

 

Link to comment
https://forums.phpfreaks.com/topic/172309-solved-help/
Share on other sites

The surrounding code is all dreamweaver created. To the best of my knowledge I didn't change any of that. My code was working before but I had another level else in there that was removed. 

 

 

<?php require_once('Connections/Carrollton.php'); ?>

<?php include('upload_functions_magick.php'); ?>

<?php

if (!function_exists("GetSQLValueString")) {

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")

{

  if (PHP_VERSION < 6) {

    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  }

 

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

 

  switch ($theType) {

    case "text":

      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

      break;   

    case "long":

    case "int":

      $theValue = ($theValue != "") ? intval($theValue) : "NULL";

      break;

    case "double":

      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";

      break;

    case "date":

      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

      break;

    case "defined":

      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;

      break;

  }

  return $theValue;

}

}

 

//call upload image function

if (isset($_POST['submitted'])) {

$image_type = upload_image();

//check to see if image type returned ok

if ($image_type == 'ok')  {

//call move image function

$full_path = "/home6/carroll7/public_html/classified_images/";

$short_path = "/classified_images/";

$stored_name = move_image($full_path, $short_path); 

$_POST['hiddenField'] = $stored_name;

echo "Image upload success!"; }

    else

  { echo "image wrong type";  }

}

 

 

$editFormAction = $_SERVER['PHP_SELF'];

if (isset($_SERVER['QUERY_STRING'])) {

  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);

}

 

 

Link to comment
https://forums.phpfreaks.com/topic/172309-solved-help/#findComment-908494
Share on other sites

The function in the if statement is a little odd... Try changing echo "Image upload success!"; } to:

echo "Image upload success!"; 
}

 

Do that with the else statement too, putting curly brackets on their own line is good practice and makes things easier to read and find the beginning/end of an if statement.

Link to comment
https://forums.phpfreaks.com/topic/172309-solved-help/#findComment-908504
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.