By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,984 Members | 1,025 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,984 IT Pros & Developers. It's quick & easy.

Php odbc_prepare/odbc_exec error

P: 1
Expand|Select|Wrap|Line Numbers
  1. // Relevant parts of my DB class (from include file)
  2. class db_connection
  3. {
  4.     function __construct()
  5.     {
  6.         $this->con = odbc_connect('ShippingData','name','pass');
  7.     }
  8.     private $con;
  9.  
  10.     function Prepare($query)
  11.     {
  12.         return odbc_prepare($this->con, $query);
  13.     }
  14.  
  15.     // Execute prepared queries...
  16.     function Pexec($pq, $arr)
  17.     {
  18.         return odbc_exec($pq, $arr); // This is line 43 from below error
  19.     }
  20. }
  21.  
  22.  
  23. // *** clip from my file ***
  24.  
  25. $db = new db_connection;
  26.  
  27. // Build the query...
  28. $query = "INSERT INTO Customers (CustomerID,CompanyName,ContactName) VALUES (?,?,?);";
  29.  
  30. // Prepare the query
  31. $pquery = $db->Prepare($query);
  32.  
  33. // Build data array...
  34. $arr = array($customer_id,$company_name,$contact_name);
  35.  
  36. // Execute the prepared query... (dies in this func)
  37. $db->Pexec($pquery, $arr);    


// The error I get
Warning: odbc_exec(): supplied resource is not a valid ODBC-Link resource in E:\Web\ShipView\inc\db.phpinc on line 43


What is causing me to get this error? I'm doing what every other example I've ever seen online is doing. Please help.
May 17 '07 #1
Share this Question
Share on Google+
1 Reply


pbmods
Expert 5K+
P: 5,821
According to PHP's manual, odbc_exec is supposed to prepare the query for you (as opposed to odbc_execute).

Also, it doesn't look like odbc_exec takes an array for any of its arguments.

Also also, if odbc_prepare fails to prepare the query, the return value won't be a valid resource identifier.

I've never used ODBC before, but I hope this information (plus links) are useful.
May 17 '07 #2

Post your reply

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