Welcome Guest, Not a member yet? Register   Sign In
Help my SQL please !!
#1

[eluser]satanrulehis[/eluser]
hi all!!
My SQL statement doesn’t work when I add $num, $offset into it

Code:
$sql = "SELECT c.name as catalogname,p.id,p.name,p.product_code,p.small_pic,p.price FROM  product p, product_catalog c where c.id=".$catalogid." and c.id=p.catalog_id and p.active=1 limit ".$offset.",".$num;

Tell me what's wrong??

thanks for reading
#2

[eluser]jalalski[/eluser]
What is the error?
How about if you put hard numbers in there ( "... limit 0,5")?
#3

[eluser]satanrulehis[/eluser]
I can't put hard number because I have pagination
#4

[eluser]jedd[/eluser]
[quote author="satanrulehis" date="1237645275"]I can't put hard number because I have pagination[/quote]

I think they mean for testing. Not forever.

Have you used the [url="http://ellislab.com/codeigniter/user-guide/general/profiling.html"]Profiling system[/url] to see what the actual SQL query is that gets passed to the DB? Often very handy with these types of problems.
#5

[eluser]TheFuzzy0ne[/eluser]
I think he meant for testing purposes.

I'm guessing that one of those numbers is probably FALSE or 0, or ''. Add this to your controller's constructor, and you'll be able to see the query.

Code:
$this->output->enable_profiler(TRUE);
#6

[eluser]jedd[/eluser]
I feel a disturbance in the force.
#7

[eluser]TheFuzzy0ne[/eluser]
You must be a Jedd-i knight.




Theme © iAndrew 2016 - Forum software by © MyBB