Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
warriorforgod
Forum Newbie
Posts: 15 Joined: Tue Jun 02, 2009 11:16 am
Post
by warriorforgod » Tue Jun 02, 2009 11:36 am
I am using the following script to connect to a mssql 2005 database, however when I bring up the page nothing displays. I am a php newb so go easy on me.
Code: Select all
<?php
error_reporting(E_ALL);
$dbuser='username';
$dbname='database name';
$server='servername';
$connect = mssql_connect($server, $dbuser) or die (mysql_error());
mssql_select_db($dbname, $connect) or die (mysql_error());
echo("ConnectID: $numero<br>\n");
?>
mikemike
Forum Contributor
Posts: 355 Joined: Sun May 24, 2009 5:37 pm
Location: Chester, UK
Post
by mikemike » Tue Jun 02, 2009 12:01 pm
So far as this script goes $numero isn't set.
mssql_connect may very well not be connecting, in which case you're killing the script and calling mysql_error. Notice the obvious mistake here? You're connecting to a >MS< SQL server but trying to call >MY< SQL errors.
Have a read of
mssql_min_message_severity()
warriorforgod
Forum Newbie
Posts: 15 Joined: Tue Jun 02, 2009 11:16 am
Post
by warriorforgod » Tue Jun 02, 2009 1:57 pm
Ok. Changed the mysql to mssql and used the min_message_severity. Have tried all the options for this but still getting nothing displayed for error messages.
mikemike
Forum Contributor
Posts: 355 Joined: Sun May 24, 2009 5:37 pm
Location: Chester, UK
Post
by mikemike » Tue Jun 02, 2009 2:20 pm
Can you post the code you have again?
warriorforgod
Forum Newbie
Posts: 15 Joined: Tue Jun 02, 2009 11:16 am
Post
by warriorforgod » Tue Jun 02, 2009 2:28 pm
Code: Select all
<?php
error_reporting(E_ALL);
$dbuser='username';
$dbname='database name';
$server='server';
$connect = mssql_connect($server, $dbuser) or die (mssql_min_message_severity(10));
mssql_select_db($dbname, $connect) or die (mssql_min_message_severity(10));
?>
mikemike
Forum Contributor
Posts: 355 Joined: Sun May 24, 2009 5:37 pm
Location: Chester, UK
Post
by mikemike » Tue Jun 02, 2009 2:54 pm
You're using it wrong, check the documentation.
http://php.net/mssql_min_message_severity
Try something like:
Code: Select all
<?php
error_reporting(E_ALL);
$dbuser='username';
$dbname='database name';
$server='server';
mssql_min_message_severity(10);
$connect = mssql_connect($server, $dbuser);
mssql_select_db($dbname, $connect);
?>
warriorforgod
Forum Newbie
Posts: 15 Joined: Tue Jun 02, 2009 11:16 am
Post
by warriorforgod » Tue Jun 02, 2009 3:01 pm
Ok. Here is the new code. Still nothing showing up.
Code: Select all
<?php
error_reporting(E_ALL);
$dbuser='username';
$dbname='dbname';
$server='servername';
mssql_min_message_severity(10);
$connect = mssql_connect($server, $dbuser);
mssql_select_db($dbname, $connect);
?>
mikemike
Forum Contributor
Posts: 355 Joined: Sun May 24, 2009 5:37 pm
Location: Chester, UK
Post
by mikemike » Tue Jun 02, 2009 3:10 pm
is display_errors on?
warriorforgod
Forum Newbie
Posts: 15 Joined: Tue Jun 02, 2009 11:16 am
Post
by warriorforgod » Tue Jun 02, 2009 3:18 pm
Seems that was the issue. Now I am getting Fatal error: Call to undefined function: mssql_connect().
So off to get that fixed. Thanks for all the help.
mikemike
Forum Contributor
Posts: 355 Joined: Sun May 24, 2009 5:37 pm
Location: Chester, UK
Post
by mikemike » Tue Jun 02, 2009 3:21 pm
Heh, after all that your code was fine
good luck