这是从 URL 获取主机名的函数:
<?php
function get_domain($url)
{
$pieces = parse_url($url);
$domain = isset($pieces['host']) ? $pieces['host'] : '';
if (preg_match('/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i', $domain, $regs)) {
return $regs['domain'];
}
return false;
}
print get_domain("http://fileflyer.com");
?>
我想在我的文件中插入这个函数:
<?php
function connect($host,$username,$database,$password){
$to_connect = mysql_connect($host,$username,$password) or die ("UNFinded ".$username. " DB !");
$db = mysql_select_db($database, $to_connect) or die (mysql_error());
return $db;
}
connect("localhost","idevice2_ariel","idevice2_ariel","ariel123456");
if (!isset($_POST['submit_form'])) {
echo '<form name="search_form1" id="form" method="POST" action="search.php">
<input type="text" style="width: 300px; display: block; margin: 0 auto; height: 36px; text-align: center; font-size: 16px;" name="search_name" placeholder="חפש סרט או סדרה.." />
<input type="submit" value="Submit" name="submit_form" />
</form>';
} else {
$search_name = $_POST['search_name'];
$query = mysql_query("SELECT * FROM `members` WHERE (`moviename` like '%".$search_name."%')");
$count = mysql_num_rows($query);
while($row = mysql_fetch_array($query)) {
$fname = $row['moviename'];
$lname = $row['links'];
**print '<a href="'.**$row['links']**.'">'.$row['moviename'].'</a><br />';
我希望这从
$row['links']
}
}
mysql_close($to_connect);
?>
<html>
<head>
<style type="text/css">
a {
}
</style>
</head>
<body>
</body>
</html>
有人可以帮助我吗?