Icy Phoenix


Old Support Topics - This Is Driving Me Nuts !! - SQL Query Producing Double Results !!



AndyGpy [ Fri 28 Aug, 2009 22:28 ]
Post subject: This Is Driving Me Nuts !! - SQL Query Producing Double Results !!
Hi Guys,

I have a tpl file :-

Spoiler: [ Show ]


I have the following script

Spoiler: [ Show ]



Now there is a drop down box in the tpl file that gets populated with this code is the php script:-

$sql = "SELECT DISTINCT `type` FROM `" . $tbl ."`WHERE 1 ORDER BY `type` ";

$result = $db->sql_query($sql);

if (!($result = $db->sql_query($sql)))
{
die("Database Query Failed" . mysql_error());
}



while ($row = $db->sql_fetchrow($result))
{
$region_filter_options .= '<option value="' . $row['type'] . '">' . $row['type'] . '</option>';

}

$template->assign_vars(array(
'REGION_FILTER' => $region_filter_options,
)
);



For some reason it produces double entries for every entry, but it looks as if it has run through this routine twice, can someone tell me how to fix this ???


spydie [ Fri 28 Aug, 2009 22:39 ]
Post subject: Re: This Is Driving Me Nuts !! - SQL Query Producing Double Results !!
are you telling me you´ve got the sql vars assigned twice ??

once in your script and once in dropdown ??


AndyGpy [ Fri 28 Aug, 2009 22:48 ]
Post subject: Re: This Is Driving Me Nuts !! - SQL Query Producing Double Results !!
No it only gets assigned via the PHP script once


spydie [ Fri 28 Aug, 2009 23:04 ]
Post subject: Re: This Is Driving Me Nuts !! - SQL Query Producing Double Results !!
question.

why do you connect to the database then your allready connected via config ??

or are you using an extra db for your ticklist???


AndyGpy [ Sat 29 Aug, 2009 00:03 ]
Post subject: Re: This Is Driving Me Nuts !! - SQL Query Producing Double Results !!
Yes i am using a seperate DB for my ticklist, this way i can port it to new versions of IP easily.

regards


spydie [ Sat 29 Aug, 2009 00:07 ]
Post subject: Re: This Is Driving Me Nuts !! - SQL Query Producing Double Results !!
was just a question , cause i thought that it might be the cause off double output


AndyGpy [ Sat 29 Aug, 2009 19:05 ]
Post subject: Re: This Is Driving Me Nuts !! - SQL Query Producing Double Results !!
Anyone else care to help ?

Mighty Gorgon Help !!


DWho [ Sat 29 Aug, 2009 23:44 ]
Post subject: Re: This Is Driving Me Nuts !! - SQL Query Producing Double Results !!
have you tried removing this part from your code

Code: [Hide] [Select]
$result = $db->sql_query($sql);


Lopalong [ Sun 30 Aug, 2009 07:42 ]
Post subject: Re: This Is Driving Me Nuts !! - SQL Query Producing Double Results !!
Andy,

Is what you are saying is that you have a drop-down box and that is the only thing that is calling this script twice?

Spoiler: [ Show ]


Correct ?

If this MOD is GPL - Would you be kind enough to make available for me a zipped copy of the whole MOD - Because working like this has got "Feathers" on it. :shock:


AndyGpy [ Sun 30 Aug, 2009 11:42 ]
Post subject: Re: This Is Driving Me Nuts !! - SQL Query Producing Double Results !!
DWho,

I have tried that - no Joy.


Lopalong,

It dont know how to put it in zip format, i can zip the files and send them to you but i cannot send the assosciated database.

Basically i have the tpl file in the first post and the php script in the first post. There is a small section in the PHP file that populates the drop down box.

If you log into my site as

Username -- test
Password -- test

browse to Ticklists ( Top navigation bar in home page ) you will see what i mean.

Click here for website

regards


Lopalong [ Sun 30 Aug, 2009 12:57 ]
Post subject: Re: This Is Driving Me Nuts !! - SQL Query Producing Double Results !!
I don't need to log into your site because I understand what you are saying. And physically looking at the problem is not really going to help. ;)

All you need to do is dig out all of the files associated with it and .zip them up, and a copy of the original SQL that you added would be more than useful.


DWho [ Sun 30 Aug, 2009 14:06 ]
Post subject: Re: This Is Driving Me Nuts !! - SQL Query Producing Double Results !!
lots of errors on that page at the moment

> Critical Error!
message_die() was called multiple times.
Error #1
Could not query Icy_jr_admin_users table

Line : 152
File : /var/www/Forum/includes/functions_jr_admin.php
SQL : SELECT * FROM Icy_jr_admin_users WHERE user_id = '47'
Error #2
Error
Could not query log information

Line : 101
File : /var/www/Forum/includes/functions_mg_log.php
SQL : SELECT MAX(log_id) max_log_id FROM Icy_logs

cant see whats going on


AndyGpy [ Sun 30 Aug, 2009 18:29 ]
Post subject: Re: This Is Driving Me Nuts !! - SQL Query Producing Double Results !!
Hi Lopalong,

Have PM you what you requested.

DWho,

i only have those errors with the test account, will look into resolving once i get the duplication thing sorted. Thanks anyway.

regards


Lopalong [ Tue 01 Sep, 2009 08:05 ]
Post subject: Re: This Is Driving Me Nuts !! - SQL Query Producing Double Results !!
After many tests and trying to work the Db thing out. :(

It's appears it's in the .tpl file. ;)

Code: [Hide] [Select]
<option value="{REGION_FILTER}">{REGION_FILTER}</option>


The same VAR twice.

Try this?

Code: [Hide] [Select]
<option value="{REGION_FILTER}" /></option>


AndyGpy [ Tue 01 Sep, 2009 20:35 ]
Post subject: Re: This Is Driving Me Nuts !! - SQL Query Producing Double Results !!
Cheers Lopalong that fixed the duplicate entries.

With regards to DWho's spotting-

Critical Error!
message_die() was called multiple times.
Error #1
Could not query Icy_jr_admin_users table

Line : 152
File : /var/www/Forum/includes/functions_jr_admin.php
SQL : SELECT * FROM Icy_jr_admin_users WHERE user_id = '13'
Error #2
Error
Could not query log information

Line : 101
File : /var/www/Forum/includes/functions_mg_log.php
SQL : SELECT MAX(log_id) max_log_id FROM Icy_logs

It appears i am getting it for all users, moderators and admins are ok, it was as a result of missing a " ," when parsing variables.

Problems solved, Lopalong your a star and i look forward to your PM.

regards


Lopalong [ Tue 01 Sep, 2009 23:45 ]
Post subject: Re: This Is Driving Me Nuts !! - SQL Query Producing Double Results !!
AndyGpy wrote: [View Post]
Lopalong your a start and i look forward to your PM.


:mryellow:

Don't hold your breath Andy - My agenda in already bursting at the seams. But I will get around to it. :lol:




Powered by Icy Phoenix