> > Talking under correction, but you'll be better of using a TIME column in
> > MySQL.  You can also do all the calculations with MySQL's build in time
> > functions already, which will save you allot of time, seeing that all
the
> > calculations can be done via a single SQL query.
>
> Yes, this is the first thing I thought, but doing this I get an error when
> getting the records.. I'm using the following code:
>
> <SNAP>
> $result = mysql_query("SELECT * FROM tableNameWHERE field LIKE
> '%$expression%'");

--  add a mysql_error() here to see if the SELECT actually executes and
retrieve any data back from MySQL.  That LIKE '%$expression%' looks a bit
funny to me - it might be worth your while to debug it properly.  If it
doesn't return any errors and the query is just empty, you can make sure it
has data before running the while () loop, by using something like:

if (mysql_num_rows($result) > 0) {

> while ($line = mysql_fetch_array($result)) {
>    $startTime   = $linea["startTime"];
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  If it's copied and pasted, there's
your error $linea ....
>    $stopTime    = $line["stopTime"];
> }
> <SNAP>
}

If it's not, it's *rather* parculiar why it's not working...  Myself, and
allot of other people on here use TIME / DATETIME columns all the time with
very good success rates...

> If the fields are CHAR or VARCHAR I got no problem, but if a use a TIME
type

Which, just makes me think even more that your SQL statement's LIKE clause
isn't right....

> I get the following error:
> "Warning: Supplied argument is not a valid MySQL result resource in
> /var/www/text.php on line XX"

Which, tells me that your SQL statement isn't returning any data.  If you
change the columns to TIME types, and execute the query manualy via mysql,
SELECT * FROM tableName WHERE field LIKE '%09:00%';  Does the SQL statement
actually work, without any errors back from MySQL?? I think you're
$expression, needs to be more like WHERE field LIKE '$expression%' (if
$expression contains a hour), or LIKE '%$expression' if $expression contains
a minute.  Escaping the $expression might also be beneficiul, I'm not sure
if it is required, but I normally do it as a standard way of coding: WHERE
field LIKE '" . $expression . "%'.

Another possible thing you can try, is to debug it.... mysql_error() is very
helpfull, trust me on this.  I also started off implementing mysql lookups
without error checking and posted rather silly mistakes to the list which
could have easily been avoided just debugging the code properly (not that
I'm not saying you don't have a serious problem here, or that I'm taking on
anything personal or anything) - just merly making a observation...

--
me




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to