Searching and sorting problems: how can a dating site search members arrange invisible members behind image members. at the end, I added the order by avatarflag desc statement. search error: Parse error: syntax error, unexpected T_STRING, expecting ')' in E: \ PHPnow-1.5.6 \ htdocs \ source \ service \ index \ service. user. php on line 147
The error line is the last line: order by avatarflag desc. who can help you see the error above? The search code is as follows:
Public function validSearch ()
{
$ Args = array ();
$ Countwhere = "";
$ S_searchtype = XRequest: getargs ("s_searchtype ");
$ S_sex = XRequest: getint ("s_sex ");
$ S_sage = XRequest: getint ("s_sage ");
$ S_eage = XRequest: getint ("s_eage ");
$ S_dist1 = XRequest: getint ("s_dist1 ");
$ S_dist2 = XRequest: getint ("s_dist2 ");
$ S_dist3 = XRequest: getint ("s_dist3 ");
$ S_lovesort = XRequest: getint ("s_lovesort ");
$ S_sheight = XRequest: getint ("s_sheight ");
$ S_eheight = XRequest: getint ("s_eheight ");
$ S_ssalary = XRequest: getint ("s_ssalary ");
$ S_esalary = XRequest: getint ("s_esalary ");
$ S_sedu = XRequest: getint ("s_sedu ");
$ S_eedu = XRequest: getint ("s_eedu ");
If ($ s_searchtype = "adv ")
{
$ S_marry = XRequest: getcomints ("s_marry ");
$ S_havechild = XRequest: getcomints ("s_havechild ");
}
Else
{
$ S_marry = XRequest: getargs ("s_marry ");
$ S_havechild = XRequest: getargs ("s_havechild ");
}
$ S_house = XRequest: getint ("s_house ");
$ S_car = XRequest: getint ("s_car ");
$ S_avatar = XRequest: getint ("s_avatar ");
$ Args = array (
"S_sex" => $ s_sex,
"S_sage" => $ s_sage,
"S_eage" => $ s_eage,
"S_dist1" = >$ s_dist1,
"S_dist2" = >$ s_dist2,
"S_dist3" = >$ s_dist3,
"S_lovesort" => $ s_lovesort,
"S_sheight" => $ s_sheight,
"S_eheight" => $ s_eheight,
"S_ssalary" => $ s_ssalary,
"S_esalary" => $ s_esalary,
"S_sedu" => $ s_sedu,
"S_eedu" = >$ s_eedu,
"S_marry" => $ s_marry,
"S_havechild" => $ s_havechild,
"S_house" => $ s_house,
"S_car" => $ s_car,
"S_avatar" => $ s_avatar
);
$ SQL = "";
If (0 <$ s_sex)
{
$ SQL. = "AND v. gender = '". $ s_sex ."'";
$ Countwhere. = "AND ps. gender = '". $ s_sex ."'";
}
If (0 <$ s_sage & 0 <$ s_eage)
{
$ Year = date ("Y", time ());
$ Sageline = $ year-$ s_eage;
$ Eageline = $ year-$ s_sage;
$ SQL. = "AND p. ageyear> =". $ sageline. "AND p. ageyear <={$ eageline }";
$ Countwhere. = "AND ps. ageyear> =". $ sageline. "AND ps. ageyear <= {$ eageline }";
}
If (0 <$ s_dist1)
{
$ SQL. = "AND p. provinceid = '". $ s_dist1 ."'";
$ Countwhere. = "AND ps. provinceid = '". $ s_dist1 ."'";
}
If (0 <$ s_dist2)
{
$ SQL. = "AND p. cityid = '". $ s_dist2 ."'";
$ Countwhere. = "AND ps. cityid = '". $ s_dist2 ."'";
}
If (0 <$ s_dist3)
{
$ SQL. = "AND p. distid = '". $ s_dist3 ."'";
$ Countwhere. = "AND ps. distid = '". $ s_dist3 ."'";
}
If (0 <$ s_lovesort)
{
$ SQL. = "AND p. lovesort = '". $ s_lovesort ."'";
$ Countwhere. = "AND ps. lovesort = '". $ s_lovesort ."'";
}
If (0 <$ s_sheight & 0 <$ s_eheight)
{
$ SQL. = "AND p. height> =". $ s_sheight. "AND p. height <= {$ s_eheight }";
$ Countwhere. = "AND ps. height> =". $ s_sheight. "AND ps. height <= {$ s_eheight }";
}
If (0 <$ s_ssalary & 0 <$ s_esalary)
{
$ SQL. = "AND p. salary> =". $ s_ssalary. "AND p. salary <= {$ s_esalary }";
$ Countwhere. = "AND ps. salary> =". $ s_ssalary. "AND ps. salary <={$ s_esalary }";
}
If (0 <$ s_sedu & 0 <$ s_eedu)
{
$ SQL. = "AND p. education> =". $ s_sedu. "AND p. education <={$ s_eedu }";
$ Countwhere. = "AND ps. education> =". $ s_sedu. "AND ps. education <={$ s_eedu }";
}
If (TRUE === XValid: iscomchar ($ s_marry ))
{
$ SQL. = "AND p. marrystatus IN (". $ s_marry .")";
$ Countwhere. = "AND ps. marry IN (". $ s_marry .")";
}
If (TRUE === XValid: iscomchar ($ s_havechild ))
{
$ SQL. = "AND p. childrenstatus IN (". $ s_havechild .")";
$ Countwhere. = "AND ps. child IN (". $ s_havechild .")";
}
If (0 <$ s_house)
{
$ SQL. = "AND p. housing = '". $ s_house ."'";
$ Countwhere. = "AND ps. house = '". $ s_house ."'";
}
If (0 <$ s_car)
{
$ SQL. = "AND p. caring = '". $ s_car ."'";
$ Countwhere. = "AND ps. car = '". $ s_car ."'";
}
If ($ s_avatar = 1)
{
$ SQL. = "AND v. avatar! = ''AND v. avatarflag = '1 '";
$ Countwhere. = "AND ps. avatar = '1 '";
}
Return array (
$ SQL,
$ Countwhere,
$ Args
Order by avatarflag desc
);
}
Reply to discussion (solution)
Check the actual SQL statement in code debugging.
If ($ s_avatar = 1)
{
$ SQL. = "AND v. avatar! = ''AND v. avatarflag = '1 '";
$ Countwhere. = "AND ps. avatar = '1 '";
}
Avatarflag is available only when this condition is met.
Order by avatarflag. do you want to add an alias: v.
It is best to type out the complete SQL statement.
Let's see where the program is wrong. website run error: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting T_STRING or T_VARIABLE or '$' in E: \ PHPnow-1.5.6 \ htdocs \ source \ action \ index \ action. user. php on line 51
The code in line 51st is unset ("service ");
The code is as follows:
Private function _ unset ()
{
Unset ("service ");
}
Private function _ getListItems ()