Forum Moderators: coopster

Message Too Old, No Replies

T_String error

         

naveenmedia

2:12 am on Jun 14, 2004 (gmt 0)

10+ Year Member



Hi all, newbie here (to the board and to PHP MySQL).

I'm attempting to follow Dreamweaver MX's tutorial on how to connect to a MySQL database. Everything was going good (got the testing server set up, etc.), until I tried to preview a page in the browser. I got the following error:

Parse error: parse error, unexpected T_STRING in c:\inetpub\wwwroot\TestSite1\comments-add.php on line 1

Line 1 reads:

<?xml version="1.0" encoding="iso-8859-1"?>

What is wrong with this? I don't see anything missing. I'm receiving the same error on another page, for the same line of code (but on line 24, rather than 1).

Any help?

inwebsys

3:42 am on Jun 14, 2004 (gmt 0)

10+ Year Member



I think this is due to the '<?' at the beginning of the XML declaration. The PHP interpreter is seeing this as the beginning of a block of php code.

This behavior can be disabled in php.ini. If you don't have access to your php.ini file on the webserver, it may be ok to just take these lines out.

httpwebwitch

3:42 am on Jun 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



replace those lines with


<?php print("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>");?>

what's happening is the PHP parser is seeing the "<?" in the xml declaration and interprets it as PHP code. The code above will solve the confusion.

naveenmedia

7:41 pm on Jun 14, 2004 (gmt 0)

10+ Year Member



httpwebwitch,

That line of code worked great. Thanks!