Forum Moderators: coopster

Message Too Old, No Replies

Help with (error, unexpected T_VARIABLE )

         

McClain

10:38 pm on Oct 6, 2005 (gmt 0)



Hi everyone, i could do with some help if that would be ok...

Let me show you the error i get

error, unexpected T_VARIABLE in /home2/lfcsite/public_html/site/modules/Forums/admin/admin_forums.php on line 674

This is line 674

WHERE cat_id = " $new_cat, forum_parent = $new_parent;

and this is the code above and below it from one section to the other, the full section...

case 'modcat':
// Modify a category in the DB
$sql = "UPDATE " . CATEGORIES_TABLE . "
SET cat_title = '" . str_replace("\'", "''", $HTTP_POST_VARS['cat_title']) . "'
WHERE cat_id = " $new_cat, forum_parent = $new_parent;

Any help in finding what this is would be greatly apreciated

[edited by: jatar_k at 10:46 pm (utc) on Oct. 6, 2005]
[edit reason] removed large amount of code [/edit]

jatar_k

10:49 pm on Oct 6, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld McClain,

I edited your code a bit as there was a lot there and most of it seemed unnecessary ;)

when I turn your query into a sungle line it looks like this

$sql = "UPDATE " . CATEGORIES_TABLE . "SET cat_title = '" . str_replace("\'", "''", $HTTP_POST_VARS['cat_title']) . "' WHERE cat_id = " $new_cat, forum_parent = $new_parent;

I hate that multi line syntax, it just messes people up.

When I look at that you have mismatched quotes in there but I don't really know how to fix it

WHERE cat_id = " $new_cat, forum_parent = $new_parent;

the problem begins right where the comma is, everything before that is right

grandpa

8:12 am on Oct 7, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi McClain

I thought I'd toss my hat in the ring and give this a try. I took a guess and added the AND condition to the WHERE clause. Anyway, here goes..

$sql = "UPDATE CATEGORIES_TABLE SET cat_title = ' . str_replace(\"\'\", \"''\", $HTTP_POST_VARS['cat_title']) . '
WHERE cat_id = '$new_cat' && forum_parent = '$new_parent' ";

The portion of this that I am most unsure of is the value of cat_title in the SET clause.

cat_title = ' . str_replace("\'", "''", $HTTP_POST_VARS['cat_title']) . '

In my experience the quotes (") will need to be escaped (\). It's my feeling right now that those unescaped quotes will cause you problems. So maybe this is the correct expression..

cat_title = ' . str_replace(\"\'\", \"''\", $HTTP_POST_VARS['cat_title']) . '

As I mentioned earlier, your WHERE clause appears to be missing a condition.

WHERE cat_id = " $new_cat, forum_parent = $new_parent;

My solution was to make this an AND condition. It could be an OR, but I don't know that.

WHERE cat_id = '$new_cat' && forum_parent = '$new_parent'

As I was working thru this I noticed the missing apostrophes and closing quote. The first step in checking this was to ensure that the entire UPDATE statement was enclosed in quotes, and that each value was enclosed in apostrophies. Thus:

"UPDATE blah ";

cat_title = ' . str_replace(\"\'\", \"''\", $HTTP_POST_VARS['cat_title']) . '

cat_id = '$new_cat'

forum_parent = '$new_parent'

Hope this helps.