Unstoppable Domains

Parse error: Syntax error, unexpected T_IF in

Spaceship Spaceship
Watch

Amma

Established Member
Impact
8
Hi,

For some reason I get the below error. Can someone find where this is going wrong?

Parse error: syntax error, unexpected T_IF in /home/www/mydomain(.)com/page_search.php on line 8

Here is the code
PHP:
<?php

	+ // We urlencoded the whole search string so we need to
	+ // urldecode and convert it back to utf-8
	+ $id = $id === 0 ? '' : utf8_encode(urldecode($id));
	+

	if ($id != '' && !strstr($id, '|'))
	{
		$keywords = $db->real_escape_string(trim($id));
	}
Thanks
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
Missing ?> at the end of the code
 
1
•••
No,

Remove the + from your code. Replace them with //

Regards,
Peter
 
1
•••
Or just take them out entirely.
 
1
•••
Kath said:
Missing ?> at the end of the code


?> is not required at the end of a php scrpt. some people purposely leave them out as it can stop problems occuring
 
1
•••
peter@flexiwebhost said:
?> is not required at the end of a php scrpt. some people purposely leave them out as it can stop problems occuring
indeed! Those damn 'output started....' errors, ugh:td:
 
1
•••
your remarks are wrong.
php remarks are: /*whatever thing you write*/
or //whatever thing you write
 
1
•••
Kath said:
Missing ?> at the end of the code
?> is there, it is in end of the code

psalzmann said:
No,

Remove the + from your code. Replace them with //

Regards,
Peter
I will try to replace with // but it says the error in line 8. Is there any error in this line
PHP:
if ($id != '' && !strstr($id, '|'))
 
Last edited:
0
•••
Amma said:
?> is there, it is in end of the code


I will try to replace with // but it says the error in line 8. Is there any error in this line
PHP:
if ($id != '' && !strstr($id, '|'))
Man, first clean the code (correct the remarks). Them you should see an error report more acurate.
 
0
•••
rafaelrls said:
Man, first clean the code (correct the remarks). Them you should see an error report more acurate.
I tried both way as below and replacing // instead of + but the error is same
PHP:
<?php
/** We urlencoded the whole search string so we need to
  * urldecode and convert it back to utf-8
  */
  + $id = $id === 0 ? '' : utf8_encode(urldecode($id));
  +

		if ($id != '' && !strstr($id, '|'))
	{
		$keywords = $db->real_escape_string(trim($id));
	}
I'm not a coder and I couldn't catch the coder who created this. Any help will be highly apreciated.
 
0
•••
there doesnt seem to be anything wrong with the if statement but until you remove the + signs the error messages are meaningless.

If you ask for advice and help why do you not follow the advice?
 
0
•••
psalzmann, rafaelrls and Peter McDonald thanks for all and also thanks to others who commented this thread.

The problem solved by removing the + and replacing //.
If you ask for advice and help why do you not follow the advice?
I tried immediately when I show psalzmann's comment but I replaced // for all 4 + as below
PHP:
<?php 

    // We urlencoded the whole search string so we need to 
    // urldecode and convert it back to utf-8 
    // $id = $id === 0 ? '' : utf8_encode(urldecode($id)); 
    //
Sorry I'm zero with PHP

After checking with some other PHP codes I tried replacing // first two lines then peter@flexiwebhost you remind me to try by removing the + in second and third line.
Corrected code
PHP:
<?php
/** We urlencoded the whole search string so we need to
  * urldecode and convert it back to utf-8
  */
   $id = $id === 0 ? '' : utf8_encode(urldecode($id));
  
		if ($id != '' && !strstr($id, '|'))
	{
		$keywords = $db->real_escape_string(trim($id));
	}
It's works fine. Rep added for all

Thanks again.
Amma
 
0
•••
Appraise.net
Unstoppable Domains
Domain Recover
DomainEasy โ€” Zero Commission
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back