我最近从phpmyadmin 2.6到5.1,还安装了wamp ...我知道很长一段时间。 我有一个带有简单变量的webform,它们不再插入我的数据库
<form method="POST" action="record.php">
td style="width: 472px">
<input type=text name=travel size=40 style="color: black;background-color:#FFFF66; width: 270px;"></td>
</tr>
和插入php :::
<?
$travel=$_POST['travel'];
$db="xacall";
$link = mysql_connect("localhost", "sql", "sql");
//$link = mysql_connect("localhost",$_POST['username'],$_POST['password']);
if (! $link)
die("Couldn't connect to MySQL");
mysql_select_db($db , $link) or die("Select Error: ".mysql_error());
$result=mysql_query("INSERT INTO ircb (travel) VALUES ('$travel')")or die("Insert Error: ".mysql_error());
//write to file
$fp = fopen("IR_Call_Entries.txt", "a");
fwrite($fp, $_POST['travel'] . "\n" .
close($fp);
?>
我提交,没有收到任何错误消息..但没有任何东西被写入,没有写任何东西......是错误的。我应该使用GET ???阿瑞,困惑,谢谢 我也回应了变量而没有显示
答案 0 :(得分:0)
使用表格:
<form method="post" action="record.php">
<td style="width: 472px">
<input type="text" name="travel" size="40" style="color: black;background-color:#FFFF66; width: 270px;"></td>
</tr>
并使用以下内容调试post变量:print_r($_POST)
<?php #Please use full open tag.
$travel=$_POST['travel'];
$db='xacall';
$link = mysql_connect('localhost', 'sql', 'sql') or die("Couldn't connect to MySQL");
mysql_select_db($db , $link) or die('Select Error: '.mysql_error());
$result=mysql_query("INSERT INTO ircb (travel) VALUES ('$travel')")or die('Insert Error: '.mysql_error());
print_r($_POST);
#write to file
$fp = fopen('IR_Call_Entries.txt', 'a');
fwrite($fp, $_POST['travel'] . '\n' ; #you had a concat sign here?
close($fp);
?>
我也尽可能使用单引号。