PHP Parse error: syntax error, unexpected T_VARIABLE

Reply

Join Date: Sep 2008
Posts: 1
Reputation: srisree is an unknown quantity at this point 
Solved Threads: 0
srisree srisree is offline Offline
Newbie Poster

PHP Parse error: syntax error, unexpected T_VARIABLE

 
0
  #1
Sep 24th, 2008
Hello

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

  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
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,478
Reputation: cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about 
Solved Threads: 136
cwarn23's Avatar
cwarn23 cwarn23 is offline Offline
Nearly a Posting Virtuoso

Re: PHP Parse error: syntax error, unexpected T_VARIABLE

 
1
  #2
Sep 24th, 2008
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
  1. <?php
The only possible error I could see on line one (if you have an odd server) is removing the letters
  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.
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 213
Reputation: nikesh.yadav is an unknown quantity at this point 
Solved Threads: 17
nikesh.yadav's Avatar
nikesh.yadav nikesh.yadav is offline Offline
Posting Whiz in Training

Re: PHP Parse error: syntax error, unexpected T_VARIABLE

 
0
  #3
Sep 24th, 2008
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
Help as an alias

I think programming is great................
Tour Travel weblink by me and about Tour ,
Go To My Home Page and I m in Webdevelopment.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 31
Reputation: srilakshmitr7 is an unknown quantity at this point 
Solved Threads: 2
srilakshmitr7's Avatar
srilakshmitr7 srilakshmitr7 is offline Offline
Light Poster

Re: PHP Parse error: syntax error, unexpected T_VARIABLE

 
1
  #4
Sep 24th, 2008
I think there is problem in the directory path once check that if its ok ignore this
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 2
Reputation: Franky_Fr is an unknown quantity at this point 
Solved Threads: 0
Franky_Fr Franky_Fr is offline Offline
Newbie Poster

Re: PHP Parse error: syntax error, unexpected T_VARIABLE

 
0
  #5
Sep 24th, 2008
Hello ! I try this script too, and it works very well ! I think the probleme is out there !
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 1
Reputation: olammieConcept is an unknown quantity at this point 
Solved Threads: 0
olammieConcept olammieConcept is offline Offline
Newbie Poster

Re: PHP Parse error: syntax error, unexpected T_VARIABLE

 
0
  #6
Aug 21st, 2009
$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';
}

?>
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,478
Reputation: cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about 
Solved Threads: 136
cwarn23's Avatar
cwarn23 cwarn23 is offline Offline
Nearly a Posting Virtuoso

Re: PHP Parse error: syntax error, unexpected T_VARIABLE

 
0
  #7
Aug 21st, 2009
Originally Posted by olammieConcept View Post
$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:
  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. ?>
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 40
Reputation: phpbeginners is an unknown quantity at this point 
Solved Threads: 3
phpbeginners phpbeginners is offline Offline
Light Poster

Re: PHP Parse error: syntax error, unexpected T_VARIABLE

 
0
  #8
Aug 22nd, 2009
Originally Posted by srisree View Post
Hello

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

  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.

  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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC