NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
DB Form Wizard script


Joined: 24 Apr 2006
Posts: 11
Reply with quote
I get this error when I try to run a script built by the Form wizard

Fatal error: Call to undefined function: ensureconnectionavailable() in

any ideas where I should go to fix this? Thanks!
View user's profileFind all posts by cjacksSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
ensureConnectionAvailable() comes with DB module that should be included.
Depending on DB it can be either db_ibutil.inc, db_myutil.inc, db_pgutil.inc, db_util.inc, db_mssqlutil.inc, db_oracleutil.inc, or db_sqliteutil.inc.
Let me know if this was not included in code generated by the wizard.
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 24 Apr 2006
Posts: 11
Reply with quote
Ok I see what is going on. The script the wizard made is poiting toward the file

require_once $site["path"].'db_myutil.inc';
ensureConnectionAvailable();

However, that function is not in the db_myutil.inc script

I did find that function in some of the other ones you listed. I tried to paste the function in the db_myutil script, but then it errors out with Fatal error: Call to undefined function: isconnectionavailable() in ... while seeking another function.

This is odd also because I chose the option of a stand alone script..so it should not have written the code that way anyway right?

ddmitrie wrote:
ensureConnectionAvailable() comes with DB module that should be included.
Depending on DB it can be either db_ibutil.inc, db_myutil.inc, db_pgutil.inc, db_util.inc, db_mssqlutil.inc, db_oracleutil.inc, or db_sqliteutil.inc.
Let me know if this was not included in code generated by the wizard.
View user's profileFind all posts by cjacksSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
I'm not sure what file you're looking at, but both ensureConnectionAvailable() and isConnectionAvailable() are in all db_xxxx.inc files, including db_myutil.inc in particular. The only exception is db_util.inc which is a common part.
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 24 Apr 2006
Posts: 11
Reply with quote
I double checked, the file db_myutil_inc does not include the ensureConnectionAvailable function nor does it include a file that includes that function. I looked in the file as well as viewed the function list in PhPed when I had the file open. Could you post your db_myutil_inc file here? Thanks
View user's profileFind all posts by cjacksSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
then you need to triple check Smile

below is the file listing of db_myutil.inc (Apr 3 2006, 20:46), bundled with PhpED version 4.6:

Code:
<?
/*
   Misc MySQL utils to use with PHPEd generated scripts

*/

  function isConnectionAvailable() {
    return(function_exists('mysql_connect'));
  }

  function ensureConnectionAvailable() {
     if (isConnectionAvailable()) {
       return(true);
     } else {
       die("Please enable MySQL extension !");
     }
  }

  function dbconnect($dbhost, $dbuser, $dbpass, $dbname) {
      mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error());
      mysql_select_db($dbname) or die(mysql_error());
  }

  function dbquery($sql){
     return mysql_query($sql);
  }

  function dbnext($res){
     return mysql_fetch_array($res);
  }

  function str2date($str){
    global $site;
    ereg('([0-9]{1,2})[./-]([0-9]{1,2})[./-]([0-9]{3,4})', $str, $arr);

    if($site['sdate']=='mdy')
       return "$arr[3]-$arr[1]-$arr[2]";
    if($site['sdate']=='dmy')
       return "$arr[3]-$arr[2]-$arr[1]";
    if($site['sdate']=='ymd')
       return "$arr[1]-$arr[2]-$arr[3]";
  }

  function date2Str($date){
      global $site;

      $d = split(' ', $date);
      $y = split('-', $d[0]);
      if($site['sdate']=='mdy')
         return "$y[1]$site[dsep]$y[2]$site[dsep]$y[0]";
      elseif($site['sdate']=='dmy')
         return "$y[2]$site[dsep]$y[1]$site[dsep]$y[0]";
      elseif($site['sdate']=='ymd')
         return "$y[0]$site[dsep]$y[1]$site[dsep]$y[2]";
  }

  function datetime2Str($date){
      global $site;

      $d = split(' ', $date);
      $y = split('-', $d[0]);
      if($site['sdate']=='mdy')
         return "$y[1]$site[dsep]$y[2]$site[dsep]$y[0] $d[1]";
      elseif($site['sdate']=='dmy')
         return "$y[2]$site[dsep]$y[1]$site[dsep]$y[0] $d[1]";
      elseif($site['sdate']=='ymd')
         return "$y[0]$site[dsep]$y[1]$site[dsep]$y[2] $d[1]";
  }

  function WriteCombo($vals, $name, $selected){
   $res = "<select name='$name'>\n";
   while(list($val, $opt)=each($vals)){
      $res .= "<option value='$val'".
        (($val==$selected)?' selected':'').
        ">$opt</option>\n";
   }
   $res .= "</select>\n";

   return $res;
 }

function WriteLookupArray($valname, $titlename, $table){
   global $db;

   $ret = array();

   $reslt=dbquery("select $valname, $titlename from $table");
   while($row=dbnext($reslt)){
      $ret[$row[0]] = $row[1];
   }
   return $ret;
}

function WriteLookupCombo($name, $valname, $titlename, $table, $selected){
   return WriteCombo(WriteLookupArray($valname, $titlename, $table), $name, $selected);
}

function toGlobals($row) {
   while(list($f, $v)=each($row)){
         if(!is_int($f)){
            $GLOBALS[$f] = $v;
         }
   }
}
View user's profileFind all posts by dmitriSend private messageVisit poster's website
DB Form Wizard script
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic