Dethman Posted July 26, 2008 Share Posted July 26, 2008 Heres the function: function showCatigories(){ //Global Call For $rowsPerPage $rowsPerPage=8; global $rowsPerPage; $offset = ($pageNum - 1) * $rowsPerPage; $offset2=$pageNum*$rowsPerPage; //Query Var: $q="SELECT * FROM `GLASS_CATIGORIES` WHERE `id` > 0 ORDER BY `id` ASC LIMIT $offSet, $rowsPerPage"; //Query $v=mysql_query($q) or die("Unable to Select All From C-MORE-GLASS_CATIGORIES And Ascend: ".mysql_error()); $row=mysql_fetch_array($v); $count=mysql_num_rows($v); if($count==0){ $catigories=("<div class='black-box'><td colspan=4 align=center><b><i>There are no Catigories Added to the System Yet. Try back at a later time</b></i></td></div>"); } else{ while($row=mysql_fetch_array($v)){ $catigories=(" <div class='black-box'> <h2><em>".$row['name']."</em> collection</h2> <p><img src='img/src/".$row['src']."' width='120' height='105' alt='Pic ".$row['id']."' /></p> <p>".$row['info']."</p> <p class='more'><a href='index.php?page=".$row['page']."'>More</a></p> </div> "); } } return $catigories; } My SQL Error: Unable to Select All From C-MORE-GLASS_CATIGORIES And Ascend: 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 Please Help I cant figure this out Quote Link to comment https://forums.phpfreaks.com/topic/116678-i-cant-figure-out-why-look-at-this-post-or-i-kill-a-rubber-ducky/ Share on other sites More sharing options...
Lodius2000 Posted July 26, 2008 Share Posted July 26, 2008 please use <?php and ?> tags <?php function showCatigories(){ //Global Call For $rowsPerPage $rowsPerPage=8; global $rowsPerPage; $offset = ($pageNum - 1) * $rowsPerPage; $offset2=$pageNum*$rowsPerPage; //Query Var: $q="SELECT * FROM `GLASS_CATIGORIES` WHERE `id` > 0 ORDER BY `id` ASC LIMIT $offSet, $rowsPerPage"; //Query $v=mysql_query($q) or die("Unable to Select All From C-MORE-GLASS_CATIGORIES And Ascend: ".mysql_error()); $row=mysql_fetch_array($v); $count=mysql_num_rows($v); if($count==0){ $catigories=("<div class='black-box'><td colspan=4 align=center><b><i>There are no Catigories Added to the System Yet. Try back at a later time</b></i></td></div>"); } else{ while($row=mysql_fetch_array($v)){ $catigories=(" <div class='black-box'> <h2><em>".$row['name']."</em> collection</h2> <p><img src='img/src/".$row['src']."' width='120' height='105' alt='Pic ".$row['id']."' /></p> <p>".$row['info']."</p> <p class='more'><a href='index.php?page=".$row['page']."'>More</a></p> </div> "); } } return $catigories; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/116678-i-cant-figure-out-why-look-at-this-post-or-i-kill-a-rubber-ducky/#findComment-599900 Share on other sites More sharing options...
Dethman Posted July 26, 2008 Author Share Posted July 26, 2008 I usually do but forgot this time :S Quote Link to comment https://forums.phpfreaks.com/topic/116678-i-cant-figure-out-why-look-at-this-post-or-i-kill-a-rubber-ducky/#findComment-599902 Share on other sites More sharing options...
.josh Posted July 26, 2008 Share Posted July 26, 2008 I think your problem is that $pageNum is not being assigned or passed inside or to the function. This is making your offset -8 which there's no such thing. Quote Link to comment https://forums.phpfreaks.com/topic/116678-i-cant-figure-out-why-look-at-this-post-or-i-kill-a-rubber-ducky/#findComment-599919 Share on other sites More sharing options...
JasonLewis Posted July 26, 2008 Share Posted July 26, 2008 You are using this: $q="SELECT * FROM `GLASS_CATIGORIES` WHERE `id` > 0 ORDER BY `id` ASC LIMIT $offSet, $rowsPerPage"; You have a capital S in offset. Your variable is just '$offset' Change it to this: $q="SELECT * FROM `GLASS_CATIGORIES` WHERE `id` > 0 ORDER BY `id` ASC LIMIT $offset, $rowsPerPage"; Quote Link to comment https://forums.phpfreaks.com/topic/116678-i-cant-figure-out-why-look-at-this-post-or-i-kill-a-rubber-ducky/#findComment-599946 Share on other sites More sharing options...
PFMaBiSmAd Posted July 26, 2008 Share Posted July 26, 2008 Echo $q to see what it actually contains. It at least has the problem ProjectFear discovered, but your setting of $rowsPerPage=8; and global $rowsPerPage; is incorrect. The global keyword makes a global variable (defined in the main program) available inside of a function. It does not make a variable that you define inside of a function global. Doing either of these is poor coding. For the problem that ProjectFear has pointed out, when learning php, developing php code, or debugging php code, always turn on full php error reporting to get php to help you find problems like variable names that don't exist. Quote Link to comment https://forums.phpfreaks.com/topic/116678-i-cant-figure-out-why-look-at-this-post-or-i-kill-a-rubber-ducky/#findComment-600029 Share on other sites More sharing options...
AndyB Posted July 26, 2008 Share Posted July 26, 2008 From your error message, the query is looking for a table named C-MORE-GLASS_CATIGORIES ... that will be parsed as a table named C minus MORE minus GLASS_CATIGORIES. Hardly surprising that you get an error!! Quote Link to comment https://forums.phpfreaks.com/topic/116678-i-cant-figure-out-why-look-at-this-post-or-i-kill-a-rubber-ducky/#findComment-600098 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.