ellifant Posted May 10, 2013 Share Posted May 10, 2013 I receive the following error code: 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 'database ORBER BY id' at line 1 I am driving myself crazy trying to figure it out. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <!-- TemplateBeginEditable name="doctitle" --> <title>NoEqualGaming</title> <!-- TemplateEndEditable --> <link rel="stylesheet" type="text/css" href="/stylesheet.css" /> <script language="JavaScript" type="text/javascript" src="/SpryAssets/SpryCollapsiblePanel.js"></script> <link href="/SpryAssets/SpryCollapsiblePanel.css" rel="stylesheet" type="text/css" /> <!-- TemplateBeginEditable name="head" --> <!-- TemplateEndEditable --> </head> <body> <div class="container"> <div class="bannerArea"> <div class="toplogo"><a href="#"><img src="/images/banner_logo.gif" border="0" /></a></div> </div> <div class="contentArea"> <div class="leftnavigation"> <a href="/" >Home</a> <a href="/news.php" >News</a> <a href="/research.php" >Research</a><a href="/reviews.php" >Reviews</a> <a href="/aboutus">About Us</a><a href="/contactus.php" >Contact Us</a> <a href="/member_area/index.php" >Members Only</a> </div> <div class="contentleft"><!-- TemplateBeginEditable name="item 1" --> <h2>Research</h2> <?php mysql_connect("host", "user", "pass")or die("cannot connect"); mysql_select_db("db")or die("cannot select DB"); $query = "SELECT * FROM database ORDER BY id"; $result = mysql_query($query); if($result === FALSE) { die(mysql_error()); } $date = date("l F d Y", $row['pubdate']); $title = stripslashes($row['title']); $abstract = stripslashes($row['abstract']); $author = stripslashes ($row['author']); $author2 = stripslashes ($row['author2']); $author3 = stripslashes ($row['author3']); $author4 = stripslashes ($row['author4']); $author5 = stripslashes ($row['author5']); $author6 = stripslashes ($row['author6']); $author7 = stripslashes ($row['author7']); $author8 = stripslashes ($row['author8']); $keyword = stripslashes ($row['keyword']); $keyword2 = stripslashes ($row['keyword2']); $keyword3 = stripslashes ($row['keyword3']); $keyword4 = stripslashes ($row['keyword4']); $keyword5 = stripslashes ($row['keyword5']); $link = stripslashes ($row['link']); $game = stripslashes ($row['game']); while($row = mysql_fetch_array($result)) { ?> <p><strong><?php echo $title; ?></strong><br /><br /><?php echo $author; ?> <?php echo $author2; ?> <?php echo $author3; ?> <?php echo $author4; ?> <?php echo $author5; ?> <?php echo $author6; ?> <?php echo $author7; ?> <?php echo $author8; ?><br /><?php echo $pubdate; ?><br /> <?php echo $abstract; ?><br /><br /> <?php echo $keyword; ?> <?php echo $keyword2; ?> <?php echo $keyword3; ?> <?php echo $keyword4; ?> <?php echo $keyword5; ?> <br /> <?php echo $game; ?> <br /> <?php echo '<a href="' . $row['link'] . '">' . $row['link'] . '</a>'; ?> <?php }?> <hr /></p> <!-- TemplateEndEditable --></div> <div class="contentright"><!-- TemplateBeginEditable name="item 4" --> </div> <br class="clear_both" /> </div> <div class="footerArea"> <div class="footercontent"> <div class="footernav"><a href="/contactus.php" >Contact Us</a> •<a href="adminlogin.php">Admin Login</a></div> <div class="copyright">Appalachian State University. All rights reserved.</div> </div> </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/277863-syntax-error/ Share on other sites More sharing options...
Solution akphidelt2007 Posted May 10, 2013 Solution Share Posted May 10, 2013 Database is probably a reserved word that you can't use as a table name. Just a guess. Quote Link to comment https://forums.phpfreaks.com/topic/277863-syntax-error/#findComment-1429407 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.