Hi all , im not much of a programmer but i can find my way around most things if i can figure it out, however im a little stuck with this one. Ive just transferred a site from one server and database to another , both are PHP 5 and Both mySQL 5 , but on the new server im getting this error : 1064: 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 '' at line 1 PHP: Now the site is custom coded and pretty basic so im hoping its something basic to fix too. Any help would be great
You probably have an extra ' ; or space in there some place. Post the php code and I will take a look at it.
<?php error_reporting (E_ALL); require_once ("./includes/config.php"); include ("./includes/functions.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> <?php $cat_id = $_GET['cat_id']; $getosscategory = "SELECT OSSCategoryId, Category FROM osscategory WHERE OSSCategoryId=".$cat_id.""; $osscategoryrs = mysql_query($getosscategory, $conn) or die (mysql_errno() . ": " . mysql_error()). "\n"; while($osscategory = mysql_fetch_array($osscategoryrs)) { $oss_category = $osscategory['Category']; echo "Open Source CMS - " .$oss_category ." Systems"; } mysql_free_result($osscategoryrs); ?> </title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta name="keywords" content="open source cms, open source <?php echo $oss_category; ?>, <?php echo $oss_category; ?> cms, open source software, free cms, free content managment system, content management system, open source applications" /> <meta name="description" content="Open source <?php echo $oss_category; ?> content management systems." /> <meta name="robots" content="index,follow" /> <meta name="resource-type" content="document" /> <meta name="revisit-after" content="1 day" /> <meta name="distribution" content="global" /> <meta name="rating" content="general" /> <link href="/style.css" rel="stylesheet" type="text/css" /> </head> <body> <?php include_once("header.php"); ?> <div class="heading"><a href="/oss.php">Open Source Scripts and Applications</a></div> <div><img src="/images/navbits.gif" alt="<?php echo $oss_category; ?> tutorials" /><strong><?php echo $oss_category; ?></strong></div> <br /> <table cellpadding="2" cellspacing="1" class="freewebs_layout"> <tr> <td style="background-color:#f8f8f8;"> <div style="padding:2px 0px 2px 2px;"> <div><strong>Sponsored Links</strong></div> </div> </td> </tr> <tr> <td class="freewebs_data"> <div style="padding:3px;"> <script type="text/javascript"><!-- google_ad_client = "pub-9358805988358620"; google_ad_width = 336; google_ad_height = 280; google_ad_format = "336x280_as"; google_ad_type = "text_image"; google_ad_channel ="0346520389"; google_color_border = "FFFFFF"; google_color_link = "0484CB"; google_color_bg = "FFFFFF"; google_color_text = "717171"; google_color_url = "717171"; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> </div> </td> </tr> </table> <br /> <?php // this is the default page = #1 if(!isset($_GET['page' ])) { $page = 1; } else { $page =$_GET ['page' ]; } // Define the number of results per page $max_results = 10; // Figure out the limit for the query based on the current page number. $from = (( $page *$max_results ) - $max_results ); $getfreeoss = "SELECT * FROM freeoss WHERE Status = '1' and OSSCategoryId=".$cat_id." ORDER BY Hits DESC LIMIT $from, $max_results"; $freeossrs = mysql_query($getfreeoss, $conn) or die (mysql_errno() . ": " . mysql_error()). "\n"; while($freeoss = mysql_fetch_array($freeossrs)) { $ossid = $freeoss['FreeOSSId']; $ossname = $freeoss['Name']; $description = $freeoss['Description']; $url = $freeoss['URL']; $demo = $freeoss['DemoURL']; $download = $freeoss['DownloadURL']; ?> <table cellpadding="2" cellspacing="1" class="freewebs_layout"> <tr> <td style="background-color:#f8f8f8;"> <div style="padding:2px 0px 2px 2px;"> <div><a href="/ossjump/<?php echo $ossid; ?>.html" target="_blank"><strong><?php echo $ossname; ?></strong></a></div> </div> </td> <td align="right" style="background-color:#f8f8f8;"> <div style="font-size:10px; padding:2px;"> <a href="/ossjump/<?php echo $ossid; ?>.html" target="_blank">Home</a> | <a href="<?php echo $demo; ?>" target="_blank">Demo</a> | <a href="<?php echo $download; ?>" target="_blank">Download</a> </div> </td> </tr> <tr> <td class="freewebs_data" colspan="2"> <div style="padding:3px;"> <div style="text-align:justify;"><?php echo $description; ?></div> </div> </td> </tr> </table> <br /> <?php } mysql_free_result($freeossrs); // Figure out the total number of results in DB: $total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM freeoss WHERE Status ='1' and OSSCategoryId=".$cat_id."" ), 0); // Figure out the total number of pages. Always round up using ceil() $total_pages =ceil ($total_results /$max_results ); ?> <div class="pagination"> <strong>Page: </strong> <?php // Build Previous Link if( $page>1) { $prev = ( $page -1); echo "<a href=\"/opensource/".$cat_id."/page".$prev.".html\"><img src=\"/images/prev.gif\" alt=\"\" /> " ; } for( $i =1;$i <= $total_pages ;$i ++) { if(( $page ) == $i ) { echo "<strong>$i</strong> "; } else { echo "<a href=\"/opensource/".$cat_id."/page".$i.".html\"><strong>$i</strong></a> " ; } } // Build Next Link if( $page <$total_pages ) { $next = ( $page +1); echo "<a href=\"/opensource/".$cat_id."/page".$next.".html\"> <img src=\"/images/next.gif\" alt=\"\" /></a>" ; } ?> </div> <?php mysql_close($conn) ?> </div> </td> <!-- right column //--> <td id="right_layout"> <div style="padding:0px 0px 10px 0px;" align="right"> <table cellpadding="0" cellspacing="0" class="box_layout"> <tr> <td valign="top" width="4"> <img src="/images/box_tl.gif" width="4" height="4" alt="" /></td> <td class="box_top" width="100%"><img src="/images/spacer.gif" alt="" /></td> <td valign="top" align="right" width="4"> <img src="/images/box_tr.gif" width="4" height="4" alt="" /></td> </tr> <tr> <td colspan="3" class="box_content"> <div style="padding:0px 2px 0px 3px;"> <div class="heading" align="left"> <a href="/directory">Webmaster Directory</a></div> <div style="float:left; padding:3px 5px 5px 5px;"><img src="/images/directory.gif" alt="webmaster directory" /></div> <div align="left">Submit your site to our search-engine friendly webmaster directory.</div> </div> </td> </tr> <tr> <td valign="top"> <img src="/images/box_bl.gif" width="4" height="4" alt="" /></td> <td class="box_bottom"><img src="/images/spacer.gif" alt="" /></td> <td valign="top"> <img src="/images/box_br.gif" width="4" height="4" alt="" /></td> </tr> </table> </div> <div style="padding:0px 0px 10px 0px;" align="right"> <table cellpadding="0" cellspacing="0" class="box_layout"> <tr> <td valign="top" width="4"> <img src="/images/box_tl.gif" width="4" height="4" alt="" /></td> <td class="box_top" width="100%"><img src="/images/spacer.gif" alt="" /></td> <td valign="top" align="right" width="4"> <img src="/images/box_tr.gif" width="4" height="4" alt="" /></td> </tr> <tr> <td colspan="3" class="box_content"> <div style="padding:0px 2px 0px 3px;"> <div class="heading" align="left"> <a href="/hosting.php">Premium Web Hosting</a></div> <div style="float:left; padding:3px 5px 5px 5px;"><img src="/images/hosting.gif" alt="cheap web hosting" /></div> <div align="left">Browse our directory of premium and professional web hosting providers.</div> </div> </td> </tr> <tr> <td valign="top"> <img src="/images/box_bl.gif" width="4" height="4" alt="" /></td> <td class="box_bottom"><img src="/images/spacer.gif" alt="" /></td> <td valign="top"> <img src="/images/box_br.gif" width="4" height="4" alt="" /></td> </tr> </table> </div> <div style="padding:0px 0px 10px 0px;" align="right"> <table cellpadding="0" cellspacing="0" class="box_layout"> <tr> <td valign="top" width="4"> <img src="/images/box_tl.gif" width="4" height="4" alt="" /></td> <td class="box_top" width="100%"><img src="/images/spacer.gif" alt="" /></td> <td valign="top" align="right" width="4"> <img src="/images/box_tr.gif" width="4" height="4" alt="" /></td> </tr> <tr> <td colspan="3" class="box_content"> <div style="padding:0px 2px 0px 3px;"> <div class="heading" align="left"> <a href="http://www.ourwebsite.com" target="_blank">Premium Web Templates</a></div> <div style="float:left; padding:3px 5px 5px 5px;"><img src="/images/templates.gif" alt="premium web templates" /></div> <div align="left">High-end professional website templates at a very affordable prices.</div> </div> </td> </tr> <tr> <td valign="top"> <img src="/images/box_bl.gif" width="4" height="4" alt="" /></td> <td class="box_bottom"><img src="/images/spacer.gif" alt="" /></td> <td valign="top"> <img src="/images/box_br.gif" width="4" height="4" alt="" /></td> </tr> </table> </div> <div style="padding:0px 0px 10px 0px;" align="right"> <table cellpadding="0" cellspacing="0" class="box_layout"> <tr> <td valign="top" width="4"> <img src="/images/box_tl.gif" width="4" height="4" alt="" /></td> <td class="box_top" width="157"><img src="/images/spacer.gif" alt="" /></td> <td valign="top" align="right" width="4"> <img src="/images/box_tr.gif" width="4" height="4" alt="" /></td> </tr> <tr> <td colspan="3" class="box_content"> <div style="padding:3px 0px 3px 0px;" align="right"> <script type="text/javascript"><!-- google_ad_client = "pub-9358805988358620"; google_ad_width = 160; google_ad_height = 600; google_ad_format = "160x600_as"; google_ad_type = "text_image"; google_ad_channel ="0346520389"; google_color_border = "FFFFFF"; google_color_link = "0484CB"; google_color_bg = "FFFFFF"; google_color_text = "717171"; google_color_url = "717171"; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> </div> </td> </tr> <tr> <td valign="top"> <img src="/images/box_bl.gif" width="4" height="4" alt="" /></td> <td class="box_bottom"><img src="/images/spacer.gif" alt="" /></td> <td valign="top"> <img src="/images/box_br.gif" width="4" height="4" alt="" /></td> </tr> </table> </div> </td> <!-- end right column //--> <?php include_once("footer.php"); ?> </body> </html> Code (markup):
Ok thats actually got the styled page to load but in the page im now getting these errors Notice: Undefined variable: oss_category in /home/content/w/e/b/webmasterranks/html/opensource.php on line 39 Code (markup): 1064: 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 'ORDER BY Hits DESC LIMIT 0, 10' at line 1 Code (markup): Thanks for looking at this by the way , really appreciate it