CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Call to undefined function civicrm_api() after moving domain
Pages: [1]

Author Topic: Call to undefined function civicrm_api() after moving domain  (Read 1155 times)

unclejustin

  • I post occasionally
  • **
  • Posts: 38
  • Karma: 2
  • CiviCRM version: 4.3.x
  • CMS version: Drupal 7.x
  • MySQL version: 5.5
  • PHP version: 5.3.6
Call to undefined function civicrm_api() after moving domain
February 22, 2012, 04:08:35 pm
Running Drupal 7 + Civi 4.1

I just moved domains on civihosting and now the code in one of my blocks is throwing an error. I updated CIVICRM_UF_BASEURL in civicrm.settings.php as well as the resource URLs in the settings. Error log shows "PHP Fatal error:  Call to undefined function civicrm_api() in .../modules/php/php.module(80) : eval()'d code on line 2" I cleared both Drupal and Civi caches.

Interestingly the block works on the home page, but all other pages that render the block fail (white screen). If I disable the block then all the pages work just fine.

Is there something else I need to update? Or does anybody have any ideas where else I can look?

Here's the code the block is running:

Code: [Select]
<?php
$results
=civicrm_api("Event","getsingle", array ('version' =>'3', 'event_type' =>'7'));
$eventid = $results['id'];
$link = "/civicrm/event/info?id=$eventid&reset=1";
?>

-justin

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Call to undefined function civicrm_api() after moving domain
February 22, 2012, 05:01:18 pm
You should call (if not done already)

civicrm_initialize();
at the top of your code

-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

unclejustin

  • I post occasionally
  • **
  • Posts: 38
  • Karma: 2
  • CiviCRM version: 4.3.x
  • CMS version: Drupal 7.x
  • MySQL version: 5.5
  • PHP version: 5.3.6
Re: Call to undefined function civicrm_api() after moving domain
February 22, 2012, 05:21:33 pm
Thank you xavier that did the trick. I'm unsure why it:

A) Worked just fine before the domain change
and
B) It worked on the home page but not other pages.

Honestly I'm ok with not knowing, right now I'm just glad it works. Thanks again!
-justin

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Call to undefined function civicrm_api() after moving domain

This forum was archived on 2017-11-26.