Page 1 of 1
using define
Posted: Thu Jan 13, 2005 9:04 am
by pelegk2
i have done :
PHP:
--------------------------------------------------------------------------------
DEFINE ("START_TIME","$startTime");
--------------------------------------------------------------------------------
and when i echo it from an included page i get for eample : 1105592400 - which is unix time!
but when i try to put it in a string like this :
"select * from table1 where AND TAARICH_HASPAKA >= ".START_TIME
the START_TIME is gives me an "empty string" and i see:
"select * from table1 where AND TAARICH_HASPAKA >="
what to do?
thnaks i advance
peleg
Posted: Thu Jan 13, 2005 9:45 am
by MrSpam
On the query you have missed out the $ on start_time.
Posted: Thu Jan 13, 2005 9:48 am
by feyd
constant's don't use $..
I think I need to understand the scope locations of each of these calls. Are they in two differing pages?
i know tht
Posted: Fri Jan 14, 2005 12:12 am
by pelegk2
beacuse of that i wrote START_TIME !!!!
but still when i try to add it to a string it doesnt gives an output!
(only if i wil do echo START_TIME i will see the value!!!)
whay to do?
Posted: Fri Jan 14, 2005 8:15 am
by feyd
it sure seems to work perfectly on my machine.. can you post the code around the select? (including the select)
Posted: Sun Jan 16, 2005 1:35 am
by pelegk2
this is the code :
Code: Select all
"SELECT *,order_header.weight as del_weight FROM order_header,delivery WHERE (order_header.del_id=delivery.del_id) AND
order_header.region_id='".$_REQUESTї'r_region_id']."' AND delivery.round_num=$round_num
and (
(TAARICH_HASPAKA <= $endTime AND TAARICH_HASPAKA >= ".START_TIME." AND TEUDAT_MISH='')
OR (TAARICH_TEUDA >= ".START_TIME ."AND TAARICH_TEUDA <= $endTime )
) ORDER BY LAKOACH"
Posted: Sun Jan 16, 2005 7:24 am
by feyd
seems to generally work.. syntax error with $endTime vs. $endtime, at least.
Code: Select all
<?php
define('START_TIME', time());
$endtime = 20;
$round_num = 3;
$_REQUESTї'r_region_id'] = 'test';
$sql = "SELECT *,order_header.weight as del_weight FROM order_header,delivery WHERE (order_header.del_id=delivery.del_id) AND
order_header.region_id='".$_REQUESTї'r_region_id']."' AND delivery.round_num=$round_num
and (
(TAARICH_HASPAKA <= $endTime AND TAARICH_HASPAKA >= ".START_TIME." AND TEUDAT_MISH='')
OR (TAARICH_TEUDA >= ".START_TIME ."AND TAARICH_TEUDA <= $endTime )
) ORDER BY LAKOACH";
echo $sql;
?>
Code: Select all
SELECT *,order_header.weight as del_weight FROM order_header,delivery WHERE (order_header.del_id=delivery.del_id) AND
order_header.region_id='test' AND delivery.round_num=3
and (
(TAARICH_HASPAKA <= AND TAARICH_HASPAKA >= 1105881775 AND TEUDAT_MISH='')
OR (TAARICH_TEUDA >= 1105881775AND TAARICH_TEUDA <= )
) ORDER BY LAKOACH
nope it isnt working look at your code :
Posted: Sun Jan 16, 2005 8:42 am
by pelegk2
this is your code u just gave me :
Code: Select all
SELECT *,order_header.weight as del_weight FROM order_header,delivery WHERE (order_header.del_id=delivery.del_id) AND
order_header.region_id='test' AND delivery.round_num=3
and (
(TAARICH_HASPAKA <= AND TAARICH_HASPAKA >= 1105881775 AND TEUDAT_MISH='')
OR (TAARICH_TEUDA >= 1105881775AND TAARICH_TEUDA <= )
) ORDER BY LAKOACH
if you look good you will see that "TAARICH_HASPAKA <= "
misiing the START_TIME !!!!!!!!!!!!
Posted: Sun Jan 16, 2005 8:49 am
by feyd
that's not START_TIME. That's $endTime. Same with "TAARICH_TEUDA <="
Look at your code, now look at the second sentance of my previous post:
syntax error with $endTime vs. $endtime
ok maybe i didint copy wel from my page
Posted: Sun Jan 16, 2005 9:02 am
by pelegk2
but still can u give me your own code that you say it works and i will run it on my end?
thnaks i nadvance
peleg
Posted: Sun Jan 16, 2005 9:04 am
by feyd
the code I posted works, provided you choose either $endTime or $endtime. The problem is you have both in your query. Fix that, and it should work...
Posted: Sun Jan 16, 2005 9:06 am
by JAM
If you can, you should aswell edit the error level reporting to something higher. You should then see more about whats missing...
Code: Select all
Notice: Undefined variable: endTime in \test.php on line 12
Notice: Undefined variable: endTime in \test.php on line 14
...and...
should be
...and...
Code: Select all
OR (TAARICH_TEUDA >= ".START_TIME ."AND
should be
Code: Select all
OR (TAARICH_TEUDA >= ".START_TIME ." AND
...to name a few problems.
pelegk2 wrote:if you look good you will see that "TAARICH_HASPAKA <= "
misiing the START_TIME !!!!!!!!!!!!
Note that we dont't tend to give out solutions. We give pointers to what to look at/for. Try to read your code and see if you understand it. Then change it to something that you might think work and test it.
Bad question: "This doesn't work..."
Good question: "I've tried X and Y. But i get the following error: 'Z'. Ideas?"