|
Posted by ste on 05/11/06 04:13
"Rik" <luiheidsgoeroe@hotmail.com> wrote in message
news:e3i4l7$ivk$1@netlx020.civ.utwente.nl...
> ste wrote:
>> <?php
>> include("databasepasswords");
>> if (isset($_GET['pageno'])) {
>> $pageno = $_GET['pageno'];
>
> Tssk, if thought I told you to escape GET variables if used in queries
> :-).
> $pageno = mysql_real_escape_string(_GET['pageno'],$connection);
>
>> $query = "SELECT count(*) FROM images ".$where;
>> $result = mysql_query($query) or trigger_error("SQL", E_USER_ERROR);
>
> As said, $where whould be set BEFORE this query.
>
>> $query = "SELECT * FROM images ORDER BY dateadded,
>> datetaken DESC $limit ".$where ;
>
> Echo this query and you'll see what's wrong. It should be
>
> $query = "SELECT * FROM images ORDER BY `dateadded`, `datetaken` DESC
> $where
> $limit";
>
> Wether your code creates proper pages I'm not going to check.
>
> For future reference:
> Echoing variables after they are set or print_r() arrays will make a lot
> more clear to you in debugging.
> In this instance, echoing the query would have told you right away the
> query
> was composed in the wrong order.
>
> Grtz,
> --
> Rik Wasmus
Hi Rik,
I echo'd the actual query to see what was failing, then I tried the query in
question in MyPHPAdmin to see if it worked there, and it didn't of course.
After a bit of trial and error, I have changed the query from:
SELECT *
FROM images
ORDER BY dateadded, datetaken DESC
LIMIT 0,9
WHERE category = 'Abstract'
To:
SELECT *
FROM images
WHERE category = 'Abstract'
ORDER BY dateadded, datetaken
LIMIT 0 , 9
....and this now works! :-)
Thanks again,
Ste
Navigation:
[Reply to this message]
|