0

送信ボタンをクリックしてもデータが処理されない理由がわかりません。現在、そのようなクエリがあります。

 $link = mysqli_connect("$server", "$user", "$pass", "webdb");
 $page = mysqli_real_escape_string($link, (string) $_POST['page']);
 $content = mysqli_real_escape_string($link, (string) $_POST['content']);
 $query = "UPDATE `pages` SET `content`='$content' WHERE `name`='$page'";
 mysqli_query($link, $query);
 mysqli_close($link);
 header("location: index.php");
 ?>

このクエリに接続するために、データを送信するフォームがあります。

<form action="update_content.php" method="post">
<textarea name="content" cols="60" rows="10"></textarea>
<input type="hidden" name="page" value="Index" />
<br /><input type="submit" value="Update" />
</form>

私が立っている場所から見ると、すべてが正しいように見えます。私は頭を悩ませ、何時間もウェブ全体を見回してきましたが、ここで解決策を見つけることができません.

4

2 に答える 2

0

Step 1 :

Print the query variable, so that you can know the query is constructed well.

(Comment the redirection so that you can see the query output)

Step 2:

If the values passed in the query aren't correct or empty, fix this by printing the passed params (you can print $_REQUEST - Which will show all the values posted)

Step 3

if all these are correct and if the query is not executed correctly, then check your database connection.

You can print out the connection variable $link to see if a connection is made successfully.

These these steps will help you sort out the issue.

Let me know if these steps doesn't help you.

于 2012-10-08T04:30:11.090 に答える
0

実際の答えは、リダイレクトが無効になったときに、接続が失敗していることを確認できました。これは、echo $query 文字列を確認するためにリダイレクトを無効にするまで確認できませんでした。教訓: すべての変数が正しいことを確認してください。:)

于 2012-10-08T18:13:27.420 に答える