illuz1on Posted March 9, 2007 Share Posted March 9, 2007 if (isset($_POST['docreate']) && isset($_POST['news'])) { SQLQuery('INSERT INTO `'.SQLTable('news').'` (`ID`, `PostedTime`, `Title`, `Text`) VALUES (\'\', '.time().', \''.$_POST['title'].'\', \''.$_POST["news"].'\');'); print 'News added to database<br><br><hr>'; } ?> Whats wrong with the bold part of things? Link to comment https://forums.phpfreaks.com/topic/41957-sql-query-line-not-working-used-to-though/ Share on other sites More sharing options...
JasonLewis Posted March 9, 2007 Share Posted March 9, 2007 instead of: SQLQuery('INSERT INTO `'.SQLTable('news').'` (`ID`, `PostedTime`, `Title`, `Text`) VALUES (\'\', '.time().', \''.$_POST['title'].'\', \''.$_POST["news"].'\');'); try this: mysql_query("INSERT INTO `news` (`ID`, `PostedTime`, `Title`, `Text`) VALUES ('".time()."', '".$_POST['title']."', '".$_POST['news']."')") or die("Error: ".mysql_error()); Link to comment https://forums.phpfreaks.com/topic/41957-sql-query-line-not-working-used-to-though/#findComment-203427 Share on other sites More sharing options...
chrisuk Posted March 9, 2007 Share Posted March 9, 2007 dont you need another variable to actually execute the query? eg. $result = mysql_query($SQLQuery) or die (mysql_error()); Link to comment https://forums.phpfreaks.com/topic/41957-sql-query-line-not-working-used-to-though/#findComment-203428 Share on other sites More sharing options...
illuz1on Posted March 9, 2007 Author Share Posted March 9, 2007 $result = SQLQuery('SELECT ID,Day,Month,Year,ShortDescription FROM `'.SQLTable('party').'` WHERE `ClubID`='.$_GET['view'].' ORDER BY `Year` DESC,`Month` DESC,`Day` DESC'); How about that? Link to comment https://forums.phpfreaks.com/topic/41957-sql-query-line-not-working-used-to-though/#findComment-203639 Share on other sites More sharing options...
per1os Posted March 9, 2007 Share Posted March 9, 2007 dont you need another variable to actually execute the query? eg. $result = mysql_query($SQLQuery) or die (mysql_error()); Not for an insert statement. $result = SQLQuery('SELECT ID,Day,Month,Year,ShortDescription FROM `'.SQLTable('party').'` WHERE `ClubID`='.$_GET['view'].' ORDER BY `Year` DESC,`Month` DESC,`Day` DESC'); $result = SQLQuery("SELECT ID,Day,Month,Year,ShortDescription FROM `".SQLTable('party')."` WHERE `ClubID`=".$_GET['view']." ORDER BY `Year`,`Month`,`Day` DESC"); You do not need to put DESC after every single column in the order by. And for debugging purposes I would add this to that line $result = SQLQuery("SELECT ID,Day,Month,Year,ShortDescription FROM `".SQLTable('party')."` WHERE `ClubID`=".$_GET['view']." ORDER BY `Year`,`Month`,`Day` DESC") or DIE(mysql_error()); --FrosT Link to comment https://forums.phpfreaks.com/topic/41957-sql-query-line-not-working-used-to-though/#findComment-203649 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.