Monday, July 27, 2009

PHP Parse error: syntax error, unexpected T_STRING in C:\Inetpub\wwwroot\example.php on line 8?

Hi


I get the above error in the following code, the line with the error seems to be:


$test-%26gt; sql = "SELECT body FROM test.articles";





full code:


%26lt;?php


phpinfo();





include("C:\Inetpub\wwwroot\my_pagina_...


$_SERVER['DOCUMENT_ROOT'] = "C:\Inetpub\wwwroot\";





$test = new MyPagina;


$test-%26gt; sql = "SELECT body FROM test.articles";


$result = $test-%26gt;get_page_result();


$num_rows = $test-%26gt;get_page_num_rows();


$nav_links = $test-%26gt;navigation(" | ", "currentStyle");


$nav_info = $test-%26gt;page_info("to");


$simple_nav_links = $test-%26gt;back_forward_link();


$total_recs = $test-%26gt;get_total_rows();


?%26gt;





when i refresh the example.php page i get the following error:





Error in my_thread_global_end(): 1 threads didn't exit PHP Parse error: syntax error, unexpected T_STRING in C:\Inetpub\wwwroot\example.php on line 8





global variables parameter in php.ini is on, so i dont understand why it doesnt work.





I am a php newbie,


Thanks in advance





kind regards





Tovia Singer

PHP Parse error: syntax error, unexpected T_STRING in C:\Inetpub\wwwroot\example.php on line 8?
There's a space in "$test-%26gt; sql" when it should be "$test-%26gt;sql." Remove it. :-)





#########


Update:





Okay, since that doesn't fix the error, the error is triggered before it gets to that part! (The space thing would have also caused an error.)





In the line before it:


$test = new MyPagina;


Try adding parentheses:


$test = new MyPagina();





I didn't think that's necessary, but it's worth a shot.





###########


Update 2:





Maybe the problem is on the line we can't see?


include(...
Reply:Hello jam,





Error in my_thread_global_end(): 1 threads didn't exit PHP Parse error: syntax error, unexpected T_STRING in C:\Inetpub\wwwroot\example.php on line 8





The my_thread_global_end() error message above refers to one of two things (and hopefully not both!). The problem is either your PHP script or your MySQL version. If it's your PHP code, the problem is that somewhere mysql_thread_init() is being called to create a new MySQL thread but mysql_thread_end() is not being called to close it when it's not needed anymore. MySQL won't automatically close this for you and therefore throws the error that you see.





Try checking your mypagina class for the mysql_thread_init() function and see if the thread is being correctly closed. If you can't find it, at the end of the method which calls the MySQL query, add a mysql_thread_end() function call anyway, to make sure the thread is closed. Just because you can't find any calls to mysql_thread_init() doesn't mean it's not being used: it's also called by some other core PHP functions.





If it is your MySQL version, you will need to apply this patch: http://lists.mysql.com/commits/25160. Or just upgrade to the latest stable release.





For more information there is a long discussion on this error/bug at http://bugs.mysql.com/bug.php?id=25621. It will most likely be worth you reading this.





The 'PHP Parse error: syntax error, unexpected T_STRING' error message may or may not be related: it usually refers to a PHP command declaration not being following by a semi colon (all lines in PHP must be finished by a semi colon (;)).





And BTW, you don't necessarily need to follow class instantiations with paranthesis' (mypagina or mypagina() are the same unless the mypagina class has a constructor which requires arguments).





Hope it helps,


Refined.
Reply:$test-%26gt; sql = "SELECT body FROM test.articles";





it should be


$test-%26gt;sql = "SELECT `body` FROM test";
Reply:Remove space here: $test-%26gt; sql


~~~~~


No comments:

Post a Comment