Hello

PHP Parse error: syntax error, unexpected T_VARIABLE in /home/mysite/public_html/guestbook/getdrawings.php on line 1

<?php

$dir=opendir("data");
	while ($file=readdir($dir)){
		if(substr($file, -3) == "xml"){
						print 'data/'.$file.'|';
		}
	}
	closedir($dir);
?>

Need your suggestions to solve this problom

regards

PHP Parse error: syntax error, unexpected T_VARIABLE in /home/mysite/public_html/guestbook/getdrawings.php on line 1

I have tested the provided code both as it currently is and with many different modifications and from what I have found, although with single character changes errors can be made, I don't think that with this code alone that a T_variable error could occure. Especially with line 1 being

<?php

The only possible error I could see on line one (if you have an odd server) is removing the letters

php

from line 1. Other than that I would say that a global variable such as ini settings may be interfering with the script.
So basically I just couldn't reproduce the error and was working for me fine.

commented: Yes..Same for me also... +2

Hello

PHP Parse error: syntax error, unexpected T_VARIABLE in /home/mysite/public_html/guestbook/getdrawings.php on line 1

Dear sisree,

I try this script but show no error.
can u give me php.ini and server details

I think there is problem in the directory path once check that if its ok ignore this

commented: a thoughtfull.... +2

Hello ! I try this script too, and it works very well ! I think the probleme is out there !

$connection = mysql_connect($host,$usernamee,$passwordd) or die ('Could not connect to server.');
$db = mysql_select_db($database,$connection) or die ('Could not select database.');
$sqlerror = mysql_error();

//The next line is where the error is, please help me out....
$sqlinsert = "INSERT INTO usercomments(namee, emailaddress, comments, datesent) VALUES ('".$fName."', '".$emaill."', '".$commentt."', '"$datee."')";

$sqlinsertt = mysql_query($sqlinsert) or die ('Could not insert record');

if($sqlinsertt)
{
echo '<br><br>RECORD INSERTED SUCCESSFULLY <br>';
}

else
{
echo '<br>Record cannot be inserted with Shipper Login:<br> ';
//echo 'error$sqlerror';
}

?>

$connection = mysql_connect($host,$usernamee,$passwordd) or die ('Could not connect to server.');
$db = mysql_select_db($database,$connection) or die ('Could not select database.');
$sqlerror = mysql_error();

//The next line is where the error is, please help me out....
$sqlinsert = "INSERT INTO usercomments(namee, emailaddress, comments, datesent) VALUES ('".$fName."', '".$emaill."', '".$commentt."', '"$datee."')";

$sqlinsertt = mysql_query($sqlinsert) or die ('Could not insert record');

if($sqlinsertt)
{
echo '<br><br>RECORD INSERTED SUCCESSFULLY <br>';
}

else
{
echo '<br>Record cannot be inserted with Shipper Login:<br> ';
//echo 'error$sqlerror';
}

?>

First of all welcome to daniweb.
And did you not read my signature saying not to bump old topics. Also please use code tags as they can make it easier to read your post. As for your question, the following code should do the trick:

$connection = mysql_connect($host,$usernamee,$passwordd) or die ('Could not connect to server.'); 
$db = mysql_select_db($database,$connection) or die ('Could not select database.');
$sqlerror = mysql_error();

$fName=mysql_real_escape_string($fName);
$emaill=mysql_real_escape_string($emaill);
$commentt=mysql_real_escape_string($commentt);
$datee=mysql_real_escape_string($datee);
$sqlinsert = "INSERT INTO usercomments(namee, emailaddress, comments, datesent) VALUES ('$fName', '$emaill', '$commentt', '$datee')";

$sqlinsertt = mysql_query($sqlinsert) or die ('Could not insert record'); 

if($sqlinsertt)
{
echo '<br><br>RECORD INSERTED SUCCESSFULLY <br>';
}

else
{
echo '<br>Record cannot be inserted with Shipper Login:<br> ';
//echo 'error$sqlerror';
}

?>

Hello

PHP Parse error: syntax error, unexpected T_VARIABLE in /home/mysite/public_html/guestbook/getdrawings.php on line 1

<?php

$dir=opendir("data");
	while ($file=readdir($dir)){
		if(substr($file, -3) == "xml"){
						print 'data/'.$file.'|';
		}
	}
	closedir($dir);
?>

Need your suggestions to solve this problom

regards

try to use getcwd.

$dirPath = getcwd();  Gets the current working directory
$thePath = $dirPath.'/data/';
$dir=opendir($thePath);
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.