Forum Moderators: coopster

Message Too Old, No Replies

PHP & MSSQL

Syntax correction sought

         

trebian

2:19 pm on Jun 10, 2004 (gmt 0)

10+ Year Member



Hi forum. I am using PHP to connect to a MS-SQL Server.

In my SQL statement this snippet of code is giving me error:
[/CODE]
... DATEPART(m, Changedate) ...
more statements...
[/CODE]

I looked at online docs -Microsoft, the syntax is correct as far as I could tell, but this is where the SQL errors out...

The variable Changedate is a date and time column as:
2003-11-30 00:00:00

Any ideas?

Timotheos

3:45 pm on Jun 10, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hmmm... that seems strange. What sort of error are you getting? Does DATENAME(m, Changedate) work?

trebian

7:44 pm on Jun 10, 2004 (gmt 0)

10+ Year Member



The error is no print back of any print_r() or var_dum() that I do.

What is confusing is if I have code like this:


mssql_select_db ("Change");
$result = mssql_query ("SELECT Changedate as tim, COUNT(Changedate) as total
from ChangeItems
where Changedate = '2004-06-08 00:00:00' ");
mssql_close($link);

while ($row=mssql_fetch_assoc($result)) {
$tim['tim'] = ($row['tim']);
$val['total'] = ($row['total']); }
print_r($tim);
print_r($val);

Nothing comes back

If I do :


mssql_select_db ("Change");
$result = mssql_query ("SELECT Changedate as tim, '100' as total
from ChangeItems
where Changedate = '2004-06-08 00:00:00' ");
mssql_close($link);

while ($row=mssql_fetch_assoc($result)) {
$tim['tim'] = ($row['tim']);
$val['total'] = ($row['total']); }
print_r($tim);
print_r($val);

I get a dump of variables.

What gives?

By the way no error comes back just empty browser, even though I have E_ALL enabled.

trebian

8:08 pm on Jun 10, 2004 (gmt 0)

10+ Year Member



Please disregard, I found couple of errors in my code.

Thank you for your time!