|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[1998-05-08 15:57 UTC] jwalsh at verio dot net
The reproducible error
Parse error</b>: parse error, expecting `'}'' in <b>/home/virtual/celsoc/db/list.php3</b> on line <b>34</b><br>
occurs with the following code segment. It seems to be a problem with variable variables and arrays.
<SCRIPT LANGUAGE="PHP">
require("./inc/globalsettings.inc");
// HELP WANTED LISTING
if ($cmd == "wantedpost") {
$msg = "Employment Openings";
$dbTable = "HelpWanted";
// FIRST TWO ITEM VALS PASSED FROM PREVIOUS PAGE
$item = array("Region","Type","FirmName","Location","ShortDescrip");
$query = "SELECT _rowid,";
// HELP AVAILABLE LISTING
} elseif ($cmd = "availablepost") {
$msg = "Personnel Available";
$dbTable = "HelpAvailable";
// FIRST TWO ITEM VALS PASSED FROM PREVIOUS PAGE
$item = array("Region","License","Name","Location","ShortDescrip");
$query = "SELECT _rowid, ContactFirst || || ContactLast AS ";
}
$query .= "$item[0],$item[1],$item[2],$item[3],$item[4] ";
$query .= "FROM $dbTable ";
// MAX NUMBER OF ITEMS RETRIEVED AT ONCE
$startval = intval($next);
$maxquery = 15;
// BUILDING QUERY
for ($i=0, $qcount=0; $i<4; $i) {
if (strlen(${$item[$i]}) > 0) {
if ($qcount > 0) $query .= "AND ";
else $query .= "WHERE ";
if ($i == 3) $query .= "$item[3] LIKE '%${$item[3]}%' ";
else $query .= "$item[$i]='${$item[$i]}' ";
$qcount++;
}
}
$query .= "ORDER BY $item[0] LIMIT $startval,$maxquery";
// CONNECT TO DB AND PERFORM QUERY
echo $query;
mysql_connect($dbHost,$dbUser,$dbPwd);
$result = mysql($dbName,$query);
$num = mysql_NumRows($result);
</SCRIPT>
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 08 05:00:02 2025 UTC |
These variables are not supported within encapsulated strings. Variable expansion inside encapsulated strings is extremely limited in version 3.0, and as a rule of the thumb, only very simple variables are recognized. This will only be addressed in version 3.1. In the meantime, use the concatenation operator instead, e.g. "_text_".${...}."_text_"