ntspdy Posted April 19, 2006 Share Posted April 19, 2006 First off, I appreciate any help I can get. Here is my issue, I'm making a call to a DB then depending on the data from one column I'm displaying the data from a second column. The problem I'm getting is that even though I know the data in the column I cannot get my if statement to recognize the "true" part of the statement. Here is the code.<?phpinclude('dbconnect.php');$query="SELECT runtime FROM missionruntime";$query1="SELECT start FROM missionruntime";$runtime=mysql_query($query);$start=mysql_query($query1);if ( $start == 2006-04-19 13:51:59 ) { echo "SERVER DOWN";} else { echo mysql_result($runtime,"runtime");}?>Now I know that $start = 2006-04-19 13:51:59 but it will not display SERVER DOWN. It just displays a blank page. Since the data type is varchar(20) do I have to specify my = statement differently? Link to comment https://forums.phpfreaks.com/topic/7893-if-statement-not-working/ Share on other sites More sharing options...
ToonMariner Posted April 19, 2006 Share Posted April 19, 2006 try...if ( $start == '2006-04-19 13:51:59') { echo "SERVER DOWN";} else { echo mysql_result($runtime,"runtime");} Link to comment https://forums.phpfreaks.com/topic/7893-if-statement-not-working/#findComment-28772 Share on other sites More sharing options...
High_-_Tek Posted April 19, 2006 Share Posted April 19, 2006 You need to fetch the stuff[code]<?phpinclude('dbconnect.php');$query="SELECT runtimeFROM missionruntime";$query1="SELECT startFROM missionruntime";$runtime=mysql_fetch_array(mysql_query($query));$start=mysql_fetch_array(mysql_query($query1));if ( $start['start'] == 2006-04-19 13:51:59 ) {echo "SERVER DOWN";} else {echo {$runtime['runtime']};}?>[/code] Link to comment https://forums.phpfreaks.com/topic/7893-if-statement-not-working/#findComment-28773 Share on other sites More sharing options...
kenrbnsn Posted April 20, 2006 Share Posted April 20, 2006 You should combine the two queries into one.[code]<?phpinclude('dbconnect.php');$query="SELECT runtime, start FROM missionruntime";$rs = mysql_query($query1);$row=mysql_fetch_assoc($rs);if ( $row['start'] == 2006-04-19 13:51:59 ) echo "SERVER DOWN";else echo $row['runtime']; // you don't need the curly braces here. (edited original post)?>[/code]Ken Link to comment https://forums.phpfreaks.com/topic/7893-if-statement-not-working/#findComment-28798 Share on other sites More sharing options...
ntspdy Posted April 20, 2006 Author Share Posted April 20, 2006 Thanks guys, and thanks for answering my second question before I asked it kenrbnsn. I was sure there was a way to do that but that was second on my list. Link to comment https://forums.phpfreaks.com/topic/7893-if-statement-not-working/#findComment-28847 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.