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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.