开发者

How do I call this in this script?

data.php is main file and if the search terms not within the database 开发者_开发技巧then it should call getdata.php to grab data. so how do I call this in this script.

$db = mysql_connect($db_host, $db_username, $db_password) or die("Could not connect.");
mysql_select_db($databse_name,$db)or die(mysql_error());
$row = mysql_fetch_assoc($result);
if($row > 0){
    //show the result
}else{
    //call getdata.php
}

but how I call getdata.php without using header()?


...}else{
include( 'getdata.php' )
}


require('getdata.php'); comes to mind


You can do either as Carlos said, or you can use

require('getdata.php');

It all depends on if you want the application to produce a warning if getdata.php does not exist or if you want the application to produce a fatal error (require will produce the fatal error).

It might also be good practice to use require_once() instead to ensure the file is not included more than once at any point.

Hope this helps.


From here

// Something like this

$execute = /path/to/php/script.php;

// If you needed the output echo $execute;

You can also refer to PHP Execution Operators

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