Home  >  Article  >  Backend Development  >  基础问题,在线等在线结贴

基础问题,在线等在线结贴

WBOY
WBOYOriginal
2016-06-23 14:26:29855browse

网上找了一段 留言源码。 数据库是远程服务器。 有ip和端口  假设数据库名字叫ABC  请问如何将下面代码读取到的信息,插入到这个数据库当中。


回复讨论(解决方案)

<?php$YourEmailAddress = "";error_reporting (E_ALL ^ E_NOTICE);$post = (!empty($_POST)) ? true : false;if($post) {	function ValidateEmail($email){		$regex = "^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$^";		$eregi = preg_replace($regex,'', trim($email));				return empty($eregi) ? true : false;	}	$subject = "Quick contact from home page";	$to = $YourEmailAddress; //trim($_POST['to']);	$email = trim($_POST['user-email']);	$message = stripslashes($_POST['user-message']);	$error = '';	$Reply=$to;	$from=$to;		if(!$email) { 		$error .= '请输入邮箱地址<br />';	}	if($email && !ValidateEmail($email)) {		$error .= '请输入验证过的邮箱<br />';	}	if(!$message || strlen($message) < 3) {		$error .= "请输入留言信息<br />";	}		if(!$error) {		$messages="From: $email <br>";		$messages.="Email: $email <br>";		$messages.="Message: $message <br>";		$emailto=$to;				$mail = mail($emailto,$subject,$messages,"from: $from <$Reply>\nReply-To: $Reply \nContent-type: text/html");				if($mail) {			echo '成功';		}	} else {		echo '<div class="error">'.$error.'</div>';	}}?>

www.w3school.com.cn
里面有连接db,插入db的教程。

你没有说明是什么数据库,所以没法写代码

看下php的pdo

数据库是远程服务器。 这种架构不合适,要避免这么个架构。因为连接不可靠不稳定,性能也不行。

mysqlconnect函数不是有服务器地址。用户名密码。吗。你用这个连接。。其它都一样

大神从C++转PHP?

  好了 - - 我知道了。  谢谢大家参与。我结贴

大神从C++转PHP?   嗯。 做web了。 有掉费劲。 刚做web一个周。。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Zend中的注释模板问题Next article:php调用c#的方法