Jump to content

whats wrong with this?


rex9990

Recommended Posts

Here is code i have and im a bit confused about

 

$charset='UTF-8';
$page1  =  htmlentities ($_GET['page'], ENT_NOQUOTES, $charset);
if(!isset($page1)){ 
    $page = 1; 
} else { 
    $page = '$page1'; 
} 
$max_results = 10; 
$from = (($page * $max_results) - $max_results);

 

it gives me the error

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 '-10, 10' at line 1

 

but if i change "if(!isset($page1))" to "if(!isset($test))" it excutes the page right but with some smaller errors :|

Can anyone see whats going wrong?

Thanks

Steve

Link to comment
Share on other sites

Well, I'm not sure what you are trying to accomplish with the htmlentities() command (you should be validating that the value is a whole number). But, your problem is this line:

$page = '$page1';

 

It is setting $page to the string value of "$page1". In fact there is no reason for that line at all:

 

$charset='UTF-8';
$page  =  htmlentities ($_GET['page'], ENT_NOQUOTES, $charset);

if(!isset($page)){ 
    $page = 1; 
} 

$max_results = 10; 
$from = (($page * $max_results) - $max_results);

 

Although I still think you should be doing a different validation other than htmlentities().

 

Link to comment
Share on other sites

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.