简体   繁体   中英

Correct SQL Queries Giving Different Results in Joomla Articles

I have a few modules, but I will focus on one in particular. This module was working fine, and it appears in two articles. One article is viewable to registered users and the other article to the public.

I query my database from both of these articles. However, in the public article the module does what is supposed to, but in the registered article, it doesn't.

Before posting code and examples, is there anything obvious that I'm missing that I can try to overcome this?

EDIT

Here are the results of debugging mode:

Working article:

SELECT name, specialty, location
  FROM people
  WHERE name = 'larry' OR specialty = 'testing' OR location = 'seattle'

Non-working article:

SELECT name, specialty, location
  FROM people
  WHERE name = '' OR specialty = '' OR location = ''

The same query should be at work in both cases, and is this:

SELECT name, specialty, location, description
  FROM people 
  WHERE name = '$name' OR specialty = '$specialty' OR location = '$location'

where these variables are POST data, eg, $name = cleaned_up($_POST['name']);

So basically the "registered" users version of the form doesn't post data to the query but the "guest" users version does.

EDIT 2

I discovered that when I remove the module on the left side of my page (I have two modules in div s, side by side, that share POST variables - which is probably part of my problem), the form that doesn't work, starts to work properly.

So I built an identical module, thinking if I pulled that form out and gave the code to another module it would work, but it gave same results as above.

Any help is greatly appreciated.

EDIT 3

I threw a var_dump($_POST); in there in several locations, one at a time, and this gave the expected POST data. So now I'm really confused, because the SQL query is correct and the POST data are getting to the file that needs them.

Although the question is a bit vague without specifics, I would suggest turning on debug profiling in Joomla. If you turn this on, you'll be able to see the exact SQL queries being executed by the module. Locate the queries used by your module, run them via phpMyAdmin or MySQL Workbench, and make sure you get the expected result.

If the issue is not SQL related, then you may need to provide more specific examples.

I found a work around that seems to solve my problem. The original weird issue still exists, but this work around gets my site working and gives me something to go on.

I created as separate variable file for each access state, registered and public. Apparently in the registered state the variables were getting conflicted and the POST data wasn't making it to the SQL query and thus wasn't showing up in my results table.

I think it may be a bug in Joomla but I'd like to get someone else feedback before reporting it. BUT... I posted on forum.joomla.org weeks ago with not response so I have little faith in that support site at all. Actually, if this is as good as their support forums get, then I think I might look into another CMS.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM