我将我的网站移动到godaddy服务器,但即使有足够的更改,SQL连接也无法正常工作
<?php
$link = mysql_connect('www.xxxxx.com', 'phpadminusername', 'phpadminpasswor');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
/*echo 'Connected successfully';*/
echo "DB CONNECTION :<font color='green'>ACTIVE</font>";
?>
Run Code Online (Sandbox Code Playgroud)
它显示错误
警告:mysql_connect()[function.mysql-connect]:在'读取初始通信数据包'时失去与MySQL服务器的连接,系统错误:第196行/home/content/58/9508458/html/psychiatric/private.php中的111无法连接:在"读取初始通信数据包"时丢失与MySQL服务器的连接,系统错误:111
我使用sql创建了一个简单的登录系统
它有4个主要组件索引 - 用户名和传递checklogin - 检查凭据logsuccess主页 - 登录页面成功登录后
产生的错误在帖子的末尾给出
Index.php asks for username and pass
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Nottingham Uni</TITLE>
<script type="text/javascript" src="js/mootools-1.2.1-core-yc.js"></script>
<script type="text/javascript" src="js/process.js"></script>
<link rel="stylesheet" type="text/css" href="style.css" />
</HEAD>
<BODY>
<center>
<div id="intro">
<p> </p>
<p><img align="absmiddle" src="images/nott-uni-logo.jpg"></p>
</div>
<div id="status">
<fieldset><legend align="center">Authentication</legend>
<div id="login_response"><!-- spanner --></div>
<form id="login" name="login" method="post" action="checklogin.php">
<table align="center" width="300" border="0">
<tr>
<td width="80">Username</td><td><input id="name" type="text" name="myusername"></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="mypassword"></td>
</tr>
<tr>
<td> </td>
<td> </td> …Run Code Online (Sandbox Code Playgroud) 我创建了以下代码,它使下拉列表能够从sql db获取所有值,它能够获取数字但不显示..
<?php
$link = mysql_connect('www.xxxxxxxx.com', 'xxxxxxx', 'xxxxxxx');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("xxxxxxxxxxxxxxxxxxxxx", $link);
function print_dropdown($query)
{
$queried = mysql_query($query);
$menu = '<select name="Topic">';
while ($result = mysql_fetch_array($queried)) {
$menu .= '
<option value="' . $result['topic'] .'</option>';
}
$menu .= '</select>';
return $menu;
}
echo print_dropdown("SELECT topic FROM learning_outcome");
?>
Run Code Online (Sandbox Code Playgroud)
但输出似乎是空的.. :(