Hi people... ran some asp code thru a php translator and the php page displays nothing but this error message. I take out the php code and it displays. I've checked and rechecked and read tons of possible scenarios... but I don't see anything. Sometimes another set of eyes and an unmelted brain helps. Any ideas? LINE54 is actually LINE12 in this pasted code.

~ Tom

Parse error: parse error, unexpected T_VARIABLE in /vservers/magicwebs/htdocs/index_database.php on line 54

<?
//dim $DataConn, $cmdDC, $rsDC;
//dim $Item, $strVendorType;
//dim $iFieldCount, $iLoopVar;
 
$strVendorType = @$_GET["VendorType"];
//If strVendorType = "" Then strVendorType = "Miscellaneous"
//Response.write "user selected " & strVendorType & "<br>"
 
// Finally we've got all our info, now to the cool stuff
// Create and establish data connection
Set $DataConn = Server.CreateObject("ADODB.Connection");
$DataConn.ConnectionTimeout = 15;
$DataConn.$CommandTimeout = 30;
 
//Access connection code
$DataConn.$Open "DBQ=".Server.MapPath("database.mdb").";Driver={Microsoft Access Driver (*.mdb)}";
 
// Create and link command object to data connection then set attributes and SQL query
Set $cmdDC = Server.CreateObject("ADODB.Command");
$cmdDC.$ActiveConnection = $DataConn;
$cmdDC.$CommandText = "SELECT * FROM Vendors WHERE (VendorType = '".$strVendorType."');";
//Response.write cmdDC.CommandText
$cmdDC.$CommandType = 1;
 
// Create recordset and retrieve values using command object
Set $rsDC = Server.CreateObject("ADODB.Recordset");
// Opening record set with a forward-only cursor (the 0) and in read-only mode (the 1)
$rsDC.$Open $cmdDC, , 0, 1;
?>

<span class="bodyText"><B>Results of search for :: <?= $strVendorType ?> </B>
<hr size=1 noshade><p>
<?	Do While Not $rsDC.$EOF;
		echo "<b>Company: </b>".$rsDC["CompanyName"];
		echo " (".$rsDC["VendorType"].")<br>";
		echo "<b>City: </b>".$rsDC["City"]."<br>";
		echo "<b>State: </b>".$rsDC["ST"]."<br>";
		echo "<b>Address: </b>".$rsDC["Address"]."<br>";
		echo "<b>ZIP: </b>".$rsDC["Zip"]."<br>";
		echo "<b>Country: </b>".$rsDC["Country"]."<br>";
		echo "<b>Vendor Type: </b>".$rsDC["VendorType"]."<br>";
		echo "<b>URL: </b>"."<a href=http://www.".$rsDC["URL"]." target=_blank>"."<b>".$rsDC["URL"]."</b></a>"."<br>";
		echo "<b>Salutation: </b>".$rsDC["Salutation"]."<br>";
		echo "<b>First Name: </b>".$rsDC["FirstName"]."<br>";
		echo "<b>Last Name </b>".$rsDC["LastName"]."<br>";
		echo "<b>Professional Title: </b>".$rsDC["ProfessionalTitle"]."<br>";
		echo "<b>E-mail Address: </b>"."<a href=mailto:".$rsDC["EmailAddress"].">"."<b>".$rsDC["EmailAddress"]."</b></a>"."<br>";
		echo "<b>Main Phone: </b>".$rsDC["PhoneMain"]."<br>";
		echo "<b>Direct Phone: </b>".$rsDC["PhoneDirect"]."<br>";
		echo "<b>Fax Number: </b>".$rsDC["FaxNumber"]."<br>";
		echo "<b>Mobile Phone: </b>".$rsDC["PhoneMobile"]."<br>";
		//Response.Write "<b>Account Info.: </b>" & rsDC("AccountInfo") & "<br>"
		echo "<b>Payment Type: </b>".$rsDC["PaymentType"]."<br>";
		echo "<b>Notes: </b>".$rsDC["Notes"]."<br>";
		echo "<b>Last Modified: </b>".$rsDC["LastModifiedDate"]."<br><br>";
		echo "<b><a href=index.asp><b>Click here</b></a> to Search again.</b><br>";		
		echo "<p><hr size=1 noshade><p>";
		$rsDC.$MoveNext;
	Loop;
// Close Data Access Objects and free DB variables
$rsDC.Close;
Set $rsDC =  Nothing;
// can't do a "cmdDC.Close" !
Set $cmdDC = Nothing;
$DataConn.Close;
Set $DataConn = Nothing ?></span>

AFAIK "Set" is not a php command. I don't think the translator is very good.

AFAIK "Set" is not a php command. I don't think the translator is very good.

Now I get unexpected T_CONSTANT_ENCAPSED_STRING in /vservers/magicwebs/htdocs/index_database.php on line 58 which is actually ::

$DataConn = Server.CreateObject("ADODB.Connection");
Member Avatar for diafol

This is rubbish. I mean it doesn't look like php. Reminds me of VB.

Member Avatar for diafol

Did you notice the first comment in the list:

