-2
これらのコードを使用していて、なぜ私のデータベースに書き込まないのかわかりません。今夜はサーバーにアクセスできませんが、これは大変恐ろしいものです。htmlとphpでmySQLに書き込む
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Basic Page Needs
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<meta charset="utf-8">
<title>Collecting Data for Database</title>
<meta name="description" content="">
<meta name="author" content="AleR">
<!-- Mobile Specific Metas
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- FONT
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<link href="http://fonts.googleapis.com/css?family=Raleway:400,300,600" rel="stylesheet" type="text/css">
<!-- CSS
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<link rel="stylesheet" href="normalize.css">
<link rel="stylesheet" href="skeleton.css">
<link rel="stylesheet" href="backbone.css">
<link rel="stylesheet" href="asspage.css">
<style>
#container{
width:90%;
margin: 40px auto 0 auto;
}
h1 {color:lightgreen;}
</style>
<style>
body {background-color:lightgreen; color: green;}
h1 {color: lightgreen;}
p {color: lightgreen;}
header {
margin-top: -25px;
margin-left: -500px;
height: 100px;
width: 10000px;
background-color: green;
}
nav{background-color: green; height: 100%;
width: 100%;}
aside{background-color: green; height: 100%;
width: 100%;}
</style>
</head>
<header></header>
<nav></nav>
<aside></aside>
<body>
<!-- Primary Page Layout
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<div id="container" align="center">
<form action="final.php" method="post">
<div class="row">
<div class="six columns">
<label for="Age">Category</label>
<input class="u-full-width" type="text" name="Category">
<label for="Qualifications">Brand</label>
<input class="u-full-width" type="text" name="Brand">
<label for="Experience">Condition</label>
<input class="u-full-width" type="text" name="Condition">
</div>
</div>
<form action="final.php" method="post">
<input class="button-primary" type="submit" value="Submit">
</form>
</div>
\t </body>
</html>
この次のスニペットは、私のデータベースに情報を送信することになっているPHPです!
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Basic Page Needs
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<meta charset="utf-8">
<title>Audio Search</title>
<meta name="description" content="">
<meta name="author" content="AlexR">
<!-- Mobile Specific Metas
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- FONT
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<link href="http://fonts.googleapis.com/css?family=Raleway:400,300,600" rel="stylesheet" type="text/css">
<!-- CSS
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<link rel="stylesheet" href="normalize.css">
<link rel="stylesheet" href="skeleton.css">
<link rel="stylesheet" href="backbone.css">
<style>
#container{
width:90%;
margin: 40px auto 0 auto;
}
background{
color: green;
}
</style>
<style>
body {background-color:lightgreen;}
h1 {color:blue;}
p {color:green;}
</style>
</head>
<body>
<!-- Primary Page Layout
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<div id="container">
<form>
<div class="row">
<div class="six columns">
<p>Thank you for your name and e-mail.</p>
<?php
DEFINE('DB_USERNAME', '*****');
DEFINE('DB_PASSWORD', '*****');
DEFINE('DB_HOST', 'localhost');
DEFINE('DB_DATABASE', '*****');
echo "here!";
if (isset($_REQUEST['Age'])){
$Age = $_REQUEST['Age'];
$Qualifications = $_REQUEST['Qualifications'];
$Experience = $_REQUEST['Experience'];
#echo "Thanks for your submission.";
$dbc = mysqli_connect(DB_HOST,DB_USERNAME,DB_PASSWORD,DB_DATABASE) OR die ('Could not connect to MySQL: '.mysqli_connect_error());
$q = "INSERT INTO `FinalForm`(`Age`, `Qualifications`, `Experience`) VALUES ('$Age','$Qualifications','$Experience')";
#$q = "INSERT INTO `EmailList1`(`firstName`, `lastName`, `eMail`) VALUES ('Joseph','Wales','[email protected]')";
$r = mysqli_query($dbc,$q);
# ^^^ Search submit results window
if ($r){echo "Results below";} else {echo "Your search found zero results";};
}
?>
</div>
<div>
</div>
\t
</html>
このコードは動作していない、私のデータベースのデータを取得し、表示するようになっているものです!
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Basic Page Needs
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<meta charset="utf-8">
<title>Audio Shop Data Retrieval</title>
<meta name="description" content="">
<meta name="author" content="AlexR">
<!-- Mobile Specific Metas
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- FONT
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<link href="http://fonts.googleapis.com/css?family=Raleway:400,300,600" rel="stylesheet" type="text/css">
<!-- CSS
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<link rel="stylesheet" href="normalize.css">
<link rel="stylesheet" href="skeleton.css">
<link rel="stylesheet" href="backbone.css">
<style>
#container{
width:90%;
margin: 40px auto 0 auto;
}
h1 {color:lightgreen;}
</style>
<style>
body {background-color:lightgreen; color: green;}
h1 {color: lightgreen;}
p {color: lightgreen;}
header {
margin-top: -25px;
margin-left: -500px;
height: 100px;
width: 10000px;
background-color: green;
}
</style>
</head>
<header><h1>Audio Supply Retrieval</h1></header>
<body>
<!-- Primary Page Layout
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<div id="container" align="center">
<form>
<div class="row">
<div class="six columns">
<?php
DEFINE('DB_USERNAME', '*****');
DEFINE('DB_PASSWORD', '*****');
DEFINE('DB_HOST', 'localhost');
DEFINE('DB_DATABASE', '*****');
$dbc = mysqli_connect(DB_HOST,DB_USERNAME,DB_PASSWORD,DB_DATABASE) OR die ('Could not connect to MySQL: '.mysqli_connect_error());
$q = "SELECT * FROM `FinalForm` ORDER BY `Category` ASC";
[email protected]_query($dbc,$q);
if ($r) {
echo '<table><tr><td><b>Age</b></td><td><b>Qualifications</b></td><td><b>Experience</b></td></td>';
while($row=mysqli_fetch_array($r,MYSQLI_ASSOC)){
echo "<tr><td>$row[NameID]</td><td>$row[Age]</td><td>$row[Qualifications]</td><td>$row[Experience]</td></tr>";
}
echo "</select>";
};
echo "<p>";
?>
</div>
<div>
</div>
\t </body>
</html>
は(E_ALL)のerror_reportingの文を '追加;'各PHPファイルの先頭に、その後、私たちはメッセージがに現れ何のエラーを知らせますあなたのサーバーの 'error.log'ファイル。 –
あなたの最初のHTMLページには、同じアクションとメソッドを持つ '
私はこの質問を下落させました。なぜなら、毎日「MySQLが動作していない」ことについて何十回も尋ねているからです。このドキュメントを読んだら、mysqli_queryがfalseを返すときに余分なエラー情報を取得する方法のサンプルも見られます。だから、ドキュメントを読んで、実際のエラーメッセージを手に入れてください。その情報を使って解決できない場合は、少なくとも質問に追加してください。 – GolezTrol