New to php. I am able to connect to my database and I can pull results from a table but when a date field is added in the mix then nothing is returned. It has something to do with trying to display the date but I am baffled as to the cause.
php
$serverName = “STISD-WEB01\STBOBCATS”;
$connectionInfo = array( “Database”=>“STBOBCATS”, “UID”=>“××××”, “PWD”=>“××××××”);
$conn = sqlsrv_connect( $serverName, $connectionInfo);if ($conn === false) die("
".print_r(sqlsrv_errors(), true));echo “Successfully connected!”;$sql = "SELECT TOP (5) EDate, Time, Event
FROM dbo.Events
WHERE (EDate >= GETDATE()) AND (IncludeOnHome = 1)
ORDER BY EDate";
$query = sqlsrv_query($conn, $sql);
if ($query === false)
{ exit("
".print_r(sqlsrv_errors(), true));}while ($row = sqlsrv_fetch_array($query))
{ $date = strtotime($row[Edate]); echo date("F j Y", $date), "<p> > $row[Event] </p>" ; }
sqlsrv_free_stmt($query);
Everthing connects. If I run echo date(“F j Y”, $date), "
> $row[Event]
" I get an incorrect date 12/31/1969 and the events
If I run echo "> $row[Event]
" I get the events
If I run echo "$row [EDate] > $row[Event]
" I get no resultsPlayed around with variations but can’t get the dates in the table to display.