PDA

View Full Version : Dealing With Conditions Errors Without a Condition?


TheMayhem
03-09-2009, 05:53 AM
So I assume I am going to learn something new today with vBulletin. I have a plugin that runs this wonderful query.

// Get Pay Per View Results
$ppv = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "ppv where id='1'");


And this query runs on a vBulletin global start. It works perfectly fine and I am able to retrieve certain parts of the table that I am selecting from. So I go to insert an array of data into the template and I try

$ppv[ppv_name]

And it works perfectly fine. So then I try and insert another part of the array to display for users which is

$ppv[1_wrestler1]

And the template errors start coming

The following error occurred when attempting to evaluate this template:

Parse error: syntax error, unexpected T_STRING, expecting ']' in /home/tmforum/public_html/includes/adminfunctions_template.php(3938) : eval()'d code on line 1

This is likely caused by a malformed conditional statement. It is highly recommended that you fix this error before continuing, but you may continue as-is if you wish.[/quote]

I could put this on line 1 or line 51 no matter what or any other part of that $ppv array that I try to insert and it gives errors gallore. So I guess my question is what in vBulletin or programming mechanics could cause this when there is no if statement in there and why would it only sound off the alarms for certain parts of the array even though all data type of that array are the same.

Dismounted
03-09-2009, 06:06 AM
Try:
{$ppv[1_wrestler1]}

Marco van Herwaarden
03-09-2009, 12:33 PM
You must enclose the key in double quotes if it starts with an integer or you will get a parse error.

TheMayhem
03-09-2009, 07:24 PM
You must enclose the key in double quotes if it starts with an integer or you will get a parse error.

I'm not really sure I follow what you mean. Could you give me an example?

Marco van Herwaarden
03-10-2009, 10:13 AM
$ppv["1_wrestler1"]

TheMayhem
03-10-2009, 11:25 PM
That gives you this:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/tmforum/public_html/includes/adminfunctions_template.php(3938) : eval()'d code on line 83

Dismounted
03-11-2009, 06:19 AM
That will not work in a template (quoting, I mean). Assign that value to another variable, and use that instead.