Problem Solved Thanks to Everyone who Helped
![]()
| SitePoint Sponsor |
Problem Solved Thanks to Everyone who Helped
![]()
Last edited by tnrstudios; Jul 29, 2005 at 18:49.





PHP Code:$query = "SELECT category FROM stuff_emotions WHERE $cat = 'category' LIMIT $limitvalue, $limit";
Something obvious like adding quotes around category?
Try this:
edit: darn, a little too latePHP Code:$query = "SELECT category FROM stuff_emotions WHERE $cat = 'category' LIMIT $limitvalue, $limit";
![]()
Don't Drink & Surf The Net
I tried both examples and neither worked![]()





Then most likely one of your variables is blank? Try echoing out the query before running the query to see if the correct variable is being passed.
Silly
Not sure if this helps but here's the rest of the script:
PHP Code:@mysql_select_db("tnrstudi_emotions") or die("ERROR--CAN'T CONNECT TO DB");
$limit = 12;
$query_count = "SELECT * FROM stuff_emotions";
$result_count = mysql_query($query_count);
$totalrows = mysql_num_rows($result_count);
if(empty($page)){
$page = 1;
}
$limitvalue = $page * $limit - ($limit);
$query = "SELECT category FROM stuff_emotions WHERE $cat = 'category' LIMIT $limitvalue, $limit";
$result = mysql_query($query) or die("Error: " . mysql_error());
if(mysql_num_rows($result) == 0){
echo("Nothing to Display!");
}
$bgcolor = "#E0E0E0"; // light gray
$counter = "1";
echo("<table cellspacing=3 cellpadding=5><tr>");
while($row = mysql_fetch_array($result)){
if ($bgcolor == "#FFFFFF"){
$bgcolor = "#FFFFFF";
}else{
$bgcolor = "#FFFFFF";
}
if ($row["category"] == $cat)
{
$counter += 1;
echo("<td bgcolor=".$bgcolor."><TABLE><TR><TD height=125 width=125>");
echo("<a href=show.php?id=");
echo($row["id"]);
echo("><img border=0 src=http://www.messenger-stuff.com/files/");
echo($row["type"]);
echo("/");
echo($row["category"]);
echo("/");
echo($row["filename"]);
echo("></a><BR><p>");
echo($row["filename"]);
echo("<BR><i>");
echo($row["size"]);
echo(" bytes</i></p></TD></TR></TABLE></TD>");
if ($counter == "4"){
echo "</TR><TR>";
$counter = "1"; }
}
}
echo("</tr></table>");
if($page != 1){
$pageprev = $page -1;
echo("<a href=\"$PHP_SELF?page=$pageprev\">PREVIOUS PAGE</a> ");
}else{
echo("PREV".$limit." ");
}
$numofpages = $totalrows / $limit;
for($i = 1; $i <= $numofpages; $i++){
if($i == $page){
echo($i." ");
}else{
echo("<a href=\"$PHP_SELF?page=$i&cat=$cat\">$i</a> ");
}
}
if(($totalrows - ($limit * $page)) >= 0){
if($i == $page){
echo($i." ");
}else{
echo("<a href=\"$PHP_SELF?page=$i&cat=$cat\">$i</a> ");
}
}
if(($totalrows - ($limit * $page)) > 0){
$pagenext = $page +1;
echo("<a href=\"$PHP_SELF?page=$pagenext&cat=$cat\">NEXT PAGE</a>");
}else{
echo("NEXT".$limit);
}
mysql_free_result($result);
?>
I echoed the query beforehand and it was filled (it is defined by the url anyways ie: page.php?cat=abstract )
And I have the database full of entries where category = abstract so I don't know whats up!
EDIT: I am now getting:
with this query:Code:Error: Unknown column 'abstract' in 'where clause'
PHP Code:$query = "SELECT * FROM stuff_emotions WHERE $cat = category LIMIT $limitvalue, $limit";
PHP Code:$query = "SELECT * FROM stuff_emotions WHERE category = '$cat' LIMIT $limitvalue, $limit";
Don't Drink & Surf The Net
Using Gonik's example, I changed the query to:
And now the script works except for it is returning nothing :OPHP Code:$query = "SELECT * FROM stuff_emotions WHERE category = '$cat LIMIT $limitvalue, $limit'";
PHP Code:$query = "SELECT category FROM stuff_emotions WHERE category = '$cat' LIMIT $limitvalue, $limit";
ya that is returning the same thing freakysid
echo out the value of $query and then cut and paste it into an SQL query and see what result you get (either using mysql from the shell or phpMyAdmin).
I got it working when i used:
But when I added the limit statement:PHP Code:$query = "SELECT category FROM stuff_emotions where category = '".$cat."'";
It didn't return anything!PHP Code:$query = "SELECT category FROM stuff_emotions where category = '".$cat."' category = 'ategory LIMIT $limitvalue, $limit'"";
try this:
regardsPHP Code:$query = "
SELECT category
FROM stuff_emotions
WHERE category = '".$cat."'
LIMIT $limitvalue, $limit
";



Why do you keep using the wrong SQL even when other's have posted it correctly so many times.
Use that to replace what you have right now. And if it doesn't work, please paste the query echoed in your page so that we can figure out what's wrong.Code:$query = "SELECT category FROM stuff_emotions WHERE `category` = '$cat' LIMIT $limitvalue, $limit"; echo $query;
Problem is Fixed thanks to all who helped![]()
Bookmarks