Jump to content

SQL query line not working, used to though??


illuz1on

Recommended Posts

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?

 

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()); 

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.