Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 02-08-2008, 04:34 PM Mysql syntax problem
andyp's Avatar
Extreme Talker

Posts: 165
Name: andy patterson
Trades: 0
I keep on getting the error shown on my homepage, http://ap-gfx.com. In my PHP I have this;
PHP Code:
//pagination
   
$cur = (($page $max) - $max); 
   
   if( 
$_GET['page']){ $page $_GET['page'];} else{ $page=1; }
   
   
$counttotal1 mysql_query("SELECT * FROM articles ") or die(mysql_error()); // select all records        
   
$counttotal mysql_num_rows($counttotal1); // count records
    
   
$max "8";
   
$totalpages ceil($counttotal $max);
   
   if(
$page 1){ // is the page number more than 1?
                
$prev = ($page 1); // if so, do the following. take 1 away from the current page number
                
echo '<a href="?page=" . $prev . "">« Previous</a>'// echo a previous page link
                
}
   for(
$i 1$i <= $total_pages$i++) // for each page number
                
{
                    if(
$page == $i// if this page were about to echo = the current page
                        
{
                            echo 
'<b>" . $i . "</b> '// echo the page number bold
                                
} else {
                            echo 
'<a href="?page=' $i '>' $i '</a> '// echo a link to the page
                        
}
                }
   if(
$page $totalpages){ // is there a next page?
                    
$next = ($page 1); // if so, add 1 to the current
                
echo '<a href="?page=' $next '">Next »</a>'// echo the next page link
                    
}    
    
   
   if( !isset( 
$_GET['category'] ))
   { 
$sql "select * from articles order by date_added desc limit '$cur','$max'"; }
   else
   {
    
$cat $_GET['category'];
    
$sql "select * from articles where category='$cat' order by date_added desc limit '$cur','$max'";
    
   } 
andyp is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-08-2008, 04:43 PM Re: Mysql syntax problem
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Code:
select * from articles where category='$cat' order by date_added desc limit '$cur','$max'
First, the limit values are numeric, not strings. Drop the '
Second, but this is minor, the correct SQL syntax is
Code:
LIMIT {how_many} OFFSET {starting_row}
So, I would suggest you to try
Code:
select * from articles where category='$cat' order by date_added desc limit $cur offset $max
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 02-09-2008, 05:04 AM Re: Mysql syntax problem
kids's Avatar
Ultra Talker

Posts: 301
Trades: 0
Simply:
PHP Code:
$sql"select * from articles where category='$cat' order by date_added desc limit $cur,$max
Not: '$cur' , '$max'

I dunt have any problems with upper sql string
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
kids is offline
Reply With Quote
View Public Profile Visit kids's homepage!
 
Reply     « Reply to Mysql syntax problem
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.11486 seconds with 12 queries