Heim > Artikel > Backend-Entwicklung > 生手提问。直接看吧。
新手提问。。。直接看吧。。。
我是把有mysql的代码独立在in.php页面,in.php代码如下:
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><?php date_default_timezone_set('PRC'); $sj = date("Y-m-d H:i:s"); $sql = mysql_connect("127.0.0.1","root","kingmo"); mysql_query('$sql'); if (!$sql){ die('数据连接失败,原因:'.mysql_error()); } mysql_select_db("yang",$sql); $a_os = mysql_query("SELECT os FROM os"); if (!$a_os){ die('数据查询失败,原因:'.mysql_error()); } $os = mysql_fetch_array($a_os); if($go==1) mysql_select_db("yang",$sql); $a_lr = "SELECT xinxi FROM name, old, add, pj"; mysql_query($a_lr,$sql); $lr = "INSERT INTO Persons (name, old, add, pj) VALUES ('$_POST[name]','$_POST[old]','$_POST[add]','$_POST[pj]')"; if (!mysql_query($lr,$sql)){ die ('发生错误了囧,代码:'.mysql_error()); } echo "录入成功拉!!!"; mysql_close($sql); ?>
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><meta http-equiv="Content-Type" content="text/html; charset=GBK">