PHP Problem

Discuss Programming
Post Reply
X11
guru
guru
Posts: 676
Joined: Sun Jan 19, 2003 11:09 pm
Location: Australia
Contact:

PHP Problem

Post by X11 » Sat Sep 17, 2005 4:55 pm

There is something wrong with this code, only I have no idea what.

Code: Select all

        $request = db_query("
                SELECT ID_MSG, ID_MEMBER
                FROM {$db_prefix}messages
                WHERE ID_TOPIC = $topic " . (isset($_REQUEST['only_attach']) && $_REQUEST['only_attach'])? 'AND ID_MSG IN (' . implode(',', $ID_MSG) . ')' : '') . "
                ORDER BY ID_MSG " . ($ascending ? '' : 'DESC') . ($modSettings['defaultMaxMessages'] == -1 ? '' : "
                LIMIT $start, $limit"), __FILE__, __LINE__);
It does this...

Code: Select all

Parse error: parse error, unexpected ',' in /users/kintaro/public_html/labs/Sources/Display.php on line 560

X11
guru
guru
Posts: 676
Joined: Sun Jan 19, 2003 11:09 pm
Location: Australia
Contact:

Post by X11 » Sat Sep 17, 2005 5:13 pm

Okay, I changed that, which brings about another problem.

Code: Select all

2: implode(): Bad arguments.
File: /users/kintaro/public_html/labs/Sources/Display.php
Line: 558
Basically it doesn't like this line...

Code: Select all

                WHERE ID_TOPIC = $topic " . (isset($_REQUEST['only_attach']) && $_REQUEST['only_attach'])? 'AND ID_MSG IN (' . implode(',', $ID_MSG) . ')' : '' . "

User avatar
Void Main
Site Admin
Site Admin
Posts: 5715
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main » Sat Sep 17, 2005 5:43 pm

When you say "Okay, I changed that", what exactly did you change? I bet the problem is actually before the line you quote. I also see spacing problems in your SQL in the first post. It would be a lot easier to see the entire program.

X11
guru
guru
Posts: 676
Joined: Sun Jan 19, 2003 11:09 pm
Location: Australia
Contact:

Post by X11 » Sat Sep 17, 2005 5:48 pm

I got rid of the last ) in that WHERE ID_TOPIC line.

User avatar
Void Main
Site Admin
Site Admin
Posts: 5715
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main » Sat Sep 17, 2005 6:10 pm

Are you saying you changed it from this:

Code: Select all

                WHERE ID_TOPIC = $topic " . (isset($_REQUEST['only_attach']) &&
to this?

Code: Select all

                WHERE ID_TOPIC = $topic " . (isset($_REQUEST['only_attach'] &&
which most certainly isn't right. What is this a part of?

X11
guru
guru
Posts: 676
Joined: Sun Jan 19, 2003 11:09 pm
Location: Australia
Contact:

Post by X11 » Sat Sep 17, 2005 6:17 pm

I changed it to this

Code: Select all

   WHERE ID_TOPIC = $topic " . (isset($_REQUEST['only_attach']) && $_REQUEST['only_attach'])? 'AND ID_MSG IN (' . implode(',', $ID_MSG) . ')' : '' . "

User avatar
Void Main
Site Admin
Site Admin
Posts: 5715
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main » Sat Sep 17, 2005 6:53 pm

Is this part of a program that was already working that you are modifying? If so, can I see the original?

X11
guru
guru
Posts: 676
Joined: Sun Jan 19, 2003 11:09 pm
Location: Australia
Contact:

Post by X11 » Sat Sep 17, 2005 7:55 pm

It happened after automatically installing modifications in a forum, Simple Machines Forum.

I have got some support on the forum for that forum. And I am now left to this SQL error...

Code: Select all

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND ID_MSG=' at line 1
File: /users/kintaro/public_html/labs/Sources/Display.php
Line: 560
For this query...

Code: Select all

        $request = db_query("
                SELECT ID_MSG, ID_MEMBER
                FROM {$db_prefix}messages
                WHERE ID_TOPIC = $topic " . (isset($_REQUEST['only_attach']) && $_REQUEST['only_attach'])? 'AND ID_MSG=' . $ID_MSG : '' . "
                ORDER BY ID_MSG " . ($ascending ? '' : 'DESC') . ($modSettings['defaultMaxMessages'] == -1 ? '' : "
                LIMIT $start, $limit"), __FILE__, __LINE__);

User avatar
Void Main
Site Admin
Site Admin
Posts: 5715
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main » Sat Sep 17, 2005 8:15 pm

Can't you back out the mods and then ask the person who wrote the mod what's broke?

X11
guru
guru
Posts: 676
Joined: Sun Jan 19, 2003 11:09 pm
Location: Australia
Contact:

Post by X11 » Sat Sep 17, 2005 9:16 pm

I could but I have no idea which bloody one did it (I installed lots, and I probably should have been making backups).

User avatar
Void Main
Site Admin
Site Admin
Posts: 5715
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main » Sat Sep 17, 2005 9:20 pm

X11 wrote:I probably should have been making backups
Hmmm, haven't we been here before? :)

X11
guru
guru
Posts: 676
Joined: Sun Jan 19, 2003 11:09 pm
Location: Australia
Contact:

Post by X11 » Sat Sep 17, 2005 9:42 pm

:'( I know.

X11
guru
guru
Posts: 676
Joined: Sun Jan 19, 2003 11:09 pm
Location: Australia
Contact:

Post by X11 » Sun Sep 18, 2005 1:01 am

Okay, I found the mods and fscked them off away from my fscking forum which took me forever but oh well

IT WORKS!!!1111one

Good reason to make a backup.

Post Reply