tim2boles
Posts: 16
|
| Posted: 09/19/2007, 10:41 PM |
|
Hello,
I am using SQLServer and PHP. I am trying to get the daggon thing to use a text field on the form within the where clause.
I can add a where clause like
" where emp_task_datetime >= '09/05/2007' ";
but no matter what I do it will not take my variable date.
$testtime= '09/05/2007'
" where emp_task_datetime >= '$testtime' ";
Why will it take it as a literal but will not use the variable?
I am so frustrated.
And YES I did try making it a date field but that would not work, and I have tried to do it within the GUI itself for building the select statement and that did not work either.
Regards
Tim
|
 |
 |
peterr
Posts: 5971
|
| Posted: 09/19/2007, 11:00 PM |
|
That's because the database doesn't know about PHP variables and cannot understand them or obtain their values. When using GUI (Visual Query Builder) you'd have to create an Expression-type parameter and enter the variable name as the Expression.
Or if using PHP code you can try separating your variable from the SQL statement, like:
" where emp_task_datetime >= " . $testtime;
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
DonP
|
| Posted: 09/19/2007, 11:12 PM |
|
I've found that sometimes you get better results by putting the quotes as
part of the variable when using as you are in a query. Something like this:
$testtime = "'09/05/2007'";
$Gridname->ds->Where = "emp_task_datetime >= $testtime";
If the date is being passed as a variable, then try comething like this:
$testtime = "'" . CCGetParam("FormDate","") . "'";
$Gridname->ds->Where = "emp_task_datetime >= $testtime";
This will work only inside the Before Build Select event rather than
directly in the query. Check the Help for exact syntax as this is off the
top of my head without CCS being open and in front of me.
DonP
"tim2boles" <tim2boles@forum.codecharge> wrote in message
news:546f2082405e38@news.codecharge.com...
> Hello,
>
> I am using SQLServer and PHP. I am trying to get the daggon thing to use
> a
> text field on the form within the where clause.
>
> I can add a where clause like
>
> " where emp_task_datetime >= '09/05/2007' ";
> but no matter what I do it will not take my variable date.
>
> $testtime= '09/05/2007'
> " where emp_task_datetime >= '$testtime' ";
>
> Why will it take it as a literal but will not use the variable?
>
> I am so frustrated.
>
> Regards
> Tim
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
 |
tim2boles
Posts: 16
|
| Posted: 09/20/2007, 3:34 AM |
|
Thanks to you both for your time and answers. I thought I had tried both those methods before but I will try again just to be sure and let you know if it worked.
Thanks
Tim
|
 |
 |
|