Icy Phoenix

     
 

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

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

Article
Reply with quote    Download Post  
Post 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 ???



 
Edited by DWho, Sat 29 Aug, 2009 16:17: Added spoiler bbcode to make the post easy to read...
AndyGpy - View user's profile Send private message  
AndyGpy [ Fri 28 Aug, 2009 22:28 ]
Icy Phoenix is an open source project, you can show your appreciation and support future development by donating to the project.

Support us


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

Comments
Reply with quote    Download Post  
Post 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 ??



 
spydie - View user's profile Send private message  
spydie [ Fri 28 Aug, 2009 22:39 ]
Reply with quote    Download Post  
Post Re: This Is Driving Me Nuts !! - SQL Query Producing Double Results !! 
 
No it only gets assigned via the PHP script once



 
AndyGpy - View user's profile Send private message  
AndyGpy [ Fri 28 Aug, 2009 22:48 ]
Reply with quote    Download Post  
Post 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???



 
spydie - View user's profile Send private message  
spydie [ Fri 28 Aug, 2009 23:04 ]
Reply with quote    Download Post  
Post 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



 
AndyGpy - View user's profile Send private message  
AndyGpy [ Sat 29 Aug, 2009 00:03 ]
Reply with quote    Download Post  
Post 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



 
spydie - View user's profile Send private message  
spydie [ Sat 29 Aug, 2009 00:07 ]
Reply with quote    Download Post  
Post Re: This Is Driving Me Nuts !! - SQL Query Producing Double Results !! 
 
Anyone else care to help ?

Mighty Gorgon Help !!



 
AndyGpy - View user's profile Send private message  
AndyGpy [ Sat 29 Aug, 2009 19:05 ]
Reply with quote    Download Post  
Post 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);




 
DWho - View user's profile Send private message  
DWho [ Sat 29 Aug, 2009 23:44 ]
Reply with quote    Download Post  
Post 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.  



 
   
Inactive User [ Sun 30 Aug, 2009 07:42 ]
Reply with quote    Download Post  
Post 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



 
AndyGpy - View user's profile Send private message  
AndyGpy [ Sun 30 Aug, 2009 11:42 ]
Reply with quote    Download Post  
Post 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.



 
   
Inactive User [ Sun 30 Aug, 2009 12:57 ]
Reply with quote    Download Post  
Post 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



 
DWho - View user's profile Send private message  
DWho [ Sun 30 Aug, 2009 14:06 ]
Reply with quote    Download Post  
Post 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



 
AndyGpy - View user's profile Send private message  
AndyGpy [ Sun 30 Aug, 2009 18:29 ]
Reply with quote    Download Post  
Post 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>




 
   
Inactive User [ Tue 01 Sep, 2009 08:05 ]
Reply with quote    Download Post  
Post 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 
AndyGpy - View user's profile Send private message  
AndyGpy [ Tue 01 Sep, 2009 20:35 ]
Display posts from previous:    

HideWas this topic useful?

Post new topic  Reply to topic  Page 1 of 2
Goto page 1, 2  Next
 




 


 

  cron