|
 |
|
insert ไม่ได้ งมมานานแล้ว กูรู ช่วยด้วยครับ เช็คแล้ว ก็ไม่มีอะไรผิด แต่ไม่สามารถ insert ลงฐานข้อมูลได้สักที |
|
 |
|
|
 |
 |
|
Code (PHP)
<?
session_start();
If ($_SESSION[sess_userid]<>session_id()) {
header( "Location: userlogin.php"); exit();
}
$user_id = $_SESSION['user_id'];
$user_name = $_SESSION['user_name'];
include("blog.inc.php");
my_connect();
if($_POST) {
if(get_magic_quotes_gpc()) {
foreach($_POST as $k => $v) {
$_POST[$k] = stripslashes($v);
}
}
$cat_id = $_POST['cat'];[font=Verdana][/font]
$title = htmlspecialchars($_POST['title'], ENT_QUOTES);
$content = $_POST['content'];
$sql_insert = "INSERT INTO entry VALUES
(' ', '$cat_id', '$user_id,'$title', '$content', '$user_name',' ')";
$result_insert=mysql_db_query("$dbname",$sql_insert);
@mysql_query($sql) or die(mysql_error());
header("Refresh: 3; url=index.php");
echo "บล็อกของท่านถูกจัดเก็บแล้ว และจะไปยังหน้าหลักใน 3 วินาที";
exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<title>Blog: New Entry</title>
<script src="../ckeditor_3.5.2/ckeditor/ckeditor.js"> </script>
<style type="text/css">
<!--
a:link {
text-decoration: none;
color: #003399;
}
a:visited {
text-decoration: none;
color: #FF00FF;
}
a:hover {
text-decoration: none;
color: #FF0000;
}
a:active {
text-decoration: none;
color: #000000;
}
.style4 {
font-family: Arial, Helvetica, sans-serif;
font-size: 9px;
}
-->
</style>
</head>
<body>
<?php
include("_header.php");
?>
<p />
<h3 align="center">สร้างบล็อกใหม่</h3>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="form1" id="form1">
<table border="0" cellspacing="3" cellpadding="0" align="center">
<tr>
<td>หมวด:</td>
<td>
<select name="cat" id="cat">
<?php
foreach($BLOG_CATS as $key => $value) {
echo "<option value=$key>$value</option>";
}
?>
</select>
</td>
</tr>
<tr>
<td>หัวข้อ:</td>
<td><label>
<input name="title" id="title" type="text" size="60" />
</label></td>
</tr>
<tr>
<td>รายละเอียด:</td>
<td>
<textarea cols="80" name="content" id="content" rows="10" class="ckeditor">test </textarea>
<script type="text/javascript">
//<![CDATA[
CKEDITOR.replace( 'message' );
//]]>
</script>
</td>
</tr>
<tr>
<td> </td>
<td align="left"><pre><a href="insert img.html">วิธีการแทรกรูปภาพใน Editor</a></pre></td>
</tr>
<tr>
<td> </td>
<td><label>
<input type="submit" name="Submit1" value="สร้างบล็อกใหม่" />
</label></td>
</tr>
</table>
</form><hr align="center" /><center>
</center><p> </p>
</body>
</html>
Tag : PHP, MySQL

|
|
 |
 |
 |
 |
Date :
2011-03-06 21:48:23 |
By :
was |
View :
991 |
Reply :
5 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
mysql_query($sql) or die(mysql_error());
ลองดูที่ Error น่ะครับ
Go to : PHP MySQL Add/Insert Record
|
 |
 |
 |
 |
Date :
2011-03-07 10:17:04 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่ผ่านครับ
กด submit
พบว่า Query was empty
ครับ
|
 |
 |
 |
 |
Date :
2011-03-07 11:46:51 |
By :
was |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
@mysql_query($sql) or die(mysql_error());
เอาทิ้งไปครับ
|
 |
 |
 |
 |
Date :
2011-03-07 16:16:49 |
By :
PlaKriM |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
@mysql_query($sql) or die(mysql_error());
เอาออกแล้ว แต่ก็ไม่เข้าฐานข้อมูล
มีเพียงบอกว่า ทำการสำเร็จ
ฐานข้อมูล ก็ไม่มีอะไรผิด
เลยไปไหนไม่ได้
ท่านใดผ่านมา ช่วยทีครับ
|
 |
 |
 |
 |
Date :
2011-03-07 20:17:33 |
By :
was |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ได้แล้ว ครับ ตรง code ตรงนี้ นิดเดียว
(' ', '$cat_id', '$user_id,
ใส่ ' '.ไม่ครบ
(' ', '$cat_id', '$user_id',
ขอบคุณ ทุกคำตอบครับ 
|
 |
 |
 |
 |
Date :
2011-03-07 22:57:56 |
By :
was |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|