Re: Re: What wrong am I doing now?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jul 24, 2013 at 2:45 PM, Jim Giner <jim.giner@xxxxxxxxxxxxxxxxxx>wrote:

> On 7/24/2013 8:19 AM, Karl-Arne Gjersøyen wrote:
>
>> mysql> SELECT DATE_FORMAT(dato, '%e-%c-%Y') FROM transportdokument WHERE
>> dato >= '2013-07-20' AND dato <= '2013-07-24' GROUP BY dato DESC;
>> +-----------------------------**--+
>> | DATE_FORMAT(dato, '%e-%c-%Y') |
>> +-----------------------------**--+
>> | 24-7-2013                     |
>> | 23-7-2013                     |
>> +-----------------------------**--+
>> 2 rows in set (0.00 sec)
>>
>> mysql>
>>
>>
>> // My PHP code looks like this.
>> // ------------------------------**-----------
>> $sql = "SELECT DATE_FORMAT(dato, '%e-%c-%Y') FROM transportdokument WHERE
>> dato >= '2013-07-20' AND dato <= '2013-07-24' GROUP BY dato DESC";
>> $resultat = mysql_query($sql, $tilkobling) or die(mysql_error());
>>
>> while($rad = mysql_fetch_array($resultat)){
>> $dato = $rad['dato'];
>> var_dump($dato);
>>
>> I gott NULL,NULL here and believe it is something with my PHP Source that
>> is wrong when using DATE_FORMAT. As you see above it work in terminal.
>>
>> I hope this not is off-topic for the list. If so, I am sorry for it and
>> hope you can give me advice about a good MySQL list for newbie's.
>>
>> Thanks again for your help!
>>
>> Karl
>>
>>  Add a check on the query result to be sure your query actually ran.
>
> > $resultat = mysql_query($sql, $tilkobling) or die(mysql_error());
> >
> if (!$resultat)
> {
>    echo "Query failed to run - ".mysql_error();
>    exit();
> }
> > while($rad = mysql_fetch_array($resultat)){
> ....
> ...
>
>
Jim,

He already has that...

- Matijn

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux