PHP Problem

Discuss Programming

PHP Problem

Postby 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: 674
Joined: Sun Jan 19, 2003 11:09 pm
Location: Australia

Postby 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) . ')' : '' . "
X11
guru
guru
 
Posts: 674
Joined: Sun Jan 19, 2003 11:09 pm
Location: Australia

Postby 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.
User avatar
Void Main
Site Admin
Site Admin
 
Posts: 5705
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA

Postby X11 » Sat Sep 17, 2005 5:48 pm

I got rid of the last ) in that WHERE ID_TOPIC line.
X11
guru
guru
 
Posts: 674
Joined: Sun Jan 19, 2003 11:09 pm
Location: Australia

Postby 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?
User avatar
Void Main
Site Admin
Site Admin
 
Posts: 5705
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA

Postby 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) . ')' : '' . "
X11
guru
guru
 
Posts: 674
Joined: Sun Jan 19, 2003 11:09 pm
Location: Australia

Postby 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?
User avatar
Void Main
Site Admin
Site Admin
 
Posts: 5705
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA

Postby 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__);
X11
guru
guru
 
Posts: 674
Joined: Sun Jan 19, 2003 11:09 pm
Location: Australia

Postby 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?
User avatar
Void Main
Site Admin
Site Admin
 
Posts: 5705
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA

Postby 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).
X11
guru
guru
 
Posts: 674
Joined: Sun Jan 19, 2003 11:09 pm
Location: Australia

Postby 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? :)
User avatar
Void Main
Site Admin
Site Admin
 
Posts: 5705
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA

Postby X11 » Sat Sep 17, 2005 9:42 pm

:'( I know.
X11
guru
guru
 
Posts: 674
Joined: Sun Jan 19, 2003 11:09 pm
Location: Australia

Postby 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.
X11
guru
guru
 
Posts: 674
Joined: Sun Jan 19, 2003 11:09 pm
Location: Australia


Return to Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron