php.lv forumi: You have an error in your SQL syntax; - php.lv forumi

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

You have an error in your SQL syntax;

#1 User is offline   suport Icon

  • Daudzsološais profiņš
  • PipPipPip
  • Group: Reģistrētie lietotāji
  • Posts: 143
  • Joined: 2008.03.01

Posted 2010.02.02 11:36

Quote

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'and parent = 0' at line 1


sql kods:
SQL KODS:
<?

$sql = "SELECT * FROM `ura_items` WHERE CategoryID != 2 AND CategoryID != 1 AND CategoryID != 0 ORDER BY `Add_Date` DESC LIMIT 10";
$result = @mysql_query($sql);
if( !$result ) {
echo "MySql Error: ".mysql_error();
}
$i = 0;// for alternative row color
while( $row = mysql_fetch_assoc($result) ){

echo "<li><a href=\"".seo_links('detail', $row['ProductID'], $row['ProductName'], 1, _SEO)."\">".fewchars($row['ProductName'], 60)."</a> <span class=\"date_right\">".nice_date($row['Add_Date'])."</span></li>";
echo "<li class=\"shortdesc\">".fewchars($row['LongDesc'], 140)."</li>";

$i++;
}
?>

#2 User is offline   Aleksejs Icon

  • code ex machina
  • PipPipPipPipPip
  • Group: Moderatori
  • Posts: 4,043
  • Joined: 2003.04.05

Posted 2010.02.02 11:55

nav tas kods, jo šajā pilnīgi nekur nav koda fragmenta:
and parent = 0
http://tinyurl.com/web-aplikaciju-izstrade Web Aplikāciju Izstrāde - publisks čats skaipā latviešu valodā.
http://www.twitter.com/AleksejsZ

#3 User is offline   2easy Icon

  • Spama meistars
  • PipPipPipPip
  • Group: Reģistrētie lietotāji
  • Posts: 1,550
  • Joined: 2009.10.02

Posted 2010.02.02 19:15

lol true

es vienīgi varu ieteikt mysql_query() vietā lietot slaveno go() funkciju
function go($sSql) {  // izpilda mysql query
	$h = mysql_query($sSql) or exit('<b>mysql_query() error ' . mysql_errno() . ':</b> ' . mysql_error() . '<br /><b>query:</b> ' . substr($sSql, 0, 1000));
	return $h;
}
tā uzreiz pasaka arī sql, kur bija kļūda

This post has been edited by 2easy: 2010.02.02 19:16


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic