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


Goto page 1, 2  Next

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 ???

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 ??

Subject: Re: This Is Driving Me Nuts !! - SQL Query Producing Double Results !!
No it only gets assigned via the PHP script once

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???

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

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

Subject: Re: This Is Driving Me Nuts !! - SQL Query Producing Double Results !!
Anyone else care to help ?

Mighty Gorgon Help !!

Subject: Re: This Is Driving Me Nuts !! - SQL Query Producing Double Results !!
have you tried removing this part from your code

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

Inactive User
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:

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

Inactive User
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.

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

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

Inactive User
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: [Download] [Hide] [Select]
<option value="{REGION_FILTER}">{REGION_FILTER}</option>


The same VAR twice.

Try this?

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

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

Last edited by AndyGpy on Wed 02 Sep, 2009 07:04; edited 1 time in total
Goto page 1, 2  Next

Page 1 of 2


  
You cannot post new topics
You cannot reply to topics
You cannot edit your posts
You cannot delete your posts
You cannot vote in polls
You cannot attach files
You can download files
You cannot post calendar events

   

This is a "Lo-Fi" version of our main content. To view the full version with more information, formatting and images, please click here.

Powered by Icy Phoenix based on phpBB
Generation Time: 0.4535s (PHP: 6% SQL: 94%)
SQL queries: 15 - Debug Off - GZIP Enabled