Skip to main content
Known Participant
July 12, 2010
Question

urgent help needed please, with parse error message

  • July 12, 2010
  • 1 reply
  • 772 views

Hi. I've got a page which comes at the end of a 3 page sequence - search, results, detail. The detail page had been working fine, but yesterday I added a second recordset to the page, to pull reviews from a separate table, and now I'm getting the following error:

Parse error: syntax error, unexpected ')', expecting T_STRING or T_VARIABLE or '$' in /Applications/MAMP/htdocs/goodvetguide/practice_Detail.php on line 78

(should point out that I'm using DMW8 on a Mac and testing locally using MAMP as my testing server).

line 78 is:

if (isset()) {

  $Parampractice_id_WADApracticelist = (get_magic_quotes_gpc()) ?  : addslashes();

}

and the full code for the page is posted below. I've googled this error and found a variety of different reasons for why this might be happening but none of the examples I've seen appear to apply to my case, so I'd really appreciate any assistance anyone can offer with this. Thanks in advance.
Page code:
<?php require_once('Connections/connGVG.php'); ?>
<?php require_once('Connections/connGVG.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;
}
}
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;
}
}
?><?php
if (!session_id()) session_start();
?>
<?php
$Parampractice_WADApracticelist = "-1";
if (isset($_GET['practice_id'])) {
  $Parampractice_WADApracticelist = (get_magic_quotes_gpc()) ? $_GET['practice_id'] : addslashes($_GET['practice_id']);
}
$ParamSessionpractice_WADApracticelist = "-1";
if (isset($_SESSION['WADA_Insert_practicelist'])) {
  $ParamSessionpractice_WADApracticelist = (get_magic_quotes_gpc()) ? $_SESSION['WADA_Insert_practicelist'] : addslashes($_SESSION['WADA_Insert_practicelist']);
}
$Parampractice_WADApracticelist = "-1";
if (isset($_GET['practice_id'])) {
  $Parampractice_WADApracticelist = (get_magic_quotes_gpc()) ? $_GET['practice_id'] : addslashes($_GET['practice_id']);
}
$Parampractice_id_WADApracticelist = "-1";
if (isset()) {
  $Parampractice_id_WADApracticelist = (get_magic_quotes_gpc()) ?  : addslashes();
}
$Parampractice_id2_WADApracticelist = "-1";
if (isset()) {
  $Parampractice_id2_WADApracticelist = (get_magic_quotes_gpc()) ?  : addslashes();
}
$ParamSessionpractice_id_WADApracticelist = "-1";
if (isset()) {
  $ParamSessionpractice_id_WADApracticelist = (get_magic_quotes_gpc()) ?  : addslashes();
}
mysql_select_db($database_connGVG, $connGVG);
$query_WADApracticelist = sprintf("SELECT practice_id, practicename, address1, address2, address3, address4, postcode, location, practicewebsite, practicetype, starrating FROM practicelist WHERE practice_id = %s OR ( -1= %s AND practice_id= %s)", GetSQLValueString($Parampractice_id_WADApracticelist, ""),GetSQLValueString($Parampractice_id2_WADApracticelist, ""),GetSQLValueString($ParamSessionpractice_id_WADApracticelist, ""));
$WADApracticelist = mysql_query($query_WADApracticelist, $connGVG) or die(mysql_error());
$row_WADApracticelist = mysql_fetch_assoc($WADApracticelist);
$totalRows_WADApracticelist = mysql_num_rows($WADApracticelist);
$colname_rsReviews = "-1";
if (isset($_GET['WADALocation'])) {
  $colname_rsReviews = (get_magic_quotes_gpc()) ? $_GET['WADALocation'] : addslashes($_GET['WADALocation']);
}
mysql_select_db($database_connGVG, $connGVG);
$query_rsReviews = sprintf("SELECT * FROM reviews WHERE practice_id = %s", GetSQLValueString($colname_rsReviews, "int"));
$rsReviews = mysql_query($query_rsReviews, $connGVG) or die(mysql_error());
$row_rsReviews = mysql_fetch_assoc($rsReviews);
$totalRows_rsReviews = mysql_num_rows($rsReviews);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Details practicelist</title>
<style type="text/css">
<!--
-->
</style>
<link href="style.css" rel="stylesheet" type="text/css" />
<link href="WA_DataAssist/styles/Refined_Pacifica.css" rel="stylesheet" type="text/css" />
<link href="WA_DataAssist/styles/Arial.css" rel="stylesheet" type="text/css" />
<style type="text/css">
/* Details page CSS */
.WADADetailsContainer {
font-size: 11px;
}
#WADADetails {
padding-top: 10px;
}
</style>
</head>
<body>
<div id="wrapper">
  <div id="header"></div>
  <div id="content">
    <div id="menu">
      <a href="addreview.html">Add review</a>  <a href="contact.html">Contact</a>  <a href="terms.html">Terms</a>  <a href="practice_Search.php">Search</a>  <a href="about.html">About </a><a href="index.html">Home </a></div>
    <div id="contentleft2">
      <div id="greenpiccont"></div>
      <div id="cright">
        <div class="boldwhite" id="rightblue">Review your vet<br />
          <br />
          <span class="smallbold">Tell us your experience</span><br />
          <br />
          <span class="smallwhite">Give people information<br />
          on your experiences so <br />
          that they can make an<br />
          informed decision.</span><br />
          <div id="startbutton"><a href="#">Start</a></div>
        </div>
      <div id="bluemap2"></div>
      <div id="searchbox">
        <table width="202" border="0" cellspacing="0">
          <tr>
            <th scope="row"><div align="left" class="smalltext">Search by postcode</div></th>
          </tr>
          <tr>
            <th height="31" scope="row"><input name="Name" class="Width250px" /></th>
          </tr>
          <tr>
            <th scope="row"><div align="left" class="smalltext">Miles</div></th>
          </tr>
          <tr>
            <th height="39" scope="row"><div align="left">
              <input name="Name2" class="Width250px" />
            </div></th>
          </tr>
        </table>
      </div>
      </div>
     
      <div class="about10" id="contl">Practice details<br />
        <div class="WADADetailsContainer"> <a name="top"></a>
          <div class="WADAHorizLine"><img src="WA_DataAssist/images/_tx_.gif" alt="" height="1" width="1" border="0" /></div>
          <?php if ($totalRows_WADApracticelist > 0) { // Show if recordset not empty ?>
            <div id="WADADetails">
              <table class="WADADataTable" cellpadding="0" cellspacing="0" border="0">
                <tr>
                  <th class="WADADataTableHeader">Practice name:</th>
                  <td class="WADADataTableCell"><strong><?php echo($row_WADApracticelist['practicename']); ?></strong></td>
                </tr>
                <tr>
                  <th class="WADADataTableHeader">Practice type:</th>
                  <td class="WADADataTableCell"><?php echo($row_WADApracticelist['practicetype']); ?></td>
                </tr>
                <tr>
                  <th class="WADADataTableHeader">Address:</th>
                  <td class="WADADataTableCell"><?php echo($row_WADApracticelist['address1']); ?></td>
                </tr>
                <tr>
                  <th class="WADADataTableHeader"> </th>
                  <td class="WADADataTableCell"><?php echo($row_WADApracticelist['address2']); ?></td>
                </tr>
                <tr>
                  <th class="WADADataTableHeader"> </th>
                  <td class="WADADataTableCell"><?php echo($row_WADApracticelist['address3']); ?></td>
                </tr>
                <tr>
                  <th class="WADADataTableHeader"> </th>
                  <td class="WADADataTableCell"><?php echo($row_WADApracticelist['address4']); ?></td>
                </tr>
                <tr>
                  <th class="WADADataTableHeader">Postcode:</th>
                  <td class="WADADataTableCell"><?php echo($row_WADApracticelist['postcode']); ?></td>
                </tr>
                <tr>
                  <th class="WADADataTableHeader">Location:</th>
                  <td class="WADADataTableCell"><?php echo($row_WADApracticelist['location']); ?></td>
                </tr>
                <tr>
                  <th class="WADADataTableHeader">Website:</th>
                  <td class="WADADataTableCell"><a href="http://www.<?php echo $row_WADApracticelist['practicewebsite']; ?>" target="_blank"><?php echo($row_WADApracticelist['practicewebsite']); ?></a></td>
                </tr>
                <tr>
                  <th class="WADADataTableHeader">Star rating:</th>
                  <td class="WADADataTableCell"><?php echo($row_WADApracticelist['starrating']); ?></td>
                </tr>
              </table>
              <div class="WADAHorizLine"><img src="WA_DataAssist/images/_tx_.gif" alt="" height="1" width="1" border="0" /></div>
              <div class="WADAButtonRow">
                <table class="WADADataNavButtons" border="0" cellpadding="0" cellspacing="0">
                  <tr>
                    <td class="WADADataNavButtonCell" nowrap="nowrap"></td>
                    <td class="WADADataNavButtonCell" nowrap="nowrap"></td>
                    <td class="WADADataNavButtonCell" nowrap="nowrap"><a href="practice_Results.php" title="Results"><img border="0" name="Results" id="Results" alt="Results" src="WA_DataAssist/images/Pacifica/Refined_results.gif" /></a></td>
                  </tr>
                </table>
              </div>
            </div>
          <?php } // Show if recordset not empty ?>
          <?php if ($totalRows_WADApracticelist == 0) { // Show if recordset empty ?>
            <div class="WADANoResults">
              <div class="WADANoResultsMessage">No record found.</div>
            </div>
            <div class="WADAHorizLine"><img src="WA_DataAssist/images/_tx_.gif" alt="" height="1" width="1" border="0" /></div>
            <div class="WADADetailsLinkArea">
              <div class="WADADataNavButtonCell"><a href="practice_Results.php" title="Results"><img border="0" name="Results1" id="Results1" alt="Results" src="WA_DataAssist/images/Pacifica/Refined_results.gif" /></a></div>
            </div>
            <div class="WADAHorizLine"><img src="WA_DataAssist/images/_tx_.gif" alt="" height="1" width="1" border="0" /></div><p><strong>Reviews for this practice:</strong></p>
            <?php do { ?>
              <table width="100%" border="0" cellspacing="5" cellpadding="2">
                <tr>
                  <td width="23%"> </td>
                  <td width="77%"><?php echo $row_rsReviews['comments']; ?></td>
                </tr>
                <tr>
                  <td> </td>
                  <td> </td>
                </tr>
                              </table>
              <?php } while ($row_WADApracticelist = mysql_fetch_assoc($WADApracticelist)); ?>
            <?php } // Show if recordset empty ?>
        </div>
      </div>
    </div>
    <div id="contentright">
      <p> </p>
    </div>
  </div>
  <div class="clr"></div>
  <div id="footer">hj</div>
