php191919 Posted January 21, 2007 Share Posted January 21, 2007 Hello,I am a newbie to php and am trying to use a simple php linking script. I am getting this error and I know it is a formatting problem but I have no idea what character (s) might be causing it. I have included the error and the full page code below; The url of my page is host4cash.net/resources.php. Any help appreciated, Coreyna Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/host4cas/public_html/resources.php on line 17[code]<?php/*<--- BEGIN MY LINK HELPER CODE --->Making modifications to this code can cause your links page to stop working. Please only makemodifications where modifications are allowed. Being that this is a free service, we do not havethe resources to help you debug any changes you may have made. If you do run into problems withthis code, log into your account and download the original again.*/$OnCat = @$_GET["cid"];if ($OnCat == "") {$OnCat = "0";} //Set to Main Directory Pageif (!is_numeric($OnCat)) { Response.$Status="301 Moved Permanently"; Response.AddHeader "Location", "/";}//You may name your links page anything you want. But for your links page to work correctly//you must provide us with the name of your links page (without the '.php' extension).$PageName = "resources"; // change this value to match your [PageName].php links page//You may modify the following variable to change how many columns your directory displays.//By default this value is set to show 2 columns, but you may show as few as 1 column or//as many as 4. Valid values (1,2,3,4)$DirectoryCols = 2; // change this value to adjust how many columns your main directory page displays//You may modify the following variable to display your links on a single page instead of//directory style. This is a convenient way to display your links if you have fewer than 40.$ShowAsSinglePage = 0; // change this value to 1 if you want a single page, or 0 for directory$RequestPage = "http://www.mylinkhelper.com/bin/dynfetch.asp?id=7BC5F411-C799-4DD8-9D17-B398A473B76A&pagename=".$PageName."&cid=".$OnCat."&dircols=".$DirectoryCols."&single=".$ShowAsSinglePage;Set $serverXMLHTTP = Server.CreateObject("Msxml2.ServerXMLHTTP");$serverXMLHTTP.$Open "GET", $RequestPage, False;$serverXMLHTTP.$Send;$htmlCode = $serverXMLHTTP.$ResponseText;$GetLinks = $htmlCode;if (instr(1,$GetLinks, "<!--ERROR") != 0) { Response.$Status="301 Moved Permanently"; Response.AddHeader "Location", "/";}//Get The Page Title$lLoc = instr(1,$GetLinks, "|");if ($lLoc != 0) { $sTitle = left($GetLinks, $lLoc - 1); $GetLinks = right($GetLinks, strlen($GetLinks) - $lLoc);}if ($OnCat == "0") { //This value is the title for your main directory page and can be modified $sTitle = "Sell it yourself";}//<--- END MY LINK HELPER CODE --->?><title><?=$sTitle?></title><?=$GetLinks?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/35057-parse-error-unexpected-t_constant_-encapsed_string/ Share on other sites More sharing options...
Ninjakreborn Posted January 21, 2007 Share Posted January 21, 2007 [code]<?php/*<--- BEGIN MY LINK HELPER CODE --->Making modifications to this code can cause your links page to stop working. Please only makemodifications where modifications are allowed. Being that this is a free service, we do not havethe resources to help you debug any changes you may have made. If you do run into problems withthis code, log into your account and download the original again.*/$OnCat = $_GET["cid"];if ($OnCat == "") {$OnCat = "0";} //Set to Main Directory Pageif (!is_numeric($OnCat)) { Response.$Status="301 Moved Permanently"; Response.AddHeader "Location", "/";}//You may name your links page anything you want. But for your links page to work correctly//you must provide us with the name of your links page (without the '.php' extension).$PageName = "resources"; // change this value to match your [PageName].php links page//You may modify the following variable to change how many columns your directory displays.//By default this value is set to show 2 columns, but you may show as few as 1 column or//as many as 4. Valid values (1,2,3,4)$DirectoryCols = 2; // change this value to adjust how many columns your main directory page displays//You may modify the following variable to display your links on a single page instead of//directory style. This is a convenient way to display your links if you have fewer than 40.$ShowAsSinglePage = 0; // change this value to 1 if you want a single page, or 0 for directory$RequestPage = "http://www.mylinkhelper.com/bin/dynfetch.asp?id=7BC5F411-C799-4DD8-9D17-B398A473B76A&pagename=".$PageName."&cid=".$OnCat."&dircols=".$DirectoryCols."&single=".$ShowAsSinglePage;Set $serverXMLHTTP = Server.CreateObject("Msxml2.ServerXMLHTTP");$serverXMLHTTP.$Open "GET", $RequestPage, False;$serverXMLHTTP.$Send;$htmlCode = $serverXMLHTTP.$ResponseText;$GetLinks = $htmlCode;if (instr(1,$GetLinks, "<!--ERROR") != 0) { Response.$Status="301 Moved Permanently"; Response.AddHeader "Location", "/";}//Get The Page Title$lLoc = instr(1,$GetLinks, "|");if ($lLoc != 0) { $sTitle = left($GetLinks, $lLoc - 1); $GetLinks = right($GetLinks, strlen($GetLinks) - $lLoc);}if ($OnCat == "0") { //This value is the title for your main directory page and can be modified $sTitle = "Sell it yourself";}//<--- END MY LINK HELPER CODE --->?><title><?=$sTitle?></title><?=$GetLinks?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/35057-parse-error-unexpected-t_constant_-encapsed_string/#findComment-165417 Share on other sites More sharing options...
fert Posted January 21, 2007 Share Posted January 21, 2007 [code]$serverXMLHTTP.$Open "GET", $RequestPage, False;[/code]that looks like Ajax, not PHP Quote Link to comment https://forums.phpfreaks.com/topic/35057-parse-error-unexpected-t_constant_-encapsed_string/#findComment-165418 Share on other sites More sharing options...
Ninjakreborn Posted January 21, 2007 Share Posted January 21, 2007 Response.$Status="Yes, I never saw anything like that in PHP before. Quote Link to comment https://forums.phpfreaks.com/topic/35057-parse-error-unexpected-t_constant_-encapsed_string/#findComment-165422 Share on other sites More sharing options...
bibby Posted January 21, 2007 Share Posted January 21, 2007 [b]Response.AddHeader "Location", "/";[/b]You have no operator.[b]Response.AddHeader = "Location", "/";[/b] ? Quote Link to comment https://forums.phpfreaks.com/topic/35057-parse-error-unexpected-t_constant_-encapsed_string/#findComment-165519 Share on other sites More sharing options...
php191919 Posted January 22, 2007 Author Share Posted January 22, 2007 Hi Guys, I appreciate the responses. I made the change recommended by Bibby. No luck but I did get a different error message, which might help.The error is; 'Parse error: syntax error, unexpected T_STRING in /home/propnow/public_html/resources.php on line 8'I have included the fresh code below; (Also I removed all the comments to unclutter the code)Again, any help much appreciated. I'm trying to nut it out but not really getting anywhere. Cheers, Coreyna[code]<?php$OnCat = @$_GET["cid"];if ($OnCat == "") {$OnCat = "0"; if (Not is_numeric($OnCat)) { Response.$Status="301 Moved Permanently"; Response.AddHeader "Location", "/"; ?}$PageName = "resources"; $DirectoryCols = 2; $ShowAsSinglePage = 0; $RequestPage = "http://www.mylinkhelper.com/bin/dynfetch.asp?id=7BC5F411-C799-4DD8-9D17-B398A473B76A&pagename=".$PageName."&cid=".$OnCat."&dircols=".$DirectoryCols."&single=".$ShowAsSinglePage;Set $serverXMLHTTP = Server.CreateObject("Msxml2.ServerXMLHTTP");$serverXMLHTTP.$Open "GET", $RequestPage, False;$serverXMLHTTP.$Send;$htmlCode = $serverXMLHTTP.$ResponseText;$GetLinks = $htmlCode;if (instr(1,$GetLinks, "<!--ERROR") != 0) { Response.$Status="301 Moved Permanently"; Response.AddHeader "Location", "/";}$lLoc = instr(1,$GetLinks, "|");if ($lLoc != 0) { $sTitle = left($GetLinks, $lLoc - 1); $GetLinks = right($GetLinks, strlen($GetLinks) - $lLoc);}if ($OnCat == "0") { $sTitle = "Sell it yourself";}?><title><?=$sTitle?></title><?=$GetLinks?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/35057-parse-error-unexpected-t_constant_-encapsed_string/#findComment-166183 Share on other sites More sharing options...
kenrbnsn Posted January 22, 2007 Share Posted January 22, 2007 Names like "Response.$status" are illegal in PHP. It looks like you are trying to combine PHP and Javascript syntax.Ken Quote Link to comment https://forums.phpfreaks.com/topic/35057-parse-error-unexpected-t_constant_-encapsed_string/#findComment-166282 Share on other sites More sharing options...
trq Posted January 22, 2007 Share Posted January 22, 2007 It is actually some sort of php/asp (vbscript) hybrid. Quote Link to comment https://forums.phpfreaks.com/topic/35057-parse-error-unexpected-t_constant_-encapsed_string/#findComment-166296 Share on other sites More sharing options...
php191919 Posted January 22, 2007 Author Share Posted January 22, 2007 Hi again Guys, thanks for the responses. The code is working fine now after making some adjustments, in particular removing the "Response.$status" bit. Again thanks for your help, I've posted the working code below.[code]<?php/*<--- BEGIN MY LINK HELPER CODE --->Making modifications to this code can cause your links page to stop working. Please only makemodifications where modifications are allowed. Being that this is a free service, we do not havethe resources to help you debug any changes you may have made. If you do run into problems withthis code, log into your account and download the original again.*/$OnCat = @$_GET["cid"];if ($OnCat == "") {$OnCat = "0";} //Set to Main Directory Page//You may name your links page anything you want. But for your links page to work correctly//you must provide us with the name of your links page (without the '.php' extension).$PageName = "resources"; // change this value to match your [PageName].php links page//You may modify the following variable to change how many columns your directory displays.//By default this value is set to show 2 columns, but you may show as few as 1 column or//as many as 4. Valid values (1,2,3,4)$DirectoryCols = 2; // change this value to adjust how many columns your main directory page displays//You may modify the following variable to display your links on a single page instead of//directory style. This is a convenient way to display your links if you have fewer than 40.$ShowAsSinglePage = 0; // change this value to 1 if you want a single page, or 0 for directory$file = file("http://www.mylinkhelper.com/bin/phpdynfetch.asp?id=7BC5F411-C799-4DD8-9D17-B398A473B76A&pagename=".$PageName."&cid=".$OnCat."&dircols=".$DirectoryCols."&single=".$ShowAsSinglePage);if ($OnCat == "0") { //This value is the title for your main directory page and can be modified $sTitle = "My Link Helper"; $GetLinks = $file[0];} else {$iPos = strpos($file[0], "|");$sTitle = substr($file[0],0,$iPos);$GetLinks = substr($file[0],$iPos + 1,strlen($file[0]));}//<--- END MY LINK HELPER CODE --->?><!--Place the following code into the location of your webpage template that you want yourdirectory to be displayed, it will assume the link syles and sizes you have definedin your stylesheet.Also, don't forget to use the "sTitle" variable to customize the page!Please delete this comment when you implement your links directory.--><title><?=$sTitle;?></title><?=$GetLinks;?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/35057-parse-error-unexpected-t_constant_-encapsed_string/#findComment-166761 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.