943,712 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 9213
  • PHP RSS
Sep 24th, 2008
0

PHP Parse error: syntax error, unexpected T_VARIABLE

Expand Post »
Hello

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

PHP Syntax (Toggle Plain Text)
  1. <?php
  2.  
  3. $dir=opendir("data");
  4. while ($file=readdir($dir)){
  5. if(substr($file, -3) == "xml"){
  6. print 'data/'.$file.'|';
  7. }
  8. }
  9. closedir($dir);
  10. ?>

Need your suggestions to solve this problom

regards
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
srisree is offline Offline
1 posts
since Sep 2008
Sep 24th, 2008
1

Re: PHP Parse error: syntax error, unexpected T_VARIABLE

Quote ...
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 Syntax (Toggle Plain Text)
  1. <?php
The only possible error I could see on line one (if you have an odd server) is removing the letters
PHP Syntax (Toggle Plain Text)
  1. 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.
Sponsor
Featured Poster
Reputation Points: 410
Solved Threads: 258
Occupation: Genius
cwarn23 is offline Offline
3,004 posts
since Sep 2007
Sep 24th, 2008
0

Re: PHP Parse error: syntax error, unexpected T_VARIABLE

Quote ...
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
Reputation Points: 15
Solved Threads: 21
Posting Whiz in Training
nikesh.yadav is offline Offline
219 posts
since Feb 2008
Sep 24th, 2008
1

Re: PHP Parse error: syntax error, unexpected T_VARIABLE

I think there is problem in the directory path once check that if its ok ignore this
Reputation Points: 16
Solved Threads: 2
Light Poster
srilakshmitr7 is offline Offline
32 posts
since Aug 2008
Sep 24th, 2008
0

Re: PHP Parse error: syntax error, unexpected T_VARIABLE

Hello ! I try this script too, and it works very well ! I think the probleme is out there !
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Franky_Fr is offline Offline
2 posts
since Sep 2008
Aug 21st, 2009
0

Re: PHP Parse error: syntax error, unexpected T_VARIABLE

$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';
}

?>
Reputation Points: 10
Solved Threads: 0
Newbie Poster
olammieConcept is offline Offline
1 posts
since Aug 2009
Aug 21st, 2009
0

Re: PHP Parse error: syntax error, unexpected T_VARIABLE

$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:
php Syntax (Toggle Plain Text)
  1. $connection = mysql_connect($host,$usernamee,$passwordd) or die ('Could not connect to server.');
  2. $db = mysql_select_db($database,$connection) or die ('Could not select database.');
  3. $sqlerror = mysql_error();
  4.  
  5. $fName=mysql_real_escape_string($fName);
  6. $emaill=mysql_real_escape_string($emaill);
  7. $commentt=mysql_real_escape_string($commentt);
  8. $datee=mysql_real_escape_string($datee);
  9. $sqlinsert = "INSERT INTO usercomments(namee, emailaddress, comments, datesent) VALUES ('$fName', '$emaill', '$commentt', '$datee')";
  10.  
  11. $sqlinsertt = mysql_query($sqlinsert) or die ('Could not insert record');
  12.  
  13. if($sqlinsertt)
  14. {
  15. echo '<br><br>RECORD INSERTED SUCCESSFULLY <br>';
  16. }
  17.  
  18. else
  19. {
  20. echo '<br>Record cannot be inserted with Shipper Login:<br> ';
  21. //echo 'error$sqlerror';
  22. }
  23.  
  24. ?>
Sponsor
Featured Poster
Reputation Points: 410
Solved Threads: 258
Occupation: Genius
cwarn23 is offline Offline
3,004 posts
since Sep 2007
Aug 22nd, 2009
0

Re: PHP Parse error: syntax error, unexpected T_VARIABLE

Click to Expand / Collapse  Quote originally posted by srisree ...
Hello

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

PHP Syntax (Toggle Plain Text)
  1. <?php
  2.  
  3. $dir=opendir("data");
  4. while ($file=readdir($dir)){
  5. if(substr($file, -3) == "xml"){
  6. print 'data/'.$file.'|';
  7. }
  8. }
  9. closedir($dir);
  10. ?>

Need your suggestions to solve this problom

regards


try to use getcwd.

PHP Syntax (Toggle Plain Text)
  1.  
  2. $dirPath = getcwd(); Gets the current working directory
  3. $thePath = $dirPath.'/data/';
  4. $dir=opendir($thePath);
Last edited by phpbeginners; Aug 22nd, 2009 at 12:12 am.
Reputation Points: 12
Solved Threads: 32
Posting Whiz in Training
phpbeginners is offline Offline
226 posts
since Jul 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: get_browser().....error
Next Thread in PHP Forum Timeline: Parse error: syntax error, unexpected T_VARIABLE in





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC