×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

ODBC in PHP to connect to ServiceNow

ODBC in PHP to connect to ServiceNow

ODBC in PHP to connect to ServiceNow

(OP)
I have access to ServiceNow via ODBC. Driver is installed since ages, I've been running queries and getting results since ages.

I have PHP installed on my server and I want to use it to connect via odbc to ServiceNow.

I've tried many things, including php scripts like the one below:

CODE --> php

<?php
#DSN "mydb" with a user and password 
$connect = odbc_connect("ServiceNow", "myusername", "mypassword");

# query the users table for name and surname
$query = "SELECT * FROM incident";

# perform the query
$result = odbc_exec($connect, $query);

# fetch the data from the database
while(odbc_fetch_row($result)){
        $name = odbc_result($result, 2);
        print("$name\n");
}

# close the connection
odbc_close($connect);
?> 

I'm getting the following warnings:


CODE -->

Warning: odbc_connect(): in C:\xampp\htdocs\odbc.php on line 3

Warning: odbc_exec() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\odbc.php on line 9

Warning: odbc_fetch_row() expects parameter 1 to be resource, null given in C:\xampp\htdocs\odbc.php on line 12

Warning: odbc_close() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\odbc.php on line 18 

I'm using DataDirect OpenAccess SDK Local ODBC Driver and below are my current ODBC settings for ServiceNow:

CODE -->

Data Source Name: ServiceNow
Description: ServiceNow
Service Name: ServiceNow_ODBC
Service Data Source: ServiceNow
Custom Properties: url=https://servicenowserver.service-now.com 

Any help and any clue on how to solve this is very much appreciated.
Thanks.

RE: ODBC in PHP to connect to ServiceNow

Since odbc_connect returns false on error, and you do not test the returned value, it is not surprising that subsequent statements are not happy with false as a resource. So, my guess is that your connection is failing.

Tom Morrison
Hill Country Software

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close