Page 1 of 1

PHP5.SYN doesn't actually highlight anything

Posted: Sun Mar 16, 2008 9:02 am
by robert.ross
I've closed all open files.

I've gone through all of the document classes and removed *.php from all of them (it was the HTML class only).

I've created a new document class with the name PHP, included the *.php, *.inc and *.phps.

I've re-opened a PHP file and it still comes back with no colors.

While playing around with the .SYN file, I discovered that if you have anything in Keywords 3-6, it won't highlight anything. Is this normal? Has anyone else had this issue?

I'm running on Windows XP Pro w/SP2, and just updated to TextPad 5.2.0. I had thought updating would fix it, but I was clearly incorrect.

Any suggestions?

Posted: Sun Mar 16, 2008 4:19 pm
by Bob Hansen
1. Is the syntax file in the folder defined for syntax files?

2. Has the same syntax file been designated for the php class that you defined?

3. Is the file that you are checking really a member of the php classs, and not included in any other class also?

If you have anything in 3-6, then those keywords should also be highlighted according to the colors you have set for that class.

Posted: Sun Mar 16, 2008 6:46 pm
by robert.ross
Yes, it is in the folder defined for syntax files.

Yes, the syntax file has been designated for the class I created.

Yes, the file I'm checking is a member of the class, nor is it included in any other class (as I distinctly remember noting).

As for the highlighting, it doesn't work. I have no idea why - it just doesn't highlight anything at all (not even 1 & 2) if there's anything in 3-6. I can't explain why, which is why I posted this.

Posted: Sun Mar 16, 2008 7:49 pm
by MudGuard
as you don't show the file:

could it be a syntax error in the syntax file?

Posted: Sun Mar 16, 2008 8:14 pm
by robert.ross
It is the php5.syn file from the downloads page. I've not altered it in any way. Sorry, forgot to mention that.

Posted: Mon Mar 17, 2008 12:20 am
by Bob Hansen
Please provide some of the file that you are expecting to see highlighted.

Posted: Mon Mar 17, 2008 1:11 am
by robert.ross
This script is the one I expected to be highlighted. Even with the default settings in the colors for the class, nothing in this file was highlighted at all, not even in the blue default color. When I use the old PHP.syn file, some stuff is highlighted, but not all I would like.

That being said, I'm creating my own based on the PHP.syn highlight file. It works well so far, so I think I'll just keep going with that one and forget about php5.syn.

Thanks for all of your help.

Code: Select all

<?
	include("support.php");
	$sql = "SELECT `disc`.`title`,
CONCAT(`borrower`.`firstname`,' ',`borrower`.`lastname`) AS `name`,
`borrowed`, `returned`,
`transid`, `borrower`.`id` AS `bid`,
`disc`.`id` AS `did`
FROM `disc`, `borrower`, `lent`
				WHERE `disc`.`id` = `lent`.`disc`
				AND `borrower`.`id` = `lent`.`borrower` AND `lent`.`returned` IS NULL";
	$res = @mysql_query($sql);
	if ($res===false || mysql_num_rows($res)===0) {
		$entry = "<TD COLSPAN='4'>No records to list.</TD>\n";
	} else {
		$cnt = mysql_num_rows($res);
		$entry = '';
		//phpinfo();
		for ($i=0;$i<$cnt;$i++) {
			$row = mysql_fetch_array($res,MYSQL_ASSOC);
			$entry .= file_get_contents("templates/entry.html");
			$entry = str_replace("##title##",stripslashes($row['title']),$entry);
			$entry = str_replace("##borrower##",$row['name'],$entry);
			$entry = str_replace("##bid##",$row['bid'],$entry);
			$entry = str_replace("##borrowed##",$row['borrowed'],$entry);
			$entry = str_replace("##returned##",($row['returned']!=""?$row['returned']:"<A HREF='update.php?t=ci&rid=".$row['transid']."' STYLE='text-decoration: none'>Check In</A>"),$entry);
		}
	}
	$sheet = file_get_contents("templates/listing.html");
	$sheet = str_replace("##status##","Checked Out",$sheet);
	$sheet = str_replace("##entries##",$entry,$sheet);
	echo $sheet;
	include("templates/footer.html");
?>

Posted: Mon Mar 17, 2008 12:42 pm
by Sharbotcom
Robert:

Change the first line of your code to "<?php" from "<?". and it should be fine. The syntax start directive in the php5.syn file is "<?php" not "<?". You could modify the php5.syn file and change the syntax start directive to just "<?".

Bill

Posted: Mon Mar 17, 2008 7:49 pm
by MudGuard
Sharbotcom wrote:You could modify the php5.syn file and change the syntax start directive to just "<?".
I advise to use <?php as the <? needs short-tags enabled in the php.ini while <?php works independent of specific settings in the php.ini.

Posted: Wed Mar 19, 2008 3:41 am
by robert.ross
Thanks for all your assistance. Sharbotcom, I went with your option of changing the syntaxstart option. I wish I'd noticed that. I'm still learning the syntax codes and what all that stuff at the beginning of the file means.

Thanks everybody!

P.S. - Mudguard - I use <? because I invariably control my servers and if I happen to be writing a script for portability, I usually go with <?php, but since all of my stuff is in-house, I prefer the <?. It's good advice, however. :)