PDA

View Full Version : Dynamic filter does not work


llastein374316
05-17-2010, 02:01 AM
The filter in the data selection does not work, no matter what kind of filter i choose.

<?php
$WADWCs_bygd_WADWCaldursbyti_bygd = "0";
if (isset($_SESSION['s_bygd'])) {
$WADWCs_bygd_WADWCaldursbyti_bygd = $_SESSION['s_bygd'];
}
mysql_select_db($database_manntal, $manntal);
$query_WADWCaldursbyti_bygd = sprintf("SELECT aldur AS XLABEL, m_tal AS YVALUE FROM aldursbyti_bygd WHERE ", GetSQLValueString($WADWCs_bygd_WADWCaldursbyti_byg d, "text"));
$WADWCaldursbyti_bygd = mysql_query($query_WADWCaldursbyti_bygd, $manntal) or die(mysql_error());
$row_WADWCaldursbyti_bygd = mysql_fetch_assoc($WADWCaldursbyti_bygd);
$totalRows_WADWCaldursbyti_bygd = mysql_num_rows($WADWCaldursbyti_bygd);
?>

Eric Mittman
05-17-2010, 12:28 PM
What is the result that you are getting versus the expected result from this? You can check on the query that is being executed by adding in a die statement like this:


<?php
$WADWCs_bygd_WADWCaldursbyti_bygd = "0";
if (isset($_SESSION['s_bygd'])) {
$WADWCs_bygd_WADWCaldursbyti_bygd = $_SESSION['s_bygd'];
}
mysql_select_db($database_manntal, $manntal);
$query_WADWCaldursbyti_bygd = sprintf("SELECT aldur AS XLABEL, m_tal AS YVALUE FROM aldursbyti_bygd WHERE ", GetSQLValueString($WADWCs_bygd_WADWCaldursbyti_byg d, "text"));
die($query_WADWCaldursbyti_bygd);


Please post back with this so we can determine what the query is that is being executed.

llastein374316
05-24-2010, 04:21 PM
Thank you for the reply.
The graph does not display when using a session variable, but work perfectly without.

Eric Mittman
05-24-2010, 06:27 PM
What does one of the queries using the session variable look like compared to the query that does not use the session variable? If we can compare the queries the problem with using the session variable might be more obvious.

Also, what is the result that you get when you try to view this graph that uses the session variable? Do you see an empty chart, or does the page load with no chart at all?

llastein374316
05-25-2010, 04:19 PM
Now I have tested the query and found that using a session variable which is a number the graph displays perfectly, but when using a text session variable the data does not show in the graph.

Here is the query with the number session variable which is working perfectly:

<?php
$WADWCs_bygd_WADWCaldursbyti_bygd = "-1";
if (isset($_SESSION['s_bygd'])) {
$WADWCs_bygd_WADWCaldursbyti_bygd = $_SESSION['s_bygd'];
}
mysql_select_db($database_manntal, $manntal);
$query_WADWCaldursbyti_bygd = sprintf("SELECT aldur AS XLABEL, m_tal AS YVALUE FROM aldursbyti_bygd WHERE aldur = %s", GetSQLValueString($WADWCs_bygd_WADWCaldursbyti_byg d, "int"));
$WADWCaldursbyti_bygd = mysql_query($query_WADWCaldursbyti_bygd, $manntal) or die(mysql_error());
$row_WADWCaldursbyti_bygd = mysql_fetch_assoc($WADWCaldursbyti_bygd);
$totalRows_WADWCaldursbyti_bygd = mysql_num_rows($WADWCaldursbyti_bygd);
?>

Do you have any suggestion what to do when using a text session variable?

Sincerely Lena

Eric Mittman
05-25-2010, 06:20 PM
Can you post back with the output from a working query using a session variable with a number value and also the output from the query using the session variable with a text value. I would like to see the actual query that is ok versus the one that is not ok.

You can get these queries to print to the screen using the die statement in message #2. Normally when you are setting up the data to be filtered you will need to enter the data type. If you have a text type of value and use a number you can get an error, and the same goes for the other way around. This is what it sounds like you are experiencing. Looking directly at the queries is a good way to see what the difference is.

llastein374316
05-26-2010, 01:49 AM
It seems that using the wizart the $WADWCs_bygd_WADWCaldursbyti_bygd is set to "0". I changed it manually to "null" and now it seems to work. I will try to test some other session variables to see if everything is working allright but this session variable seems to work now.
Thank you very much again.

Sincerely Lena

<?php
$WADWCs_bygd_WADWCaldursbyti_bygd = "null";
if (isset($_SESSION['s_bygd'])) {
$WADWCs_bygd_WADWCaldursbyti_bygd = $_SESSION['s_bygd'];
}
mysql_select_db($database_manntal, $manntal);
$query_WADWCaldursbyti_bygd = sprintf("SELECT aldur AS XLABEL, m_tal AS YVALUE FROM aldursbyti_bygd WHERE bygd = %s", GetSQLValueString($WADWCs_bygd_WADWCaldursbyti_byg d, "text"));
$WADWCaldursbyti_bygd = mysql_query($query_WADWCaldursbyti_bygd, $manntal) or die(mysql_error());
$row_WADWCaldursbyti_bygd = mysql_fetch_assoc($WADWCaldursbyti_bygd);
$totalRows_WADWCaldursbyti_bygd = mysql_num_rows($WADWCaldursbyti_bygd);
?>

Eric Mittman
05-26-2010, 05:03 PM
Ok, glad that it is working.