Forum Moderators: coopster

Message Too Old, No Replies

Keep getting a Parse error: syntax error, unexpected T STRING

         

Kiss_me

2:48 am on Nov 3, 2006 (gmt 0)

10+ Year Member



Ok Im a n00b when it comes to php so I was trying something.
I wanted to add a rss feed into a php file ok, i have the rss feed code and I went into the php file and put the code where i wanted it.

This is the code I put in -


<table style="width:100%;" class="mainmenu5" cellspacing="0" cellpadding="4">
<tr>
<td style="font-size:8pt;text-align:center;">
<b>Top 3 Msn Song Downloads</b>
<?php
define('MSIFETCH_DIR', '/home/topuk/public_html/music');
require_once(MSIFETCH_DIR.'/msifetch.inc');
echo get_html('a:18:{s:6:"active";a:1:{i:0;s:57: "http://music.msn.com/services/rss.aspx?chartname=topsongs"; }s:8:"inactive";a:1:{i:0;s:42:"http://movies.go.com/xml/rss/boxoffice.xml"; }s:7:"feedurl";s:7:"http://";s:8:"textarea";s:94: "http://news.search.yahoo.com/usns/ynsearch/categories/news_story_search_rss/index.html?p=AUDIO"; s:9:"textarea3";s:68:"http://news.google.com/news?hl=en&ned=us&ie=UTF-8&output=rss&q=AUDIO"; s:8:"rss_desc";s:1:"1";s:12:"rss_max_news";s:1:"2";s:13:"rss_title_len";s:1:"5";s:20: "rss_feed_title_color";s:0:"";s:10:"disp_width";s:3:"200";s:15:"disp_background"; s:5:"WHITE";s:13:"disp_bord_col";s:7:"#000000";s:15:"disp_bord_thick";s:1:"0";s:15: "disp_bord_style";s:4:"None";s:13:"disp_text_col";s:7:"#CC0000";s:14:"disp_text_font";s:22: "Comic Sans, sans-serif";s:14:"disp_text_size";s:2:"15";s:6:"submit";s:14:"Fetch RSS Feed";}');
?>
</td>
</tr>
</table>
</td>
</tr>
</table>
<br/>

And it gives me this error -
Parse error: syntax error, unexpected T_STRING in /home/topuk/public_html/music/index.php on line 788

What do I do to fix it?

Thanks

[edited by: jatar_k at 4:21 am (utc) on Nov. 3, 2006]
[edit reason] sidescroll [/edit]

Kiss_me

2:50 am on Nov 3, 2006 (gmt 0)

10+ Year Member



Sorry I forgot to add in the error code lines

Ok line 788 is this -

define('MSIFETCH_DIR', '/home/topuk/public_html/music');

eelixduppy

3:30 am on Nov 3, 2006 (gmt 0)



Welcome to WebmasterWorld!

There is no error on the line provided, however I do notice that you are using a function get_html? This isn't a function, so unless you have it defined somewhere it's going to give you an error, probably something along the lines of the error you are getting since it comes within an echo.

Adding this to the script will let you know if the function is defined or not:


