MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 23rd, 2012, 06:07 AM
accend accend is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2012
Posts: 2 accend User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 48 m 56 sec
Reputation Power: 0
Problem connecting to database

Hi all,

I'm usually developing using MySQL but now I got a project using MSSQL and having trouble even at the first hurdle.

I got a config.php file:

PHP Code:
 $hostName "csfdb01";
$databaseName "CSF_Intranet";
$username "x";
$password "x"


I know the username and password are correct.

Then I have a page with a include for the config file and bit of code and the rest of the page is html.

When I refersh the page the php code at the top is stopping the html from showing, so wondered if somebody could have a look and see if there any code issues, or ways of seeing if Im connecting to the database OK, as no errors are showing up either.

Code:
<?php
include "config.php";
if (!($connection = @ mssql_connect($hostName, $username, $password)))
die("error connecting");

if (!mssql_select_db($databaseName, $connection))
die("no db");
?>
<html>
<head>
<title>CSF Admin</title>
</head>
<body link="white" vlink="white">
<div align="center">
<p>
<font size="2" color="#990000" face="Verdana,Arial,Helvetica,sans-serif">Website Master - administration panel</font>
</p>
<div align="center"><font face="tahoma" color="#FF0000" size="2"><b><?php echo $error1; ?></b></font></div>
<table align="center" width="371" bordercolor="#00CCFF" bordercolordark="#0099FF" border="0" cellpadding="5" cellspacing="2">
<tr>
<td width="50%" height="45" style="background-image:url(images/admin_Grey_Bar_Small.jpg)">
<div style="font-family:Verdana, Arial, Helvetica, sans-serif; position:relative; font-size:13px; color:#ffffff; font-weight:bold; position:relative; float:left; left:20px; top:-2px;">
<?
function welcome(){

if(date("H") < 12){

return "Good morning - Log in below.";

}elseif(date("H") > 11 && date("H") < 18){

return "Good afternoon - Log in below.";

}elseif(date("H") > 17){

return "Good evening - Log in below.";

}

}
 echo welcome();
?>
</div>
</td>
</tr>
<tr>
<td bgcolor="666666" width="350" valign="top">
<div align="center" style="width:350px">
<form action="index.php" method="post" name="FormName">
<table width="322" border="0" cellspacing="10" cellpadding="0">
<tr>
<td><font size="2" color="#ffffff" face="Verdana,Arial,Helvetica,sans-serif">User:</font></td>
<td><input type="text" name="txtuser" size="24"></td>
</tr>
<tr>
<td><font size="2" color="#ffffff" face="Verdana,Arial,Helvetica,sans-serif">Password:</font></td>
<td><input type="password" name="txtpass" size="24"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="login" value="Log In"></td>
</tr>
</table>
</form>
<table>
<tr>
<td width="350">
<div style="position:relative; font-size:11px; color:#ffffff; float:right; width:350px; font-family:Verdana, Arial, Helvetica, sans-serif; text-align:right;">CMS V.1</div>
</td>
</tr>
</table>
</div>
</td>
</tr>
</tr>
</table>
</div>
</body>
</html>

Reply With Quote
  #2  
Old March 23rd, 2012, 07:27 AM
accend accend is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2012
Posts: 2 accend User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 48 m 56 sec
Reputation Power: 0
I thought i would try and change the code and see if its that, againusing the config.php file, and the same happens where nothing beneath that php will display, the page is completely empty with no errors.

here is the new page:

PHP Code:
<?php
include "config.php";

// connection to the database
$dbhandle mssql_connect($hostName$username$password)
or die(
"Couldn’t connect to SQL Server on $hostName");

// select a database to work with
$selected mssql_select_db($databaseName$dbhandle)
or die(
"Couldn’t open database $myDB");

echo 
"You are connected to the" $databaseName "database on the" $hostName ".";

$query "SELECT * FROM Contract_Number"// your database query
$result mssql_query($query);
while(
$row mssql_fetch_assoc($result))
{
print_r($row);
}
// close the connection
mssql_close($dbhandle);
?>


Then
<html>

</html>

is beneath that but nothing benath that php will show, and it wouldnt be so bad if an error showed up but there nothing, if its not the code what could it be.

Reply With Quote
  #3  
Old March 23rd, 2012, 05:24 PM
E-Oreo's Avatar
E-Oreo E-Oreo is offline
Lost in code
Dev Shed God 7th Plane (8000 - 8499 posts)
 
Join Date: Dec 2004
Posts: 8,057 E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)  Folding Points: 945 Folding Title: Novice Folder
Time spent in forums: 2 Months 1 Day 6 h 4 m 32 sec
Reputation Power: 7104
Read FAQ #30; it's also applicable to "my page is blank below a certain point".

Most likely you don't have mssql extension installed/enabled.
__________________
PHP FAQ
How to program a basic, secure login system using PHP
Connect with me on LinkedIn


Quote:
Originally Posted by Spad
Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Problem connecting to database

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap