using define

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

using define

Post 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
MrSpam
Forum Newbie
Posts: 3
Joined: Thu Jan 13, 2005 9:40 am

Post by MrSpam »

On the query you have missed out the $ on start_time.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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?
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

i know tht

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it sure seems to work perfectly on my machine.. can you post the code around the select? (including the select)
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post 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"
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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&#1111;'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&#1111;'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
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

nope it isnt working look at your code :

Post 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 !!!!!!!!!!!!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

ok maybe i didint copy wel from my page

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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...
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post 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...

Code: Select all

TAARICH_HASPAKA >= 1105881775
should be

Code: Select all

TAARICH_HASPAKA >= '1105881775'
...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?"
Post Reply