Brian W Posted October 14, 2008 Share Posted October 14, 2008 I recently moved a project over to a new system running PHP v 5.2.6 (which I believe is the most recent "stable" version) Suddenly, pages that used to work fine are having a common error, "unexpected $end"... I go through and balanced the braces using Dreamweaver, then counting on my fingers, then I even found a neat site that you paste your script into and it highlights w/in the braces different colors... but all three tactics turned up nothing. The braces are 100% fine it appears. I think it has something to do with v 5.2.*, but I will give it the benefit of the doubt. Is there any pieces of software out there that will check the integrity of your script? I've already spent hours on this and am tired of counting and recounting. *I do NOT use the short tag ( "<?" ) ever. *Using Dreamweaver, so I know I do not have a issue with my quotes because it comes of very clearly if I do. *I will post the script if any one is interested in counting :-p (AKA, join my insanity) Quote Link to comment https://forums.phpfreaks.com/topic/128378-solved-this-is-killing-me/ Share on other sites More sharing options...
Andy17 Posted October 14, 2008 Share Posted October 14, 2008 Post your code and I will see if I can find your problem. Quote Link to comment https://forums.phpfreaks.com/topic/128378-solved-this-is-killing-me/#findComment-665102 Share on other sites More sharing options...
kenrbnsn Posted October 14, 2008 Share Posted October 14, 2008 Please post the code that's giving you problems. It's quite possible that there was a problem uploading the files to the new system. Check the uploaded files against the ones on your development system. Ken Quote Link to comment https://forums.phpfreaks.com/topic/128378-solved-this-is-killing-me/#findComment-665104 Share on other sites More sharing options...
Brian W Posted October 14, 2008 Author Share Posted October 14, 2008 <?php require_once('../Connections/Test.php'); //Connection info ?> <?php if (!isset($_SESSION)) { session_start(); } $MM_authorizedUsers = "1,2"; $MM_donotCheckaccess = "false"; // *** Restrict Access To Page: Grant or deny access to this page function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { // For security, start by assuming the visitor is NOT authorized. $isValid = False; // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. // Therefore, we know that a user is NOT logged in if that Session variable is blank. if (!empty($UserName)) { // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. // Parse the strings into arrays. $arrUsers = Explode(",", $strUsers); $arrGroups = Explode(",", $strGroups); if (in_array($UserName, $arrUsers)) { $isValid = true; } // Or, you may restrict access to only certain users based on their username. if (in_array($UserGroup, $arrGroups)) { $isValid = true; } if (($strUsers == "") && false) { $isValid = true; } } return $isValid; } $MM_restrictGoTo = "Dashboard.php"; if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) { $MM_qsChar = "?"; $MM_referrer = $_SERVER['PHP_SELF']; if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&"; if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0) $MM_referrer .= "?" . $QUERY_STRING; $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer); header("Location: ". $MM_restrictGoTo); exit; } ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $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; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO Clients (Client, Details) VALUES (%s, %s)", GetSQLValueString($_POST['Client'], "text"), GetSQLValueString($_POST['Details'], "text")); mysql_select_db($database_Test, $Test); $Result1 = mysql_query($insertSQL, $Test) or die(mysql_error()); $insertGoTo = "Clients.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); } if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form2")) { $updateSQL = sprintf("UPDATE Clients SET Client=%s, Details=%s, ClientID=%s WHERE ID=%s", GetSQLValueString($_POST['Client2'], "text"), GetSQLValueString($_POST['Details2'], "text"), GetSQLValueString($_POST['ClientID'], "text"), GetSQLValueString($_POST['hiddenField'], "int")); mysql_select_db($database_Test, $Test); $Result1 = mysql_query($updateSQL, $Test) or die(mysql_error()); $updateGoTo = "Clients.php"; if (isset($_SERVER['QUERY_STRING'])) { $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?"; $updateGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $updateGoTo)); } if ((isset($_POST['DeleteID'])) && ($_POST['DeleteID'] != "")) { $deleteSQL = sprintf("DELETE FROM Clients WHERE ID=%s", GetSQLValueString($_POST['DeleteID'], "int")); mysql_select_db($database_Test, $Test); $Result1 = mysql_query($deleteSQL, $Test) or die(mysql_error()); $deleteGoTo = "Clients.php?Action=Deleted"; if (isset($_SERVER['QUERY_STRING'])) { $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?"; $deleteGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $deleteGoTo)); } mysql_select_db($database_Test, $Test); $query_Clients = "SELECT * FROM Clients"; $Clients = mysql_query($query_Clients, $Test) or die(mysql_error()); $row_Clients = mysql_fetch_assoc($Clients); $totalRows_Clients = mysql_num_rows($Clients); $colname_Delete = "-1"; if (isset($_GET['ID'])) { $colname_Delete = $_GET['ID']; } mysql_select_db($database_Test, $Test); $query_Delete = sprintf("SELECT * FROM Clients WHERE ID = %s", GetSQLValueString($colname_Delete, "int")); $Delete = mysql_query($query_Delete, $Test) or die(mysql_error()); $row_Delete = mysql_fetch_assoc($Delete); $totalRows_Delete = mysql_num_rows($Delete); ?> <?php //MAILER if(isset($_GET['Action']) && $_GET['Action'] == "Deleted") { $To = 'Brian W <brianw@bexexpress.com>'; $Subject = 'Client "'.$_GET['Client'].'" has been removed.'; $Body = 'Client "'.$_GET['Client'].'" has been removed by '.$_SESSION['MM_Username'].'.'; if(mail($To, $Subject, $Body)) { header('Location: Clients.php'); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Dashboard - Manage Clients</title> <link href="style.css" rel="stylesheet" type="text/css" /> </head> <body> <?php include("top.php"); ?> <?php $Show = "No"; if($row_LogedIn['Security'] == "1" && $_SERVER['REMOTE_ADDR'] == $row_LogedIn['IP']) { $Show = "Yes"; } if($row_LogedIn['Security'] == "2") { $Show = "Yes"; } if($Show == "Yes") { ?> <a href="Dashboard.php">Back to Dashboard </a><a href="Test.php">Test</a><br /> <?php //if Add if(isset($_GET['Do']) && $_GET['Do'] == "Add") { ?> <h2>Add Client</h2> <form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>"> <table width="100%" border="0" cellspacing="2" cellpadding="2"> <tr> <td width="16%" valign="top"><div align="right"><strong>Client Name:</strong></div></td> <td width="84%"> <input name="Client" type="text" id="Client" size="40" /> </td> </tr> <tr> <td valign="top"><div align="right"><strong>Notes/ Details:</strong></div></td> <td> <textarea name="Details" id="Details" cols="75" rows="5"></textarea> </p></td> </tr> <tr> <td valign="top"><div align="right"><strong>Client ID:</strong></div></td> <td> <input type="text" name="ClientID2" id="ClientID2" /> <br /> <input type="submit" name="Submit" id="Submit" value="Add Client" /> </p></td> </tr> </table> <input type="hidden" name="MM_insert" value="form1" /> </form> <p> <? } //if Add ?> <?php //if Add if(isset($_GET['Do']) && $_GET['Do'] == "Delete" && $_GET['Client'] == $row_Delete['Client']) { ?> <table width="68%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td class="update"><div align="center"> <form id="form3" name="form3" method="post" action=""> <input name="DeleteID" type="hidden" id="DeleteID" value="<?php echo $row_Delete['ID']; ?>" /> Are you sure you want to delete Client "<strong><?php echo $row_Delete['Client']; ?></strong>"? <input type="submit" name="Delete" id="Delete" value="Confirm Delete" /> </form> </div></td> </tr> </table> <p> <p> <?php } //if Delete ?> <table border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="134" class="key">ID</td> <td width="308" class="key">Client</td> <td colspan="2" class="key">Client ID</td> </tr> <?php do { ?> <tr> <td><?php echo $row_Clients['ID']; ?> </td> <td><a href="Clients.php?ID=<?php echo $row_Clients['ID']; ?>"> <?php echo $row_Clients['Client']; ?> </a> </td> <td width="191" bordercolor="#CCCCCC"><?php echo $row_Clients['ClientID']; ?></td> <td width="109" bordercolor="#CCCCCC"> </td> </tr> <tr> <td colspan="4" class="spacer" height="5px"> <?php if(isset($_GET['ID']) && $_GET['ID'] == $row_Clients['ID']) { //If selected ?> <form id="form2" name="form2" method="POST" action="<?php echo $editFormAction; ?>"> <table width="100%" border="0" cellspacing="2" cellpadding="2" class="update"> <tr> <td width="21%"><div align="right"><strong>Client Name:</strong></div></td> <td colspan="3"> <input name="Client2" type="text" id="Client2" value="<?php echo $row_Clients['Client']; ?>" size="45" /> </td> </tr> <tr> <td><div align="right"><strong>Notes/Details:</strong></div></td> <td colspan="2"> <textarea name="Details2" id="Details2" cols="75" rows="6"><?php echo $row_Clients['Details']; ?></textarea> </td> </tr> <tr> <td valign="top"><div align="right"><strong>Client ID:</strong></div></td> <td width="63%"> <input name="ClientID" type="text" id="ClientID" value="<?php echo $row_Clients['ClientID']; ?>" /> <input name="hiddenField" type="hidden" id="hiddenField" value="<?php echo $row_Clients['ID']; ?>" /> <br /> <input type="submit" name="Submit2" id="Submit2" value="Update" /> </td> <td width="16%" valign="bottom"><?php if($_SESSION['MM_UserGroup'] == "1"){ ?> <a href="?Do=Delete&ID=<?php echo $row_Clients['ID']."&Client=".$row_Clients['Client']; ?>">Delete</a> <?php } ?></td> </tr> </table> <input type="hidden" name="MM_update" value="form2" /> </form> <?php } else { echo ""; }?></td> </tr> <?php } while ($row_Clients = mysql_fetch_assoc($Clients)); ?> <tr> <td> </td> <td> </td> <td colspan="2" bordercolor="#CCCCCC"><div align="right"><a href="Clients.php?Do=Add">Add Client</a></div></td> </tr> </table> <?php }else{ ?> You have turned on the "Extra Security" setting for your account which disables the use of Express Project Manager from any other IP address than the one we have stored. Please contact ************* to have your account switched back to "Normal Security". <?php } ?> <?php include("bottom.php") ?> </body> </html> <?php mysql_free_result($Clients); mysql_free_result($Delete); ?> -Top.php <?php require_once('../Connections/Test.php'); ?><?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $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; } } $colname_LogedIn = "-1"; if (isset($_SESSION['MM_Username'])) { $colname_LogedIn = $_SESSION['MM_Username']; } mysql_select_db($database_Test, $Test); $query_LogedIn = sprintf("SELECT ID, Username, Client, `Level`, Email, Address, IP, Security FROM BexUsers WHERE Username = %s", GetSQLValueString($colname_LogedIn, "text")); $LogedIn = mysql_query($query_LogedIn, $Test) or die(mysql_error()); $row_LogedIn = mysql_fetch_assoc($LogedIn); $totalRows_LogedIn = mysql_num_rows($LogedIn); ?> <link href="style.css" rel="stylesheet" type="text/css"> <style type="text/css"> <!-- .style4 { font-family: brodyd } .style5 { font-size: 24px; color: #FF0000; } .style7 { font-size: 12px; color: #000000; } img { border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; } --> </style> <table width="100%" height="118" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="37%" rowspan="2"><a href="Dashboard.php"><img src="logo.gif" width="329" height="139"></a><span class="style7">™</span></td> <td width="36%" valign="top"><p align="right"> </p> </td> <td width="27%" valign="top"><?php if (isset($_SESSION['MM_Username'])){ ?><strong>Welcome:</strong> <?php echo $_SESSION['MM_Username']; ?><br /><a href="User.php?Name=<?php echo $_SESSION['MM_Username']; ?>">[Account Settings]</a><?php } else {?>Please <a href="../EPM/SignIn.php">Sign In</a> <?php } ?></td> </tr> <tr> <td colspan="2" valign="bottom"><h3><span class="style4 style5">Dashboard</span><span class="style7">™</span></h3> <h1>Express Project Manager <?php $last = getenv("HTTP_REFERER");?></h1> </td> </tr> </table> <?php mysql_free_result($LogedIn); ?> <?php if (isset($_GET['accesscheck'])) {?> <p align="center"><strong>You do not have access to the page you were trying to view.</strong></p> <?php } ?> -bottom.php only has some html. It is our copyright statement and link to our company's website. I think the script is pretty cluttered, but I guess that is what happens when you use Dreamweaver than go back and ad your own flavor. BTW, this is not the only page having this problem. I don't understand whats going on, its just eating up time at this point. Oh yeah, if I add a } after the last } in the code, the page doesn't work right but doesn't give me the error anymore/ Quote Link to comment https://forums.phpfreaks.com/topic/128378-solved-this-is-killing-me/#findComment-665126 Share on other sites More sharing options...
F1Fan Posted October 14, 2008 Share Posted October 14, 2008 <?php include("bottom.php") ?> needs to be <?php include("bottom.php"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/128378-solved-this-is-killing-me/#findComment-665128 Share on other sites More sharing options...
Brian W Posted October 14, 2008 Author Share Posted October 14, 2008 Well, that didn't fix it, but thank you for pointing that out. Quote Link to comment https://forums.phpfreaks.com/topic/128378-solved-this-is-killing-me/#findComment-665133 Share on other sites More sharing options...
Maq Posted October 14, 2008 Share Posted October 14, 2008 Is there any pieces of software out there that will check the integrity of your script? To my knowledge, not entirely but I'm sure they're something out there to help. I use NetBeans (free) and usually it can pick up mistakes, but besides that I'm not sure. Quote Link to comment https://forums.phpfreaks.com/topic/128378-solved-this-is-killing-me/#findComment-665146 Share on other sites More sharing options...
Brian W Posted October 14, 2008 Author Share Posted October 14, 2008 I'm downloading NetBeans and I'll see if it can point me in the right direction. Thank you. /b/ question... has any one else encountered this problem after moving to 5.2.*? Like I said, all I did was start using a different server for testing. I brought over all the exact same files. *I went from 4.1.6 (I think it was) to 5.2.6 Quote Link to comment https://forums.phpfreaks.com/topic/128378-solved-this-is-killing-me/#findComment-665165 Share on other sites More sharing options...
F1Fan Posted October 14, 2008 Share Posted October 14, 2008 It looks like you have one more { bracket than } brackets in that first file. Quote Link to comment https://forums.phpfreaks.com/topic/128378-solved-this-is-killing-me/#findComment-665169 Share on other sites More sharing options...
Lamez Posted October 14, 2008 Share Posted October 14, 2008 can you post the website? I would like to take a look at it Quote Link to comment https://forums.phpfreaks.com/topic/128378-solved-this-is-killing-me/#findComment-665172 Share on other sites More sharing options...
Brian W Posted October 14, 2008 Author Share Posted October 14, 2008 Where though? It would appear that is the problem, but I haven't found any such problem. If you mean the connection info page, there is not a single { or } in it. All it is is just my global variables for connecting to mysql. Sorry, I would post the link, but two problems. #1 - all you would see is Parse error: syntax error, unexpected $end in C:\Inetpub\wwwroot\*censored*\Clients.php on line 295 #2 - It is actually already connected to our clients database and that information is private. Sorry... Quote Link to comment https://forums.phpfreaks.com/topic/128378-solved-this-is-killing-me/#findComment-665174 Share on other sites More sharing options...
Brian W Posted October 14, 2008 Author Share Posted October 14, 2008 So, I'm going to go with "I'm screwed"... possibly I'll try reversing back to version 5.1.* or something and see if I continue to get the same problem. But please, if you refuse to believe this may be a problem with 5.2.6, keep counting, keep reviewing the code... if I don't figure this out in the next few hours, I'm downgrading. If downgrading fixes the problem, I will report this as a bug. Quote Link to comment https://forums.phpfreaks.com/topic/128378-solved-this-is-killing-me/#findComment-665183 Share on other sites More sharing options...
kenrbnsn Posted October 14, 2008 Share Posted October 14, 2008 Please compare the uploaded files against those on your development system. Something may have happened when you uploaded. If there was a problem with PHP like this, many more people would be reporting it. Ken Quote Link to comment https://forums.phpfreaks.com/topic/128378-solved-this-is-killing-me/#findComment-665186 Share on other sites More sharing options...
Lamez Posted October 14, 2008 Share Posted October 14, 2008 no the link to the website that looks at the code for ya! Quote Link to comment https://forums.phpfreaks.com/topic/128378-solved-this-is-killing-me/#findComment-665195 Share on other sites More sharing options...
Brian W Posted October 14, 2008 Author Share Posted October 14, 2008 http://www.balancebraces.com/ I've made major changes to the script since the move in order to try to fix the error. But, what I will do is move the new copy back to the old server and see what it does. I'll let every one know how that goes. There is a overwhelming amount of similar problems being discussed in other boards. Though some people are having odd and end problems of bad settings, actually missing the brace, or whatever... some people are stuck like I am. Quote Link to comment https://forums.phpfreaks.com/topic/128378-solved-this-is-killing-me/#findComment-665205 Share on other sites More sharing options...
Andy17 Posted October 14, 2008 Share Posted October 14, 2008 I have also experienced problems when just moving a working script from one subdomain to another, but always found a way to get around it (without ever finding the cause as far as I remember). Sometimes it just seems too weird to be true. Quote Link to comment https://forums.phpfreaks.com/topic/128378-solved-this-is-killing-me/#findComment-665214 Share on other sites More sharing options...
Brian W Posted October 14, 2008 Author Share Posted October 14, 2008 Which is not good for me... it is just bad practice to move on or avoid something instead of fixing a problem (no offense, speaking general). I want to do this the Linux & Mac way, not the Windows band-aid tactic... Still working at getting the old server back to functioning state so I can run that experiment on it... Quote Link to comment https://forums.phpfreaks.com/topic/128378-solved-this-is-killing-me/#findComment-665223 Share on other sites More sharing options...
wildteen88 Posted October 14, 2008 Share Posted October 14, 2008 You say your script doesn't use short tags? Then what is this here: <p> <? } //if Add ?> <?php //if Add if(isset($_GET['Do']) && $_GET['Do'] == "Delete" && $_GET['Client'] == $row_Delete['Client']) { ?> That is what is causing the error. Your previous server may of had a setting called short_open_tag enabled whereas your new server doesn't. Not all PHP setups have short tags enabled. Also try to avoid letting Dreamwever write code for you. The code generated by DW is messy and can cause a lot of problems when trying to debug. Quote Link to comment https://forums.phpfreaks.com/topic/128378-solved-this-is-killing-me/#findComment-665232 Share on other sites More sharing options...
Maq Posted October 14, 2008 Share Posted October 14, 2008 good eye. Quote Link to comment https://forums.phpfreaks.com/topic/128378-solved-this-is-killing-me/#findComment-665238 Share on other sites More sharing options...
Brian W Posted October 14, 2008 Author Share Posted October 14, 2008 Yeah, I agree with Maq... GOOD EYE! kudos comrade! Thank you for finding that. Damn that was hard to find. I have the ini setting turned off purposely because I do not want to get in the habit of using short tags. Again, Thank you wildteen88. Well, I guess I was one of those people that I mentioned before that had petty little issues. *hits head on desk* Quote Link to comment https://forums.phpfreaks.com/topic/128378-solved-this-is-killing-me/#findComment-665244 Share on other sites More sharing options...
Maq Posted October 14, 2008 Share Posted October 14, 2008 I have the ini setting turned off purposely because I do not want to get in the habit of using short tags. Guess you won't do that again Quote Link to comment https://forums.phpfreaks.com/topic/128378-solved-this-is-killing-me/#findComment-665248 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.