Re: mysql_fecth_array() and function call as parameter

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

 



I included the or die function on the end of my query statement.  When
I tested this on my web page I got the following error

Query2 Failed: You have an error in your SQL syntax near '(curdate())' at line 1

When this code executed:

$query2 = mysql_query("SELECT dayNum FROM Days WHERE dayNum = day(curdate())") ;

I can't see where the error is.  Can anyone see the error?

The table name is correct because I have another drop down box that
gets all dates in the table and outputs it with no error.  I also
tested the above SQL statement on a local copy of mysql (version
5.0.18-nt) and it worked with out any errors.  And this code works on
a different web server. Mysql client version 3.23.49.  However it does
not work on mysql client version 3.23.54.  Also both php versions are
the same.

Thanks
Paul

On 4/3/06, Jon Drukman <jsd@xxxxxxxxxxxxx> wrote:
> Paul Goepfert wrote:
>
> > function determineDay ()
> >       {
> >               $return = "";
> >               $query1 = mysql_query("SELECT months FROM Month WHERE m_id =
> > month(curdate())");
> >               $query2 = mysql_query("SELECT dayNum FROM Days WHERE dayNum =
> > day(curdate())");
> >               $query3 = mysql_query("SELECT year FROM Year WHERE year = year(curdate())");
>
> always Always ALWAYS check the error return!!!
>
> $query1 = mysql_query("SELECT months FROM Month WHERE m_id =
> month(curdate())") or die("query1 failed: " . mysql_error());
>
> do this religiously on every single mysql_query.  in fact, write a
> wrapper function to do it for you - that's what i do.
>
> > If anyone can find my error please let me know.  I have looked at this
> > for about an hour and I can't figure it out.
>
> you probably could have saved an hour by checking the error code.
>
> -jsd-
>

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



[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