</div>
</body>
</html>
<?php
mysql_free_result($WADApracticelist);
mysql_free_result($rsReviews);
?>

This topic has been closed for replies.

1 reply

David_Powers
Inspiring
July 12, 2010

I haven't studied your code in detail, but it looks very much as though you have been editing the page without properly removing server behaviors through the Server Behaviors panel. Look at the following section:

<?php require_once('Connections/connGVG.php'); ?>
<?php require_once('Connections/connGVG.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;
}
}
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;
}
}
?>

You have the connection file attached twice, and the GetSQLValueString() function is defined twice. However, the cause of all your problems lies here:

$Parampractice_WADApracticelist = "-1";
if (isset($_GET['practice_id'])) {
  $Parampractice_WADApracticelist = (get_magic_quotes_gpc()) ? $_GET['practice_id'] : addslashes($_GET['practice_id']);
}
$ParamSessionpractice_WADApracticelist = "-1";
if (isset($_SESSION['WADA_Insert_practicelist'])) {
  $ParamSessionpractice_WADApracticelist = (get_magic_quotes_gpc()) ? $_SESSION['WADA_Insert_practicelist'] : addslashes($_SESSION['WADA_Insert_practicelist']);
}
$Parampractice_WADApracticelist = "-1";
if (isset($_GET['practice_id'])) {
  $Parampractice_WADApracticelist = (get_magic_quotes_gpc()) ? $_GET['practice_id'] : addslashes($_GET['practice_id']);
}
$Parampractice_id_WADApracticelist = "-1";
if (isset()) {
  $Parampractice_id_WADApracticelist = (get_magic_quotes_gpc()) ?  : addslashes();
}
$Parampractice_id2_WADApracticelist = "-1";
if (isset()) {
  $Parampractice_id2_WADApracticelist = (get_magic_quotes_gpc()) ?  : addslashes();
}
$ParamSessionpractice_id_WADApracticelist = "-1";
if (isset()) {
  $ParamSessionpractice_id_WADApracticelist = (get_magic_quotes_gpc()) ?  : addslashes();
}
mysql_select_db($database_connGVG, $connGVG);

