SQL query error!

Permabanned
Joined
25 Oct 2004
Posts
9,078
Hiya, anyone help me out with the below SQL query for some reason its throwing out an invalid syntax error but i cant see anything wrong.

PHP:
$query = "INSERT INTO newsfeed "
            . "(title, description, pubdate, url) "
            . "VALUES (".addslashes($news_title).",".addslashes($news_lead).",$pubdate, $news_link_url)";
 
I'm guessing title, description and url are text fields, in which case the values going into them need apostrphes before and after:
Code:
$query = "INSERT INTO newsfeed "
            . "(title, description, pubdate, url) "
            . "VALUES ('".addslashes($news_title)."','".addslashes($news_lead)."',$pubdate, '$news_link_url')";
 
I'm guessing title, description and url are text fields, in which case the values going into them need apostrphes before and after:
Code:
$query = "INSERT INTO newsfeed "
            . "(title, description, pubdate, url) "
            . "VALUES ('".addslashes($news_title)."','".addslashes($news_lead)."',$pubdate, '$news_link_url')";

Cheers for that mate, realised it was something simple after scratching my head for a bit, the only thing i need to figure out now is how to get the data sorted and displayed correctly, what i have is a simple GUI for users to add news to the site (providing they have login credentials) when the news is added to the database its the last record with an auto_increment id of 15 for example. What i want is the last record stored on the database to be the first record displayed on my news feed but with the correct article number (ie item 15 on database would be item 1 when displayed) so the unique id numbers are effectively reversed.

Any idea's ?

Again appreciate any input.
 
Thats odd, working ok now, guess i did something wrong somewhere, still have the problem of it displaying the data wrong though, now that the last item entered is displayed first, i still have the problem of it displaying the wrong Id.

The last item added to database should be the first listed with number 1 instead of for example the last item entered being the first listed with its own reference number of 12.

EDIT: Never mind, too early in the morning, was just a simple case of maths.
 
Last edited:
Back
Top Bottom