안녕하세요. 내 데이터베이스에서 내 간단한 추천 앱을 업데이트하지 않는 경우 작은 문제가 있습니다. 이 구문 분석 스크립트를 사용하여 데이터베이스에 항목을 삽입 할 때 내 애플행이 업데이트되지 않음
<?php
$testtitle = preg_replace('#[^a-z0-9""-. ]#i', '', $_POST['ts_tt']);
$testbody = preg_replace('#[^a-z0-9""-. ]#i', '', $_POST['ts_tb']);
$compowner = preg_replace('#[^a-z0-9 ]#i', '', $_POST['ts_co']);
$ownertitle = preg_replace('#[^a-z0-9 ]#i', '', $_POST['ts_ot']);
$compname = preg_replace('#[^a-z0-9 ]#i', '', $_POST['ts_cn']);
$compwebsite = preg_replace('#[^a-z0-9 .-]#i', '', $_POST['ts_cw']);
include_once "../php_includes/db_conx.php";
$sql = "INSERT INTO testimonials (testtitle, testbody, compowner, ownertitle, compname, compwebsite)
VALUES ('$testtitle', '$testbody', '$compowner', '$ownertitle', '$compname', '$compwebsite')";
if (!mysql_query($sql, $connection)){
die('Error: ' . mysql_error());
}
exit();
?>
내가 내 업데이트 스크립트를 업데이트하지 않는 것을 발견 .. 잘 작동! 나는 여기에 뭔가 빠져 있니? 많은 감사 ...
<?php
$pid = $_POST['pid'];
$testtitle = preg_replace('#[^a-z0-9""-. ]#i', '', $_POST['ts_tt']);
$testbody = preg_replace('#[^a-z0-9""-. ]#i', '', $_POST['ts_tb']);
$compowner = preg_replace('#[^a-z0-9 ]#i', '', $_POST['ts_co']);
$ownertitle = preg_replace('#[^a-z0-9 ]#i', '', $_POST['ts_ot']);
$compname = preg_replace('#[^a-z0-9 ]#i', '', $_POST['ts_cn']);
$compwebsite = preg_replace('#[^a-z0-9 .-]#i', '', $_POST['ts_cw']);
include_once "../php_includes/db_conx.php";
$sql = "UPDATE testimonials SET testtitle='$testtitle', testbody='$testbody', compowner='$compowner', ownertitle='$ownertitle', compname='$compname', compwebsite='$compwebsite' WHERE id='$pid' LIMIT 1";
if (!mysql_query($sql, $connection)){
die('Error: ' . mysql_error());
}
exit();
?>
UPDATE 이 내가 지금 너희들이 무엇을 ...
<?php
$sql = "SELECT * FROM testimonials WHERE id='$pid'";
$pid = $_POST['pid'];
$testtitle = preg_replace('#[^a-z0-9""-. ]#i', '', $_POST['ts_tt']);
$testbody = preg_replace('#[^a-z0-9""-. ]#i', '', $_POST['ts_tb']);
$compowner = preg_replace('#[^a-z0-9 ]#i', '', $_POST['ts_co']);
$ownertitle = preg_replace('#[^a-z0-9 ]#i', '', $_POST['ts_ot']);
$compname = preg_replace('#[^a-z0-9 ]#i', '', $_POST['ts_cn']);
$compwebsite = preg_replace('#[^a-z0-9 .-]#i', '', $_POST['ts_cw']);
include_once "../php_includes/db_conx.php";
$sql = "UPDATE testimonials SET testtitle='$testtitle', testbody='$testbody', compowner='$compowner', ownertitle='$ownertitle', compname='$compname', compwebsite='$compwebsite' WHERE id='$pid'";
if (!mysql_query($sql, $connection)){
die('Error: ' . mysql_error());
}
exit();
?>
안녕 여기에 요청 모두 같은 요청에 따라 내 HTML 양식입니다! 나는 그것이 테이블에 있다는 것을 압니다. 나는이 인 형태로 위의 일부 PHP 코드 ...
<?php
$pid = ereg_replace("[^0-9]", "", $_POST['pid']);
include_once "../php_includes/db_conx.php";
$sql = "SELECT testtitle, testbody, compowner, ownertitle, compname, compwebsite FROM testimonials WHERE id='$pid' LIMIT 1";
$query = mysql_query($sql, $connection) or die (mysql_error());
while ($row = mysql_fetch_array($query)) {
$testtitle = $row["testtitle"];
$testtitle = str_replace("<br />", "", $testtitle);
$testbody = $row["testbody"];
$testbody = str_replace("<br />", "", $testbody);
$compowner = $row["compowner"];
$ownertitle = $row["ownertitle"];
$compname = $row["compname"];
$compwebsite = $row["compwebsite"];
}
mysql_free_result($query);
?>
이 그리고 내 양식은 UPDATE에서
<form method="post" action="testimonial_edit_parse.php" onsubmit="return validate_form ();">
<tr>
<td width="12%" align="right" bgcolor="#F5E4A9">Testimonial Full Title</td>
<td width="88%" bgcolor="#F5E4A9"><input name="ts_tt" id="testtitle" type="text" size="80" maxlength="64" value="<?php echo $testtitle; ?>" /></td>
</tr>
<tr>
<td align="right" valign="top" bgcolor="#DAEAFA">Testimonial Body</td>
<td bgcolor="#DAEAFA"><textarea name="ts_tb" id="testbody" cols="60" rows="16"><?php echo $testbody; ?></textarea></td>
</tr>
<tr>
<td align="right" bgcolor="#D7EECC">Company Owner</td>
<td bgcolor="#D7EECC"><input name="ts_co" id="compowner" type="text" maxlength="64" size="80" value="<?php echo $compowner; ?>" /></td>
</tr>
<tr>
<td align="right" bgcolor="#D7EECC">Owner Title</td>
<td bgcolor="#D7EECC"><input name="ts_ot" id="ownertitle" type="text" maxlength="64" size="80" value="<?php echo $ownertitle; ?>"/></td>
</tr>
<tr>
<td align="right" bgcolor="#D7EECC">Company Name</td>
<td bgcolor="#D7EECC"><input name="ts_cn" id="compname" type="text" maxlength="64" size="80" value="<?php echo $compname; ?>" /></td>
</tr>
<tr>
<td align="right" bgcolor="#D7EECC">Company Website</td>
<td bgcolor="#D7EECC"><input name="ts_cw" id="compwebsite" type="text" maxlength="64" size="80" value="<?php echo $compwebsite; ?>" /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="ts_button" value="Submit this edit" /></td>
</tr>
</form>
당신이 $ pid'은 데이터베이스에있는'확신에서 ID와 숨겨진 필드를 채울 필요가? –
mysql_로 시작하는 PHP 함수는 PHP 5.5.0부터 사용되지 않습니다. 그렇게 할 수있는 위치에 있다면, [MySQLi] (http://www.php.net/manual/en/book.mysqli.php) 또는 [PDO] (http : /www.php.net/manual/en/ref.pdo-mysql.php) 확장 기능을 사용하십시오. –
이런 질문이 너무 많습니다. 시간을내어 [오류를 해석하고 코드를 수정하는 방법]을 배우십시오 (http://jason.pureconcepts.net/2013/05/fixing-php-errors/). –