User Name
Password

Go Back   Planetarion Forums > Non Planetarion Discussions > Programming and Discussion
Register FAQ Members List Calendar Arcade Today's Posts

Reply
Thread Tools Display Modes
Unread 26 Feb 2005, 19:18   #1
Eidron
The Harsh Light of Day
 
Join Date: Jun 2001
Location: Behind my comp in Hertfordshire, UK
Posts: 101
Eidron is an unknown quantity at this point
One last mysql/php question

Ok , I have just used the COUNT() function to give me either the number 0 or anything else.

II then run the query like so:

Code:
			$query = "SELECT COUNT(date) FROM bookings WHERE (date = '$date' OR date = SUBDATE('$date', INTERVAL 2 DAY))";
			$result = @mysql_query ($query); //run the query
]

I then compare it to so that if it equals 0 I can proceed with whatever I want. If it donest equal 0 I just want it to shout at me, which it does, but it does it all the time. What I use is

Code:
	if ($result == '0'){
		//Do this
         }

          else{
                   //shout at me
          }
]
However, all this does is skips to the else, even when $result should be 0. I have tried with and without the inverted commas but no joy..
__________________
"I am become death, the destroyer of worlds"

You'll never see me but I am everywhere
Eidron is offline   Reply With Quote
Unread 26 Feb 2005, 19:28   #2
ceres
Registered User
 
ceres's Avatar
 
Join Date: Jan 2005
Posts: 278
ceres has much to be proud ofceres has much to be proud ofceres has much to be proud ofceres has much to be proud ofceres has much to be proud ofceres has much to be proud ofceres has much to be proud ofceres has much to be proud ofceres has much to be proud ofceres has much to be proud of
Re: One last mysql/php question

try

if(!$result)
________
Nexium Lawyer

Last edited by ceres; 31 Aug 2011 at 06:50.
ceres is offline   Reply With Quote
Unread 26 Feb 2005, 19:35   #3
Eidron
The Harsh Light of Day
 
Join Date: Jun 2001
Location: Behind my comp in Hertfordshire, UK
Posts: 101
Eidron is an unknown quantity at this point
Re: One last mysql/php question

No joy .
__________________
"I am become death, the destroyer of worlds"

You'll never see me but I am everywhere
Eidron is offline   Reply With Quote
Unread 26 Feb 2005, 20:16   #4
wu_trax
Registered User
 
Join Date: Jan 2003
Posts: 4,290
wu_trax is a pillar of this Internet societywu_trax is a pillar of this Internet societywu_trax is a pillar of this Internet societywu_trax is a pillar of this Internet societywu_trax is a pillar of this Internet societywu_trax is a pillar of this Internet societywu_trax is a pillar of this Internet societywu_trax is a pillar of this Internet societywu_trax is a pillar of this Internet societywu_trax is a pillar of this Internet societywu_trax is a pillar of this Internet society
Re: One last mysql/php question

Code:
$query = "SELECT COUNT(date)  AS whatever FROM bookings WHERE (date = '$date' OR date = SUBDATE('$date', INTERVAL 2 DAY))";
$row = mysql_fetch_assoc(@mysql_query ($query));
if ($row['whatever'] == '0'){
		//Do this
         }

          else{
                   //shout at me
          }
__________________
im not tolerant, i just dont care.
wu_trax is offline   Reply With Quote
Reply



Forum Jump


All times are GMT +1. The time now is 11:53.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2002 - 2018