Jump to content

I cant figure out why: LOOK AT THIS POST OR I KILL A RUBBER DUCKY!


Recommended Posts

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 :(

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;
}
?>

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";

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.

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!!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.