This topic is locked

Broken View Page, possibly due to WHERE in Lookup

12/6/2006 12:51:21 PM
PHPRunner General questions
G
GeddyLee author

My view page is breaking on me, the cause is missing double quotes in the php page. I can fix it manually but when I rebuild it breaks again. If any one can help me out it would be much appreciated because this page will be rebuilt several times before I can finally leave it alone (if ever).
Here are the error messages:

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in C:\filePath\phprunnerpage_view.php on line 50
Parse error: parse error, unexpected ')' in C:\filePath\phprunnerpage_view.php on line 50
So let's check out that error: (line 50 in bold)

/////////////////////////////////////////////

// FieldX -

$value="";

if(strlen($data["FieldX"]))

{

$strdata = make_db_value("FieldX",$data["FieldX"]);

$LookupSQL="SELECT ";

$LookupSQL.="`FieldX`";

$LookupSQL.=" FROM `Table` WHERE `FieldX` = " . $strdata;

$LookupSQL.=" and (".\"FieldX like 'ARS%'\".")";

LogInfo($LookupSQL);

$rsLookup = db_query($LookupSQL,$conn);

if($lookuprow=db_fetch_numarray($rsLookup))

$value=ProcessLargeText($lookuprow[0],"","",MODE_VIEW);

else

$value=ProcessLargeText(GetData($data,"FieldX", ""),"field=FieldX".$keylink,MODE_VIEW);

}

else

$value="";

$smarty->assign("show_FieldX",$value);

Now If I replace line fifty with: $LookupSQL.=" and ("."\"FieldX like 'ARS%'\"".")";

it all works fine and dandy. However, when rebuilding it will revert to the old problem.
I'm not sure why it wants to do all this fancy SQL Querying for this field in the view (because all other fields just call GetData() ) but I am ASSUMING that it is due to my using a lookup wizard for this field on the Add and Edit pages with the where clause of

"FieldX like 'ARS%'". Which makes the lookup wizard work just fine and dandy.
The only other place I use the WHERE clause is in the sql edit page of PHPRunner. Which is pretty standard and uses the same syntax.

SELECT

--field list

FROM `Table`

WHERE `FieldX` like 'ARS%';
I know this is long, and maybe confusing, but if anyone's got any ideas how I can make this work correctly, even with a rebuild, I would certainly appreciate it a lot.
-Brent

Sergey Kornilov admin 12/6/2006

Backslashes are not required here

$LookupSQL.= " and (FieldX like 'ARS%')";
G
GeddyLee author 12/7/2006

Backslashes are not required here


$LookupSQL.= " and (FieldX like 'ARS%')";


You're absolutely right, and that's an even better fix to the code than what I had,

However, whether I fix the code your way or mine, it's going to get reset when I rebuild it (I tested it to be double sure).

That code is generated by PHPRunner, not written by me.
And this Issue is "Definitely" caused due to my use of a lookup wizard where I search Table, link by Id, and display by Name using the WHERE clause of "and FieldX like 'ARS%'". PHPRunner is creating the backslashes to escape the quotes that I put into the dialog box for the lookup wizard on the add and edit pages. And it's doing it improperly (so it seems, maybe I'm doing something improperly). However if I do not use the quotes in the dialog box, than my lookup wizard doesn't work.
I say "Definitely" because I use the same WHERE clause in a Different lookup wizard for a Different field and get the same error on the view page.
Am I dealing with a bug? or is there something I could be doing wrong? Or is there some way I could trick php runner into working the right way?
Many Thanks,

-Brent

Alexey admin 12/7/2006

Brent,
thank you for pointing me to this bug.

We'll fix it in the next update of PHPRunner.
To get your pages working modify view.php file in C:\Program Files\PHPRunner3.1\source folder.

Find this line there:

$LookupSQL.=" and (".##EditFormatObj.pLookupObj.strWhere s##.")";

and replace it with:

$LookupSQL.=" and (".##EditFormatObj.pLookupObj.strWhere##.")";

G
GeddyLee author 12/7/2006

Brent,

thank you for pointing me to this bug.

We'll fix it in the next update of PHPRunner.


Hey No Problem,
Thanks a lot for the help, seems to work beautifully. I honestly wasn't sure it was a bug, I figured I screwed something up still being new to both php and phprunner. heh heh.
Anyway, thanks again, and keep up the good work.

-Brent