PDA

View Full Version : Noobie Problems, unexpected T_STRING


Kinneas
05-23-2008, 02:01 PM
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:

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:

< 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:
$replace = '$templateblah';

Kinneas
05-23-2008, 02:23 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:

< 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 1211556583 at 1211556583 ---------------

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:
$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.

$variable2 = $variable;


Also here is the difference between quotes.

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


Replace:

$replace = "$templateblah";


with


$replace = $templateblah;