This topic is locked
[SOLVED]

 PHP Snippet - unexpected t string var

6/22/2011 2:57:10 AM
PHPRunner General questions
jwoker author

Trying to get the following to work as a PHP Snippet in the visual editor

$str = "";

$str.= "<FORM METHOD="LINK" ACTION=\"Dashboard_list.php?ctlSearchFor=".$_SESSION["users_userid"].

"&srchOptShowStatus=1&ctrlTypeComboStatus=0&srchWinShowStatus=0&a=

integrated&id=1&criteria=and&type1=&value11=".$_SESSION["users_userid"].

"&field1=staff_id&option1=Contains&not1=a=search&value=1\">".

$_SESSION["users_userid"]."><INPUT TYPE="submit" VALUE="my Staff Dash">

</FORM> ";

echo $str;


It produces this error:

Parse error: syntax error, unexpected T_STRING in /home/.../include/Dashboard_events.php on line
The specific line of the error is:

$str.= "<FORM METHOD="LINK" ACTION=\"Dashboard_list.php?ctlSearchFor=".$_SESSION["users_userid"].


Can someone help me with my error? (Does anyone else wish these search urls could be simplified..)

C
cgphp 6/22/2011

jwoker,
the right version of code is:

$str = "";

$str.= "<FORM METHOD=\"LINK\" ACTION=\"Dashboard_list.php?ctlSearchFor=".$_SESSION["users_userid"].

"&srchOptShowStatus=1&ctrlTypeComboStatus=0&srchWinShowStatus=0&a=

integrated&id=1&criteria=and&type1=&value11=".$_SESSION["users_userid"].

"&field1=staff_id&option1=Contains&not1=a=search&value=1\">".

$_SESSION["users_userid"]."<INPUT TYPE=\"submit\" VALUE=\"my Staff Dash\" />

</FORM>";

echo $str;


Cheers

CGphp

jwoker author 6/22/2011

Thank you for the help with the backslashes. I have further edited the code below but can't get it to work properly. When I click the button on my page there is some sort of refresh or activity in the browser but it does not filter the records shown based on the search I am trying to get it to perform.



$str = "";

$str.= "<FORM METHOD=\"LINK\" ACTION=\"Dashboard_list.php?ctlSearchFor=".$_SESSION["users_userid"].

"&srchOptShowStatus=1&ctrlTypeComboStatus=0&srchWinShowStatus=0&a=

integrated&id=1&criteria=and&type1=&value11=".$_SESSION["users_userid"].

"&field1=staff_id&option1=Contains&not1=a=search&value=1\"><INPUT TYPE=\"submit\" VALUE=\"my Staff Dash\">

</FORM> ";

echo $str;


When I put the following into my browser which has the session variable replaced with a value, "8", the page performs as I want. Also, when I put this in the browser address window it stays there - when I click the button on my list page the address/url does not change at all.



Dashboard_list.php?ctlSearchFor=8&srchOptShowStatus=1&ctrlTypeComboStatus=0&srchWinShowStatus=0&a=integrated&id=1&criteria=and&type1=&value11=8&field1=staff_id&option1=Contains&not1=a=search&value=1


My session variable is assigned in the List page: Before process event.
Any help getting this "search" button to work is appreciated.
Peter

C
cgphp 6/22/2011

jwoker,
to add custom field, take a look at this: http://xlinesoft.com/phprunner/docs/add_custom_field_to_form.htm
But, there are two fast solutions instead of using a form:

  1. using a input button with onclick event (<input type="button" value="..." onClick="location.href='Dashboard_list.php?ctlSearchFor.......'" />)
  2. using the insert button function in the visual editor. You have to set the session vars in the "Server" option and the location.href in the "Client After" option.
    It's easy!
    Cheers

    CGphp

jwoker author 6/22/2011

Thanks for your help CGphp!
Here is the present condition of my code, when I click the button the page seems to refresh but it does not change the url or the page. The url works when I substitute value for the variables still.

$str = "";

$str.= "<input type=\"button\" value=\"my Dash\" onclick=\"location.href='Dashboard_list.php?ctlSearchFor=".$_SESSION["users_userid"].

"&srchOptShowStatus=1&ctrlTypeComboStatus=0&srchWinShowStatus=0&a=

integrated&id=1&criteria=and&type1=&value11=".$_SESSION["users_userid"].

"&field1=staff_id&option1=Contains&not1=a=search&value=1'\"/>

";

echo $str;
C
cgphp 6/22/2011

jwoker,
the problem could be caused by line breaks. Try to write the $str on one line:

$str = "";

$str.= "<input type=\"button\" value=\"my Dash\" onclick=\"location.href='Dashboard_list.php?ctlSearchFor=".$_SESSION["users_userid"]."&srchOptShowStatus=1&ctrlTypeComboStatus=0&srchWinShowStatus=0&a=integrated&id=1&criteria=and&type1=&value11=".$_SESSION["users_userid"]."&field1=staff_id&option1=Contains&not1=a=search&value=1'\"/>";

echo $str;


Cheers

CGphp