Warning: mysql_query() expects parameter 1 to be string, resource given in index.php on line 22
正在学习php,22行为啥报错呀,该怎么写?<html><head><title>TouchMyVoice</title></head><body><h2>TouchMy...
正在学习php,22行为啥报错呀,该怎么写?
<html>
<head>
<title>Touch My Voice</title>
</head>
<body>
<h2>Touch My Voice</h2>
<p>Give me your name and telephone number!</p>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" >
<label for="name">Your name: </label>
<input type="text" id="name" name="name"/><br />
<label for="code">Your student id: </label>
<input type="text" id="code" name="code"/><br />
<label for="telephone">Your telephone number:</label>
<input type="text" id="telephone" name="telephone"/><br />
<input type="submit" value="sign up" name="submit"/><br />
<?php
$_name=$_POST['name'];
$_code=$_POST['code'];
$_telephone=$_POST['telephone'];
$_dbc=mysql_connect(SAE_MYSQL_HOST_M.":".SAE_MYSQL_PORT,SAE_MYSQL_USER,SAE_MYSQL_PASS,app_snipe)or die('Error');
$_query="INSERT INTO aliendatabase(name,id,telephone) VALUES('$_name,'$_code','$_telephone')";
$_result=mysql_query($_dbc,$_query)or die('Error2');
mysql_close($_dbc);
?> 展开
<html>
<head>
<title>Touch My Voice</title>
</head>
<body>
<h2>Touch My Voice</h2>
<p>Give me your name and telephone number!</p>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" >
<label for="name">Your name: </label>
<input type="text" id="name" name="name"/><br />
<label for="code">Your student id: </label>
<input type="text" id="code" name="code"/><br />
<label for="telephone">Your telephone number:</label>
<input type="text" id="telephone" name="telephone"/><br />
<input type="submit" value="sign up" name="submit"/><br />
<?php
$_name=$_POST['name'];
$_code=$_POST['code'];
$_telephone=$_POST['telephone'];
$_dbc=mysql_connect(SAE_MYSQL_HOST_M.":".SAE_MYSQL_PORT,SAE_MYSQL_USER,SAE_MYSQL_PASS,app_snipe)or die('Error');
$_query="INSERT INTO aliendatabase(name,id,telephone) VALUES('$_name,'$_code','$_telephone')";
$_result=mysql_query($_dbc,$_query)or die('Error2');
mysql_close($_dbc);
?> 展开
1个回答
展开全部
//$_name后面少一个单引号
//$_query="INSERT INTO aliendatabase(name,id,telephone) VALUES('$_name,'$_code','$_telephone')";
//应该这样
$_query="INSERT INTO aliendatabase(name,id,telephone) VALUES('$_name','$_code','$_telephone')";
追问
确实落下一个引号,不过加上之后还是报同样的错,我用的是新浪的sinaapp,是数据库设置有问题么?
追答
<html>
<head>
<title>Touch My Voice</title>
</head>
<body>
<h2>Touch My Voice</h2>
<p>Give me your name and telephone number!</p>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" >
<label for="name">Your name: </label>
<input type="text" id="name" name="name"/><br />
<label for="code">Your student id: </label>
<input type="text" id="code" name="code"/><br />
<label for="telephone">Your telephone number:</label>
<input type="text" id="telephone" name="telephone"/><br />
<input type="submit" value="sign up" name="submit"/><br />
</form>
</body>
</html>
补全html啊
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询