abhi80 Posted February 28, 2007 Share Posted February 28, 2007 Hi All, I am a new comer in php. earlier I was involved in ASP. Currently I am facing a problem. I have created 2 tables as: 1. CREATE TABLE dtopics ( topicId int(11) NOT NULL auto_increment, topicName text, dateAdded date default NULL, PRIMARY KEY (topicId) ) TYPE=MyISAM; 2. CREATE TABLE tcomments ( commentId int(10) unsigned NOT NULL auto_increment, comment text, topicId int(10) NOT NULL default '0', postedBy varchar(100) default NULL, postdate timestamp(14) NOT NULL, isActive enum('True','False') default 'False', PRIMARY KEY (commentId), KEY postdate (postdate) ) TYPE=MyISAM; now I am running a query against these tables: $qt="Select T.*, D.topicName from tcomments T inner join dtopics D on T.topicId=D.topicId where T.topicId=$tid AND isActive='False' Order By postDate DESC"; while($result_set=mysql_fetch_array($result1)) { //show data } but this query is returning nothing. Though I tried to run same query in MYSQL and it returned expected results. but in php page it is not returning any thing. Could somebody please tell me where I am making a mistake? Quote Link to comment Share on other sites More sharing options...
mmarif4u Posted February 28, 2007 Share Posted February 28, 2007 try this one if get the value $tid from a form, $qt="Select T.*, D.topicName from tcomments T inner join dtopics D on T.topicId=D.topicId where T.topicId='$tid' AND isActive='False' Order By postDate DESC"; Quote Link to comment Share on other sites More sharing options...
abhi80 Posted February 28, 2007 Author Share Posted February 28, 2007 I am getting $tid from a query string as: $tid=$_REQUEST['tid']; and I am running the same query as posted by you. $qt="Select T.*, D.topicName from tcomments T inner join dtopics D on T.topicId=D.topicId where T.topicId='$tid' AND isActive='False' Order By postDate DESC"; Quote Link to comment Share on other sites More sharing options...
itsmeArry Posted February 28, 2007 Share Posted February 28, 2007 One thing that I noticed is you are missing the statement $result1 = mysql_query($qt); Quote Link to comment Share on other sites More sharing options...
abhi80 Posted February 28, 2007 Author Share Posted February 28, 2007 I am sorry I forgot to paste this line. I am using this code as: $result1 = mysql_query($qt) or die(mysql_error()); Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted February 28, 2007 Share Posted February 28, 2007 You didn't define T or D... Could that be the problem? I think something like this?: Select tcomments.*, dtopics.topicName from tcomments as T inner join dtopics as D on T.topicId=D.topicId where T.topicId=$tid AND isActive='False' Order By postDate DESC Quote Link to comment Share on other sites More sharing options...
abhi80 Posted February 28, 2007 Author Share Posted February 28, 2007 I am doing this in same way as urs except aliases. $qt="Select T.*, D.topicName from tcomments T inner join dtopics D on T.topicId=D.topicId where T.topicId='$tid' AND isActive='False' Order By postDate DESC"; and I told earlier that This is working fine in MySQL. Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted February 28, 2007 Share Posted February 28, 2007 Sorry I skipped that part Did you try this?: $qt="Select T.*, D.topicName from tcomments T inner join dtopics D on T.topicId=D.topicId where T.topicId=$tid AND isActive='False' Order By postDate DESC"; $result1 = mysql_query($qt) or die(mysql_error()); while($result_set=mysql_fetch_array($result1)) { echo $result_set['topicName']; } Quote Link to comment Share on other sites More sharing options...
abhi80 Posted February 28, 2007 Author Share Posted February 28, 2007 yes I tried little guy Quote Link to comment Share on other sites More sharing options...
itsmeArry Posted February 28, 2007 Share Posted February 28, 2007 are you sure that you are having records in db which have value for isActive = 'False' or you want to show the Active Records.. if yes then change the isActive='False' to isActive <> 'False' Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted February 28, 2007 Share Posted February 28, 2007 echo out $tid before $qt, and see if it has a value in it. Quote Link to comment Share on other sites More sharing options...
abhi80 Posted February 28, 2007 Author Share Posted February 28, 2007 Yes I tried all the ways I could. And I have noticed 1 thing. When I activate/deactivate more then 1 records then they start to display in my query results. Wot's wrong? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.