This topic is locked
[SOLVED]

 Database API and external php files

3/10/2020 2:24:23 PM
PHPRunner General questions
J
jaffleck author

Do I have to "include" anything in particular if I want to use the DB::Insert() function in an external php script?

K
keithh0427 3/10/2020

In the Help file, navigate to:
Advanced topics > How to add external files
Or, just search for "external"

J
jaffleck author 3/10/2020



In the Help file, navigate to:
Advanced topics > How to add external files
Or, just search for "external"



Let me rephrase the question:
Can I use the DB::Insert() function in an external script without including something or specifying something like "global $dal;"? I'm having an error that I am trying to chase down. The DB::Insert() function is not working in my external php script so I want to make sure I'm doing it properly.

S
Steve Seymour 3/10/2020



Let me rephrase the question:
Can I use the DB::Insert() function in an external script without including something or specifying something like "global $dal;"? I'm having an error that I am trying to chase down. The DB::Insert() function is not working in my external php script so I want to make sure I'm doing it properly.


//PHPR DB

include "include/dbcommon.php";

Admin 3/10/2020
  1. No, you cannot use PHPRunner API in an external file without including anything.
  2. We cannot guess what kind of error you having so it will be helpful to see your exact code and an exact error message.

J
jaffleck author 3/10/2020



In the Help file, navigate to:
Advanced topics > How to add external files
Or, just search for "external"



Thanks. Adding include "incudes/dbcommon.php" fixed the problem. You might want to mention that in the manual.....

Admin 3/10/2020



Thanks. Adding include "incudes/dbcommon.php" fixed the problem. You might want to mention that in the manual.....


Really? Did you even read it?
https://xlinesoft.com/phprunner/docs/how_to_add_external_files.htm

C
charlesfolder 4/8/2020

Hi, here is a example code I used in external file
require('../include/dbcommon.php');

require('fpdf.php');
/**

/* Taxes Information ***

/**/

$data_tax = array();

$data_tax["active"] = "Yes";

$rs_tax = DB::Select("taxes", $data_tax );

while( $record_tax = $rs_tax->fetchAssoc() )

{

if($record_tax["description"] == 'City')

{

$city_tax = $record_tax["tax"];

} else

$state_tax = $record_tax["tax"];

}