Copy link to clipboard
Copied
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();
}
Copy link to clipboard
Copied
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'); ?><?phpif (!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:
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
David, thanks for this. I've decided that starting over is the best way forward and although I've had a copy of your Foundation PHP for Dreamweaver 8 book sitting on the side of my desk for some time, I'm actually going to take some time out to start working through it and see if I can get some of this stuff clearer in my head. Appreciate your assistance and input.
Regards,
Jeff
Find more inspiration, events, and resources on the new Adobe Community
Explore Now