echo '</pre>';
print_r([url=http://us2.php.net/manual/en/function.get-defined-functions.php]get_defined_functions[/url]());
echo '</pre>';

Good luck!

Kiss_me

3:42 am on Nov 3, 2006 (gmt 0)

10+ Year Member



Hi thanks for the welcome,

where do i put that?

Seriously im new at this lol.

eelixduppy

3:48 am on Nov 3, 2006 (gmt 0)



<?php
define('MSIFETCH_DIR', '/home/topuk/public_html/music');
require_once(MSIFETCH_DIR.'/msifetch.inc');
echo '</pre>';
print_r(get_defined_functions());
echo '</pre>';
/*
echo get_html('a:18:{s:6:"active";a:1:{i:0;s:57:"http://music.msn.com/services/rss.aspx?chartname=topsongs";} s:8:"inactive";a:1: {i:0;s:42:"http://movies.go.com/xml/rss/boxoffice.xml";} s:7:"feedurl";s:7:"http://";s:8:"textarea";s:94: "http://news.search.yahoo.com/usns/ynsearch/categories/news_story_search_rss/index.html?p=AUDIO"; s:9:"textarea3";s:68:"http://news.google.com/news?hl=en&ned=us&ie=UTF-8&output=rss&q=AUDIO"; s:8:"rss_desc";s:1:"1";s:12:"rss_max_news";s:1:"2";s:13:"rss_title_len";s:1:"5";s:20: "rss_feed_title_color";s:0:"";s:10:"disp_width";s:3:"200";s:15:"disp_background"; s:5:"WHITE";s:13:"disp_bord_col";s:7:"#000000";s:15:"disp_bord_thick";s:1:"0";s:15: "disp_bord_style";s:4:"None";s:13:"disp_text_col";s:7:"#CC0000";s:14:"disp_text_font";s:22:"Comic Sans, sans-serif";s:14:"disp_text_size";s:2:"15";s:6:"submit";s:14:"Fetch RSS Feed";}');
*/
?>

This comments out the get_html function.

[edited by: jatar_k at 4:20 am (utc) on Nov. 3, 2006]
[edit reason] holy sidescroll batman! [/edit]

Kiss_me

3:52 am on Nov 3, 2006 (gmt 0)

10+ Year Member



Ok still getting a error on that same line.

Ill explain more of what I am doing.

basically I have a php page with music content on, I have installed a script which allows me to get feeds and gives me the php code to put in the page. Thats the code I am tryinng to insert.

I thought it might of been because it has the <?php &?> tags in which are meant to be used only at the start and end of the page corect?

so e.g.

this is what my page looks like

<?php

bla bla

some ph code bla bla

<?php

my feed code the code i am inserting!

?>

some more content on the page

?> end of page.

eelixduppy

4:01 am on Nov 3, 2006 (gmt 0)



It should look like this:

<?php

bla bla

some ph code bla bla

my feed code the code i am inserting!

some more content on the page

?>end of page.

Once you open the php, <?php, everything that comes after it is parsed as PHP code. If you want to close it, ?>, you can do that, but you don't want to put php tags within php tags.

Here is a common case:


<?php
//php code goes here
?>
Something HTML
<?php
//some more php code on the same page
?>

You can even do something along these lines, which happens all the time:


<input type="text" name="product" value="<?php echo $product_name;?>" />

I hope this makes it a little clearer?

Kiss_me

4:07 am on Nov 3, 2006 (gmt 0)

10+ Year Member



A little but can you show me how I would put that code into the page?

I tried removing the tags but it still didn't work.

Thanks for your help so far though.

eelixduppy

4:14 am on Nov 3, 2006 (gmt 0)




can you show me how I would put that code into the page?

I'm not exactly sure what you mean by that code. The code that you posted in your first message is fine, unless the get_html function isn't defined in the included file. If you have other php tags that enclose the whole body of the code that you gave me in your first post, then you want to remove those instead. Basically you only want PHP to be between <?php and?>, no HTML--by itself that is. It's perfectly fine to echo it.

Kiss_me

4:18 am on Nov 3, 2006 (gmt 0)

10+ Year Member



Ok sorry maybe im not explaining my self well enough. I have my php page with all my content on etc.

I want to add the feed, and the feed 'code' is generated by this program I am using.

the code it give me is -

<?php
define('MSIFETCH_DIR', '/home/topuk/public_html/msifetch');
require_once(MSIFETCH_DIR.'/msifetch.inc');
echo get_html('a:18:{s:6:"active";a:1:{i:0;s:57: "http://music.msn.com/services/rss.aspx?chartname=topsongs"; }s:8:"inactive";a:1:{i:0;s:42: "http://movies.go.com/xml/rss/boxoffice.xml"; }s:7:"feedurl";s:7:"http://";s:8:"textarea";s:94: "http://news.search.yahoo.com/usns/ynsearch/categories/news_story_search_rss/index.html?p=AUDIO"; s:9:"textarea3";s:68: "http://news.google.com/news?hl=en&ned=us&ie=UTF-8&output=rss&q=AUDIO"; s:8:"rss_desc";s:1:"1";s:12:"rss_max_news";s:1:"2";s:13:"rss_title_len";s:1:"5";s:20: "rss_feed_title_color";s:0:"";s:10:"disp_width";s:3:"200";s:15:"disp_background"; s:5:"WHITE";s:13:"disp_bord_col";s:7:"#000000";s:15:"disp_bord_thick";s:1:"0";s:15: "disp_bord_style";s:4:"None";s:13:"disp_text_col";s:7:"#CC0000";s:14:"disp_text_font"; s:22:"Comic Sans, sans-serif";s:14:"disp_text_size";s:2:"15";s:6:"submit";s:14:"Fetch RSS Feed";}');
?>

So I put that where I wnated it in my PHP page, and it doesnt work because liek you said the start and end tags. So I removed the <?php &?> tags from the code and put it where I wanted it in my PHP page but I still get an error.........
Im confused. :(

[edited by: jatar_k at 4:22 am (utc) on Nov. 3, 2006]
[edit reason] sidescroll [/edit]

eelixduppy

4:25 am on Nov 3, 2006 (gmt 0)



I think having you read the documentation [us3.php.net] on this will help you understand. As for including this generated code into your php page, it should look something like this:

<?php
//some php code that you may already have in here
?>
<table style="width:100%;" class="mainmenu5" cellspacing="0" cellpadding="4">
<tr>
<td style="font-size:8pt;text-align:center;">
<b>Top 3 Msn Song Downloads</b>
<?php
define('MSIFETCH_DIR', '/home/topuk/public_html/music');
require_once(MSIFETCH_DIR.'/msifetch.inc');
echo get_html('a:18:{s:6:"active";a:1:{i:0;s:57:"http://music.msn.com/services/rss.aspx?
chartname=topsongs";}s:8:"inactive";a:1:{i:0;s:42:"http://movies.go.com/xml/rss/
boxoffice.xml";}s:7:"feedurl";s:7:"http://";s:8:"textarea";s:94:"http://
news.search.yahoo.com/usns/ynsearch/categories/news_story_search_rss/index.html?
p=AUDIO";s:9:"textarea3";s:68:"http://news.google.com/news?hl=en&ned=us&ie=UTF-8
&output=rss&q=AUDIO";s:8:"rss_desc";s:1:"1";s:12:"rss_max_news";s:1:"2";s:13:"
rss_title_len";s:1:"5";s:20:"rss_feed_title_color";s:0:"";s:10:"disp_width";s:3:
"200";s:15:"disp_background";s:5:"WHITE";s:13:"disp_bord_col";s:7:"#000000";s:15:
"disp_bord_thick";s:1:"0";s:15:"disp_bord_style";s:4:"None";s:13:"disp_text_col";s:
7:"#CC0000";s:14:"disp_text_font";s:22:"Comic Sans, sans-serif";s:14:"disp_text_size";s:2:"15";s:6:"submit";s:14:"Fetch RSS Feed";}');
?>
</td>
</tr>
</table>
</td>
</tr>
</table>
<br/>
<?php
//some more php code that you may have in here
?>

I'm sorry if this doesn't answer you question. I'm thinking it does, but then again it's getting late after a long day; my brain might not be functioning ;)

>>holy sidescroll batman!

HAHA jatar Thanks!

Kiss_me

4:33 am on Nov 3, 2006 (gmt 0)

10+ Year Member



Na that still didn't work, if you want to take a look for your self your more than welcome to.

I have uploaded the php file as a txt document.
Where the FEED CODE needs to be I have clearly stated with
#*$!#*$!#*$!#*$!#*$! CODE NEEDS TO GO HERE! #*$!#*$!#*$!#*$!#*$!#*$!X

And thhis code needs to go there, edit it as you may as long as it shows the darn feed lol.

 <?php 
define('MSIFETCH_DIR', '/home/topuk/public_html/music');
require_once(MSIFETCH_DIR.'/msifetch.inc');
echo get_html('a:18:{s:6:"active";a:1:{i:0;s:57:"http://music.msn.com/services/rss.aspx?
chartname=topsongs";}s:8:"inactive";a:1:{i:0;s:42:"http://movies.go.com/xml/rss/
boxoffice.xml";}s:7:"feedurl";s:7:"http://";s:8:"textarea";s:94:"http://
news.search.yahoo.com/usns/ynsearch/categories/news_story_search_rss/index.html?
p=AUDIO";s:9:"textarea3";s:68:"http://news.google.com/news?hl=en&ned=us&ie=UTF-8
&output=rss&q=AUDIO";s:8:"rss_desc";s:1:"1";s:12:"rss_max_news";s:1:"2";s:13:"
rss_title_len";s:1:"5";s:20:"rss_feed_title_color";s:0:"";s:10:"disp_width";s:3:
"200";s:15:"disp_background";s:5:"WHITE";s:13:"disp_bord_col";s:7:"#000000";s:15:
"disp_bord_thick";s:1:"0";s:15:"disp_bord_style";s:4:"None";s:13:"disp_text_col";s:
7:"#CC0000";s:14:"disp_text_font";s:22:"Comic Sans, sans-serif";s:14:"disp_text_size";s:2:"15";s:6:"submit";s:14:"Fetch RSS Feed";}');
?>

If you could so kindly have a stab at it, that would be appreciated!

I look forward to your response in the morning, its 4.35am here Uk :S

Thanks, Again

[edited by: jatar_k at 4:46 am (utc) on Nov. 3, 2006]
[edit reason] no urls thanks [/edit]

eelixduppy

4:44 am on Nov 3, 2006 (gmt 0)



Ok. Firstly, personal urls are not allowed, but luckily for you I found your problem with it.

You are defining a large string variable, $music. Change your code to this, and it should work:


...blah blah blah
<table style="width:100%;" class="mainmenu5" cellspacing="0" cellpadding="4">
<tr>
<td style="font-size:8pt;text-align:center;">
<b>Top 3 Song Downloads</b>
</td>
</tr>
</table>
</td>
</tr>
</table>
<br/>
<table style="width:100%;" cellspacing="8" cellpadding="4">
<tr>
<td style="font-size:7pt;" class="border2">
<td style="font-size:8pt;text-align:center;">';

define('MSIFETCH_DIR', '/home/topuk/public_html/music');
require_once(MSIFETCH_DIR.'/msifetch.inc');
$music .= get_html('a:18:{s:6:"active";a:1:{i:0;s:57: "http://music.msn.com/services/rss.aspx?chartname=topsongs"; }s:8:"inactive";a:1:{i:0;s:42:"http://movies.go.com/xml/rss/boxoffice.xml"; }s:7:"feedurl";s:7:"http://";s:8:"textarea";s:94: "http://news.search.yahoo.com/usns/ynsearch/categories/news_story_search_rss/index.html?p=AUDIO"; s:9:"textarea3";s:68:"http://news.google.com/news?hl=en&ned=us&ie=UTF-8&output=rss&q=AUDIO"; s:8:"rss_desc";s:1:"1";s:12:"rss_max_news";s:1:"2";s:13:"rss_title_len";s:1:"5";s:20: "rss_feed_title_color";s:0:"";s:10:"disp_width";s:3:"200";s:15:"disp_background"; s:5:"WHITE";s:13:"disp_bord_col";s:7:"#000000";s:15:"disp_bord_thick";s:1:"0";s:15: "disp_bord_style";s:4:"None";s:13:"disp_text_col";s:7:"#CC0000";s:14:"disp_text_font";s:22: "Comic Sans, sans-serif";s:14:"disp_text_size";s:2:"15";s:6:"submit";s:14:"Fetch RSS Feed";}');
$music .= '</td>
</tr>
</table>
</td>
<br /><br />
<div style="text-align:center;">
'.html_adds("").'
</div>
</td>
</tr>
</table>';

What was happening was the quotes in the line:


define('MSIFETCH_DIR', '/home/topuk/public_html/music');

were conflicting with those that were part of the variable($music) declaration. The solution above should work, although the code seems a bit...messy :)

Kiss_me

9:47 am on Nov 3, 2006 (gmt 0)

10+ Year Member



I get no error, but yet it still doesn't work lol.

I think ill just give up.

So sorry about the url thingy. :(

eelixduppy

11:19 am on Nov 3, 2006 (gmt 0)



I'm sorry you cannot get it to work :( It may be due to the rest of your script not functioning properly, which I didn't take a look at last night.

I guess this leaves you with two options:

1) Get a new RSS Feed script from one of the various script repositories(sourceforge.net, hotscripts.com, etc...)

2) Refer to this thread on Troubleshooting [webmasterworld.com] and figure out where the problem lies in your current script.

In either case, I wish you luck!

Kiss_me

4:36 am on Nov 4, 2006 (gmt 0)

10+ Year Member



Thanks for your help, I have found a new rss feeder and all works now.

Damn faulty software. :S

Thank you for your time, much appreciated!