Look how many times the same code is repeated. What's causing the problem are the three final sections where there is no argument passed to isset().

Delete the code highlighted in red.

jeffmgAuthor
Known Participant
July 12, 2010

Thanks David for the quick response, much appreciated. I've deleted that section and removed the duplicate connection script line. I'm now getting the following error message instead:

Notice: Undefined variable: Parampractice_id_WADApracticelist in /Applications/MAMP/htdocs/goodvetguide/practice_Detail.php on line 44

Notice: Undefined variable: Parampractice_id2_WADApracticelist in /Applications/MAMP/htdocs/goodvetguide/practice_Detail.php on line 44

Notice: Undefined variable: ParamSessionpractice_id_WADApracticelist in /Applications/MAMP/htdocs/goodvetguide/practice_Detail.php on line 44
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'OR ( -1= AND practice_id= )' at line 1

David_Powers
Inspiring
July 13, 2010

Seeing those errors has made me look more closely at your script. I now see that only one of the sections I highlighted in red was actually a duplicate. The others use very similar, but slightly different variables.

The errors stem from the way you have built the SQL query in the Recordset dialog box. Going back to your original code, one part of the problem lies here:

$Parampractice_id_WADApracticelist = "-1";
if (isset()) {
  $Parampractice_id_WADApracticelist = (get_magic_quotes_gpc()) ?  : addslashes();
}
$Parampractice_id2_WADApracticelist = "-1";
if (isset()) {
  $Parampractice_id2_WADApracticelist = (get_magic_quotes_gpc()) ?  : addslashes();
}
$ParamSessionpractice_id_WADApracticelist = "-1";
if (isset()) {
  $ParamSessionpractice_id_WADApracticelist = (get_magic_quotes_gpc()) ?  : addslashes();
}

