Forum Moderators: coopster

Message Too Old, No Replies

unexpected T CASE

ASP converted to PHP syntax error

         

Ann_G

5:28 pm on Dec 21, 2006 (gmt 0)

10+ Year Member



I converted an ASP script using the ASP Translator that I found on the web. Of course it couldn't be that easy (copy, paste and press a button). The PHP script doesn't work.

I'm know a little php but not enough to figure out why I get this error message.

Parse error: syntax error, unexpected T_CASE in /home/slnlibrary/public_html/scripts/Search.php on line 8

Any idea would be very appreciated.

RonPK

5:37 pm on Dec 21, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



T_CASE refers to a
case
thingy inside a switch [php.net] construction. Maybe the preceding
case
thingy is not ended properly with a
break
statement?

Perhaps you could post the first 10 lines of the script; that might clarify things.

jatar_k

5:56 pm on Dec 21, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



what is the code on line8 or maybe post the whole switch.

Ann_G

6:31 pm on Dec 28, 2006 (gmt 0)

10+ Year Member



I'm very sorry I didn't respond earlier but the holidays came in- between. Anyhow I'm still working on this script that I had translated from ASP to PHP.
I made some of my own changes and now I get this message:

Parse error: syntax error, unexpected T_VARIABLE, expecting T_STRING on line 3

Help is appreciated greatly. My script might be way off and beyond fixing. Let me know. I won't take offense. But if it's pretty close it might be worthwhile for me to keep pluggin away. I appreciate your comments even if you can't give me a quick solution.

This is my script
(I'm trying to make three searches in one, which we used to have in ASP. Maybe it's not even possible in PHP?)

<?php
//Get Form Info
function $str_SearchArg=Request("PACTERMS");
$str_SearchArg=str_replace( " ", "+",$str_SearchArg);

$str_SearchScope=Request("searchscope");

switch ($str_SearchScope)
{
case "sitesearch";


//Atomz
$str_SearchString="http://search.atomz.com/search/?"."sp-q=".$str_SearchArg."&sp-a=sp10028b7a&sp-p=all&sp-f=ISO-8859-1";

break;
case "catalog";

$str_SearchType="GENERAL^SUBJECT^GENERAL^^words+or+phrase";

$str_SearchString="http://64.107.155.140/uhtbin/cgisirsi/x/LINCOLNWD/0/57/5?";
$str_SearchString=$str_SearchString."searchdata1=".$str_SearchArg;
$str_SearchString=$str_SearchString."&srchfield1=".$str_SearchType;
$str_SearchString=$str_SearchString."&library=LINCOLNWD";
$str_SearchString=$str_SearchString."&user_id=lnkibistro";
$str_SearchString=$str_SearchString."&password=ibistro";

break;

case "Internet";

//Google
$str_SearchString="http://www.google.com/search?q=".$str_SearchArg."&safe=active"."&num=20";
break;
}
?>

Part of my html form looks like this
<input type="radio" name="searchscope" value="Internet" checked="checked" />
Google

<input type="radio" name="searchscope" value="sitesearch" />
This Site

<input type="radio" name="searchscope" value="catalog" />
Library's Catalog<br />

<input type="text" name="PACTERMS" size="42" />

<input type="submit" class="BUTTON" value="Search" />
</form>

jatar_k

9:55 pm on Dec 28, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



this line is the problem

function $str_SearchArg=Request("PACTERMS");

there shouldn't be a $ there, you should have the function name

I am guessing you could remove the word function as I don't see that you have a function there

there is also another syntax error

case "sitesearch";

your case should end with : not ;

Ann_G

10:26 pm on Dec 28, 2006 (gmt 0)

10+ Year Member



Thanks! I'll try it and let you know.