473,323 Members | 1,560 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

connecting php and mssql

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 6295
Markus
6,050 Expert 4TB
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 Expert 1GB
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_mssql.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
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 Expert 4TB
The MSSQL extension is enabled by adding extension=php_mssql.dll to php.ini.
Have you done this?
Oct 7 '09 #5
yes just did, but it came up with this error

Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: OLUKAYODE\SQLEXPRESS 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_array(): 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 Expert 4TB
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
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...
3
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...
2
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...
9
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...
1
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...
1
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...
0
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...
6
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...
10
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.