Compare them with the following, which is correct:

$Parampractice_WADApracticelist = "-1";
if (isset($_GET['practice_id'])) {
  $Parampractice_WADApracticelist = (get_magic_quotes_gpc()) ? $_GET['practice_id'] : addslashes($_GET['practice_id']);
}

Notice that the variable $_GET['practice_id'] appears three times in that block of code. The relevant variables are missing for Parampractice_id, Parampractice_id2, and ParamSessionpractice_id.

You could restore that section of code and edit it manually to insert the relevant variables in the right places, but I still think you would have problems, because of the way the SQL query looks:

$query_WADApracticelist = sprintf("SELECT practice_id, practicename, 
address1, address2, address3, address4, postcode, location, 
practicewebsite, practicetype, starrating FROM practicelist WHERE 
practice_id = %s OR ( -1= %s AND practice_id= %s)", 
  GetSQLValueString($Parampractice_id_WADApracticelist, ""),
  GetSQLValueString($Parampractice_id2_WADApracticelist, ""),
  GetSQLValueString($ParamSessionpractice_id_WADApracticelist, ""));

What's that -1 doing in the OR clause of the query? I suspect if should something like practice_id2.

The other problem is that the second argument to GetSQLValueString() is an empty string in all three cases. Assuming that all three values are numbers, you should put int between the quotes:

  GetSQLValueString($Parampractice_id_WADApracticelist, "int"),
  GetSQLValueString($Parampractice_id2_WADApracticelist, "int"),
  GetSQLValueString($ParamSessionpractice_id_WADApracticelist, "int"));

You should be able to rebuild the code to get it to work, but if you're not confident working with code, you might be better off rebuilding the page from scratch. Something has gone badly wrong with the way the recordset has been built or edited.