vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Noobie Problems, unexpected T_STRING (https://vborg.vbsupport.ru/showthread.php?t=180263)

Kinneas 05-23-2008 02:01 PM

Noobie Problems, unexpected T_STRING
 
I'm still very new to this, so sorry if the answer is obvious.

I'm just trying to create a simple plugin which will auto insert into postbit. The aim at the moment is just to put something after the MSN/AIM icons. I've been able to insert just text, but not a lot more.

The plugin code is here:

PHP Code:

eval('$templateblah = "' fetch_template('testblah') . '";'); 

$find '<div>$post[icqicon] $post[aimicon] $post[msnicon] $post[yahooicon] $post[skypeicon]';
$replace "$templateblah";

$vbulletin->templatecache['postbit'] = str_replace($find$find $replace$vbulletin->templatecache['postbit']); 

Now in the template "testblah", if I just put random text in it's fine, but if I try and do any html with hyperlinking (Eg, <a href="blah">Hello</a>, it throws a wobbly and gives me lines of :

Parse error: syntax error, unexpected T_STRING in /home/mrmb/public_html/testforum/includes/class_postbit.php(292) : eval()'d code on line 71

It works without the quotation marks (Eg, <a href=blah>Hello</a>) but surely that's not the way it should be done?

Can anyone help?

Lynne 05-23-2008 02:20 PM

You need to, um, I forget what it's called (edit: the term I was looking for was 'escape'), but you put a backslash before any quotes. So:

HTML Code:

< a href=\"url/blah.php\">This is a link</a>
However, I have never had to do that. Let me compare your code to something I've done. (just a sec)

edit: Hmmm, I haven't done anything quite like you (using replace). But, try this (single quotes) and see if you don't have to escape your template quotes that way:
PHP Code:

$replace '$templateblah'


Kinneas 05-23-2008 02:23 PM

Quote:

Originally Posted by Lynne (Post 1529016)
You need to, um, I forget what it's called (edit: the term I was looking for was 'escape'), but you put a backslash before any quotes. So:

HTML Code:

< a href=\"url/blah.php\">This is a link</a>
However, I have never had to do that. Let me compare your code to something I've done. (just a sec)

Thanks for your help :)

--------------- Added [DATE]1211556583[/DATE] at [TIME]1211556583[/TIME] ---------------

Quote:

Originally Posted by Lynne (Post 1529016)
edit: Hmmm, I haven't done anything quite like you (using replace). But, try this (single quotes) and see if you don't have to escape your template quotes that way:
PHP Code:

$replace '$templateblah'


When I try that, nothing appears at all, not even errors.

Is there a better way of doing this anyway? I'm all ears if so :)

MoT3rror 05-23-2008 03:21 PM

If you are just assigning that variable to another variable use this code.
PHP Code:

$variable2 $variable

Also here is the difference between quotes.
PHP Code:

$variable 'hello world';
echo 
'$variable'// $variable
echo "$variable"//hello world 

Replace:
PHP Code:

$replace "$templateblah"

with

PHP Code:

$replace $templateblah



All times are GMT. The time now is 04:44 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01060 seconds
  • Memory Usage 1,734KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_html_printable
  • (7)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete