connecting to remote server database, displays blank page
Posted: Fri Jan 14, 2011 12:06 pm
Hey guys,
I could really use some help understanding what i am doing wrong here and i will try to explain everything the best i can. I am currently running apache on my local computer for work. I am trying to generate a a webpage to run on my computer that will call some sql statements. The database is located on server04. I can use i can use microsoft sql server 2005 express studio just fine to query the data base. I am completely new to php. But i have the apache installed and configured for php and also am putting php page to the htdocs file. Here is the current script i am using (and of course i am changing server, un, dba etc to what it should be:
<?php
$con = mysql_connect("server","un","pw");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("database", $con);
$result = mysql_query("select count(*) from customerordermaster with (nolock)
where shipdate >=
(cast(datepart (mm, getdate()) as nvarchar) +'/'+
cast (datepart( dd, getdate()) as nvarchar) +'/'+
cast(datepart(yyyy, getdate()) as nvarchar))
");
while($row = mysql_fetch_array($result));
?>
Everytime i save this and open it up in the browser by going to the address bar and type localhost/sql.php . But only a blank page displays. Does not even show the text from the document. I have tried variations in the code and even put a kill function in there to release the connection. and i have put it in the middle of <body> on an html doc. any help would be very much appreciated!
I could really use some help understanding what i am doing wrong here and i will try to explain everything the best i can. I am currently running apache on my local computer for work. I am trying to generate a a webpage to run on my computer that will call some sql statements. The database is located on server04. I can use i can use microsoft sql server 2005 express studio just fine to query the data base. I am completely new to php. But i have the apache installed and configured for php and also am putting php page to the htdocs file. Here is the current script i am using (and of course i am changing server, un, dba etc to what it should be:
<?php
$con = mysql_connect("server","un","pw");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("database", $con);
$result = mysql_query("select count(*) from customerordermaster with (nolock)
where shipdate >=
(cast(datepart (mm, getdate()) as nvarchar) +'/'+
cast (datepart( dd, getdate()) as nvarchar) +'/'+
cast(datepart(yyyy, getdate()) as nvarchar))
");
while($row = mysql_fetch_array($result));
?>
Everytime i save this and open it up in the browser by going to the address bar and type localhost/sql.php . But only a blank page displays. Does not even show the text from the document. I have tried variations in the code and even put a kill function in there to release the connection. and i have put it in the middle of <body> on an html doc. any help would be very much appreciated!