"This is an extremely helpful cross-reference. The only other thing I think you could add would be database functions like mysql_num_rows() (PHP) and the equivalent of while looping as related to $row["colname"] vs. connection.fields("colname") Keep expanding this! It'll make it so much easier for developers like myself to continue developing solid applications. Great work."

No DB function support.

If your commented line 53 was the bug then try the following.

<?
//dim $DataConn, $cmdDC, $rsDC;
//dim $Item, $strVendorType;
//dim $iFieldCount, $iLoopVar;
 
$strVendorType = @$_GET["VendorType"];
//If strVendorType = "" Then strVendorType = "Miscellaneous"
//Response.write "user selected " & strVendorType & "<br>"
 
// Finally we've got all our info, now to the cool stuff
// Create and establish data connection
Set $DataConn = Server.CreateObject("ADODB.Connection");
$DataConn.ConnectionTimeout = 15;
$DataConn.$CommandTimeout = 30;
 
//Access connection code
$DataConn.$Open "DBQ=".Server.MapPath("database.mdb").";Driver={Microsoft Access Driver (*.mdb)}";
 
// Create and link command object to data connection then set attributes and SQL query
Set $cmdDC = Server.CreateObject("ADODB.Command");
$cmdDC.$ActiveConnection = $DataConn;
$cmdDC.$CommandText = "SELECT * FROM Vendors WHERE (VendorType = '".$strVendorType."');";
//Response.write cmdDC.CommandText
$cmdDC.$CommandType = 1;
 
// Create recordset and retrieve values using command object
Set $rsDC = Server.CreateObject("ADODB.Recordset");
// Opening record set with a forward-only cursor (the 0) and in read-only mode (the 1)
$rsDC.$Open $cmdDC, , 0, 1;
?>
 
<span class="bodyText"><B>Results of search for :: <?= $strVendorType ?> </B>
<hr size=1 noshade><p>
<?	Do While Not $rsDC.$EOF;
		echo "<b>Company: </b>".$rsDC["CompanyName"];
		echo " (".$rsDC["VendorType"].")<br>";
		echo "<b>City: </b>".$rsDC["City"]."<br>";
		echo "<b>State: </b>".$rsDC["ST"]."<br>";
		echo "<b>Address: </b>".$rsDC["Address"]."<br>";
		echo "<b>ZIP: </b>".$rsDC["Zip"]."<br>";
		echo "<b>Country: </b>".$rsDC["Country"]."<br>";
		echo "<b>Vendor Type: </b>".$rsDC["VendorType"]."<br>";
		echo "<b>URL: </b>"."<a href=http://www.".$rsDC["URL"]." target=_blank>"."<b>".$rsDC["URL"]."</b></a>"."<br>";
		echo "<b>Salutation: </b>".$rsDC["Salutation"]."<br>";
		echo "<b>First Name: </b>".$rsDC["FirstName"]."<br>";
		echo "<b>Last Name </b>".$rsDC["LastName"]."<br>";
		echo "<b>Professional Title: </b>".$rsDC["ProfessionalTitle"]."<br>";
		echo "<b>E-mail Address: </b>"."<a href=mailto:".$rsDC["EmailAddress"].">"."<b>".$rsDC["EmailAddress"]."</b></a>"."<br>";
		echo "<b>Main Phone: </b>".$rsDC["PhoneMain"]."<br>";
		echo "<b>Direct Phone: </b>".$rsDC["PhoneDirect"]."<br>";
		echo "<b>Fax Number: </b>".$rsDC["FaxNumber"]."<br>";
		echo "<b>Mobile Phone: </b>".$rsDC["PhoneMobile"]."<br>";
		Response.Write "<b>Account Info.: </b>" & rsDC("AccountInfo") & "<br>";
		echo "<b>Payment Type: </b>".$rsDC["PaymentType"]."<br>";
		echo "<b>Notes: </b>".$rsDC["Notes"]."<br>";
		echo "<b>Last Modified: </b>".$rsDC["LastModifiedDate"]."<br><br>";
		echo "<b><a href=index.asp><b>Click here</b></a> to Search again.</b><br>";		
		echo "<p><hr size=1 noshade><p>";
		$rsDC.$MoveNext;
	Loop;
// Close Data Access Objects and free DB variables
$rsDC.Close;
Set $rsDC =  Nothing;
// can't do a "cmdDC.Close" !
Set $cmdDC = Nothing;
$DataConn.Close;
Set $DataConn = Nothing ?></span>

But I would like to say this it does not appear to be proper php. It looks like another kind of oop being directly copied into php with some adjustments. The main problem with the code is that the translator for this code did not use the right functions that are designed for the job. For example the mssql library. But that is just my two cents.

Member Avatar for diafol

Moral of the story... learn to code in the target language. These translators are more hassle than they're worth.

Moral of the story... learn to code in the target language. These translators are more hassle than they're worth.

microsoft stuff again failed. I converted the access db to MySQL so there will be no need to refer to any microsoft drivers etc in the code that failed as well. Was simply trying to save alot of time.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.