cotonti.com : SQL troubles https://www.cotonti.com Последние сообщения в теме Cotonti en Sun, 05 Oct 2025 23:57:15 -0000 TwistedGA
Kinda confusing lol..

EDIT//

I got it to work in the core, under the Hook forums.posts.main, it removed the looping issue so I figured that woudl be the spot to make my plugin hook into, causes a Internal 500 error for whatever reason.. God I love this coding stuff! LOL]]>
сб, 07 мар 2009 10:32:08 -0000
Brock сб, 07 мар 2009 10:26:45 -0000 TwistedGA
$multiquote = sed_import('multiquote','G','TXT');
	if ($multiquote>0)
	{
                $multi = $multiquote;
		$sql_test = sed_sql_query("SELECT fp_id, fp_text, fp_postername, fp_posterid FROM $db_forum_posts WHERE fp_topicid='$q' AND fp_sectionid='$s' AND fp_id IN ( $multi )");

		while ($row4 = sed_sql_fetcharray($sql_test))
		{
			$newmsg .= "[quote][url=forums.php?m=posts&p=".$row4['fp_id']."#".$row4['fp_id']."]#[/url] [b]".$row4['fp_postername']." :[/b]\n".sed_stripquote($row4['fp_text'])."\n[/quote]\n\n";
		}
	}

So I'm still having the repeat issue. For whatever reason, this code is not just running a single time, instead it runs for each post on the page. If theres a single post, it works how it should, 5 posts on the page, it repeats 5 times.

The only way to make it stop running for each post present on the page, is to name "sql_test" "sql"... Which in turn removes all but the first post on the page(not what I want to happen obviously).

I'm stumped on what to try that I have not already. I'm certain it's something minor, but it's a problem nonetheless. I'm working my arse off to fix it and release this..

EDIT//
Also note that this worked perfectly when it's in the core. These problems of repeating are coming from conversion to plugin. It only works when hooked into the forums.posts.loop, everywhere else the code is ineffective. The code works in the core ONLY if the code is placed right below these lines;
/* === Hook - Part1 : Set === */
$extp = sed_getextplugins('forums.posts.loop');
/* ===== */

Apparently, I'm retarded and don't know how to make it insert it right below that. I thought Hooks=forums.post.loop made it insert it right below that. I guess it's Hook - Part2 that defines where it's inserted?]]>
сб, 07 мар 2009 09:58:24 -0000
Kilandor
There are many cases where using generic queries especially hooking will break thins.

Its just good practice not to do that.]]>
сб, 07 мар 2009 07:18:45 -0000
GHengeveld
@Kilandor: What is the reason not to use $sql? Is it because its more vulnerable to attack (its easy to guess), or because it has the risk of being executed in the wrong place. I quite often use $sql so I'd like to know why I shouldn't.
By the way, using $sql multiple times shouldn't be a problem, as long as the value gets overwritten every time. Very often I have something like this:
$sql = "SELECT * FROM sometable WHERE somecondition='true'";
$query = mysql_query($sql);
while ($row = mysql_fetch_array($query)) {
echo $row['somevalue'];
}
$sql = "SELECT * FROM anothertable";
$query = mysql_query($sql);
while ($row = mysql_fetch_array($query)) {
doSomething();
}
]]>
сб, 07 мар 2009 07:14:53 -0000
Kilandor
NEVER NEVER NEVER use generic $sql names, or $sql2 I always recommend $sql_something, or $plug_something, it doesn't matter it doesn't even have to be $sql]]>
сб, 07 мар 2009 07:04:57 -0000
TwistedGA I make my sql_squery using '$sql = sed_sql_query' to define it, and it works almost as it should, but since the php it's hooked into already has a $sql, the plugin running causes problems with the original sql query. (It makes al but one of it's results disappear).

So my first thought was to change mine to $sql2. This causes my results to display twice instead of just once as it should. I tried a ton of different names for it and they all cause the same issue, two of the same result.

Anyone have any ideas on how I can correct this issue? Thanks in advance..

EDIT// This thread can be deleted if nothing comes of it in a few days.
I'm not using the same methods so this is no longer a problem for me, however, if anyone has information on it, I woudl love to hear about it and I'm sure it will benifit someone down the road.]]>
сб, 07 мар 2009 02:27:43 -0000