chico1st Posted August 21, 2006 Share Posted August 21, 2006 something is wrong with my WHERE statement :S This looks right to me"SELECT news.newsID, [b]news.authorID AS newsAuthor[/b], news.topicID AS newsTopic, news.name AS newsName, news.abstract, " . "news.fulltext, date.name AS date, topic.name AS topic, author.name AS author " . "FROM news, date, topic, author " . [b]"WHERE newsAuthor = 1";[/b] $result = mysql_query($query) or die('Error, query failed');I get 'Error, query failed'there is an entry that matches this but it shouldnt say that even if there isnt an entry Thanks for any help you may offer! Quote Link to comment https://forums.phpfreaks.com/topic/18163-solved-where-syntax/ Share on other sites More sharing options...
shoz Posted August 21, 2006 Share Posted August 21, 2006 Change the code to the following and post the output.[code]$query = 'query here';$result = mysql_query($query) or die($query."<br />\n".mysql_error());[/code] Quote Link to comment https://forums.phpfreaks.com/topic/18163-solved-where-syntax/#findComment-77943 Share on other sites More sharing options...
chico1st Posted August 21, 2006 Author Share Posted August 21, 2006 ok wow.. that mysql_error() thing is amazing i wish i knew about that beforeSELECT `news.newsID`, `news.authorID`, `news.topicID`, `news.name`, `news.abstract`, `news.fulltext`, `date.name` FROM `news`, `date`Unknown column 'news.newsID' in 'field list'newsID is definatly a field in my news table Quote Link to comment https://forums.phpfreaks.com/topic/18163-solved-where-syntax/#findComment-78123 Share on other sites More sharing options...
shoz Posted August 21, 2006 Share Posted August 21, 2006 Post the create statement for the "news" table using the following query.[code]SHOW CREATE TABLE news[/code] Quote Link to comment https://forums.phpfreaks.com/topic/18163-solved-where-syntax/#findComment-78127 Share on other sites More sharing options...
chico1st Posted August 21, 2006 Author Share Posted August 21, 2006 CREATE TABLE `news` (\n `newsID` smallint(4) NOT NULL auto_increment,\n `dateID` varchar(5) NOT NULL,\n `authorID` smallint(4) NOT NULL,\n `topicID` varchar(4) NOT NULL,\n `pictureID` varchar(4) NOT NULL,\n `name` varchar(20) NOT NULL,\n `fulltext` longtext NOT NULL,\n `abstract` tinytext NOT NULL,\n PRIMARY KEY (`newsID`)\n) ENGINE=InnoDB DEFAULT CHARSET=latin1 Quote Link to comment https://forums.phpfreaks.com/topic/18163-solved-where-syntax/#findComment-78133 Share on other sites More sharing options...
shoz Posted August 21, 2006 Share Posted August 21, 2006 I should have noticed this before.If the entire value is surrounded by backticks (`) then it's assumed to be a column name in that context. You can either remove the backticks or surround the table name and column name individually with backticks.[code]SELECT `news`.`id` FROM ...[/code] Quote Link to comment https://forums.phpfreaks.com/topic/18163-solved-where-syntax/#findComment-78134 Share on other sites More sharing options...
chico1st Posted August 21, 2006 Author Share Posted August 21, 2006 thanks a tonne! i dont know the syntax of a lot of things like that.. i just kindof toss backticks in when i feel like it.. its bad but im getting better! Quote Link to comment https://forums.phpfreaks.com/topic/18163-solved-where-syntax/#findComment-78140 Share on other sites More sharing options...
chico1st Posted August 21, 2006 Author Share Posted August 21, 2006 what does it mean when you get this error from mysql_error()?MySQL server has gone away Quote Link to comment https://forums.phpfreaks.com/topic/18163-solved-where-syntax/#findComment-78143 Share on other sites More sharing options...
shoz Posted August 21, 2006 Share Posted August 21, 2006 http://dev.mysql.com/doc/refman/4.1/en/gone-away.html Quote Link to comment https://forums.phpfreaks.com/topic/18163-solved-where-syntax/#findComment-78146 Share on other sites More sharing options...
fenway Posted August 21, 2006 Share Posted August 21, 2006 Or you could just not use backticks at all.... Quote Link to comment https://forums.phpfreaks.com/topic/18163-solved-where-syntax/#findComment-78183 Share on other sites More sharing options...
chico1st Posted August 21, 2006 Author Share Posted August 21, 2006 i usually dont but when things go wrong i kind of just throw them in, i used to think it was a good idea.. but now i knowand knowing is half the battle... GI JOE! Quote Link to comment https://forums.phpfreaks.com/topic/18163-solved-where-syntax/#findComment-78289 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.