473,569 Members | 2,716 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

connecting php and mssql

14 New Member
hi everyone,
i tried using the code below to connect to my database (MSSQL) but it gave me the error benith. actually am new to php and i dont want to use mysql because am used to MSSQL
thanks

code
Expand|Select|Wrap|Line Numbers
  1. <?php 
  2.     $con = mssql_connect('OLUKAYODE\SQLEXPRESS', 'sa', 'admin');
  3.     mssql_select_db('image', $com);
  4.     $sql = "select * from main";
  5.     $get = mssql_query($sql, $com);
  6.     $data = mssql_fetch_array($get);
  7.  
  8.     echo $data["title"];
  9.     echo $data["file_name"];
  10.  
  11. ?>
error
Fatal error: Call to undefined function mssql_connect() in C:\wamp\www\gig \crash.php on line 10
Oct 1 '09 #1
6 6308
Markus
6,050 Recognized Expert Expert
You do not have PHP's MSSQL extension enabled. See this link.

Also, I formatted your post to use [code] tags. In future, please do this yourself.

Thanks,
Mark.
Oct 1 '09 #2
dlite922
1,584 Recognized Expert Top Contributor
You need to install the mssql module for php. Did you do that?

You usually need to uncomment a line in your php.ini

extension=php_m ssql.dll

and make sure that dll file exists in your extension directory.



Dan

EDIT:

Dan <-- defeated by Markus's quick replies.
Oct 1 '09 #3
kayox007
14 New Member
where do i get the MSSQL module for php...

MarkUs... i followed the link, it told me to copy a ddl file into a folder and i can't find the .dll file.

thanks
Oct 7 '09 #4
Markus
6,050 Recognized Expert Expert
The MSSQL extension is enabled by adding extension=php_m ssql.dll to php.ini.
Have you done this?
Oct 7 '09 #5
kayox007
14 New Member
yes just did, but it came up with this error

Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: OLUKAYODE\SQLEX PRESS in C:\wamp\www\gig \crash.php on line 10

Warning: mssql_select_db (): supplied argument is not a valid MS SQL-Link resource in C:\wamp\www\gig \crash.php on line 11

Warning: mssql_query(): supplied argument is not a valid MS SQL-Link resource in C:\wamp\www\gig \crash.php on line 13

Warning: mssql_fetch_arr ay(): supplied argument is not a valid MS SQL-result resource in C:\wamp\www\gig \crash.php on line 14

this is the code

Expand|Select|Wrap|Line Numbers
  1. <?php 
  2.     $con = mssql_connect('OLUKAYODE\SQLEXPRESS', 'sa', 'admin');
  3.     mssql_select_db('image', $com);
  4.     $sql = "select * from main";
  5.     $get = mssql_query($sql, $com);
  6.     $data = mssql_fetch_array($get);
  7.  
  8.     echo $data["title"];
  9.     echo $data["file_name"];
  10.  
  11. ?>
Oct 7 '09 #6
Markus
6,050 Recognized Expert Expert
Please see mssql_get_last_ message() - there is something wrong with your connection information, and the function above should provide you with an error string.

Expand|Select|Wrap|Line Numbers
  1. $con = mssql_connect('OLUKAYODE\SQLEXPRESS', 'sa', 'admin');
  2.  
  3. if (!$con) printf("Connection failed: %s", mssql_get_last_message());
Oct 7 '09 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
1705
by: bigoxygen | last post by:
Hi. I am experiencing problems connecting to MSSQL. I'm not sure where to begin looking for the problem. I don't know if the problem is originating with PHP or MSSQL What should the host name be? When I mouse over MSSQL manager it says "\\S-CIS-0042" $db_host='local'; //IP/host of the database server
3
2292
by: John Fabiani | last post by:
Hi, I'm hoping someone on the list has connected to sybase/MsSQL with something that works with DBAPI 2.0 from a linux box (SUSE 9.2) because I can't seem to get it done. I found Object Craft's python code that uses FreeTDS. But I can't get it compiled. The code is looking for "sybdb.h" (first error) - of course I don't have "sybdb.h". It...
2
15655
by: Pippen | last post by:
I'm currently trying to access data from a Cache DB using MSSQL. I have linked the Cache server through an ODBC connection. I can see in the Linked Server expansion all the tables in Cache for the File(?) I want to access. Here is my problem: Normally to access a linked sever I would do the following: select * from...
9
5827
by: Advo | last post by:
Im having major problems trying to connect to a mssql database thats hosted on our server. I've got the ip, username, password and database name, yet no matter what i try, I cant seem to connect. I've trawled the net for hours looking for code, has anyone got any that definately works, or just a simple way I can check the connection. ...
1
1897
by: brosner | last post by:
I installed MSSQL 2000 on my desktop (running NT 2000). No problem. I created an adp and attached it to a database within MSSQL 2000, no problem. When I go into MS Access, on another PC (running Windows XP Pro) on the same network, and try to create a using 'Project(Existing Data)' and connect it to MSSQL 2000 on my desktop, I fill in the...
1
13791
by: bg_ie | last post by:
Hi, I like to develope an application which uses a MsSQL database. I believe that C# works really well with MsSQL. To start with, I'd like to host the sql server locally on my machine as I develop, but later I'd like to be able to host it on a server and have multiple instances of the application access the server. I have installed SQL...
0
1082
by: acb7621 | last post by:
Hi every1, Ive just created a database in MSSQL 2000. Ive created all the tables and inserted demo records it compiles completely. I am now trying to connect to the database with PHP through the IIS but it does not display anything at all. I have some normal 'echo' code to check that PHP is fine, and THAT displays ... but it seems i can't...
6
1633
by: Joe Adams | last post by:
I am attempting to reinstall from a windows gone bad problem. XP had "died" and unable boot into os, so there was no backup or copy database made. Have installed new hdd. copied most all of the old hdd to a "backup" folder on new hdd. I know of the program files ms sql data subdir. System state. XP professional , not sharing on network, so...
10
4072
by: khalid galal | last post by:
Hi, i am having a problem with connecting ASP with MSSQL SEVER 2005 EXPRESS EDITION, i am writing ASP code using javascript. look at this peace of code: var myConnect = "Provider=SQLNCLI;Data Source=.\SQLEXPRESS;Initial Catalog=quiz;User ID=factory1;Password = 123;"; var ConnectObj = Server.CreateObject("ADODB.Connection"); var RS =...
0
7694
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7921
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8118
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7666
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
3636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1208
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
936
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.