作者apolkingg8 (NowDays)
看板PHP
標題[請益] 無法insert到MySQL中
時間Sat Dec 26 02:41:45 2009
程式碼如下
//form部分
<form id="form1" name="form1" method="post" action="try.php">
<label>
<input type="text" name="name" id="name" />
name<br />
<input type="text" name="num" id="num" />
num <br />
<input type="text" name="account" id="account" />
account<br />
<input type="text" name="password" id="password" />
password<br />
<input type="text" name="mail" id="mail" />
mail<br />
<input type="submit" name="submit" id="submit" value="送出" />
</label>
<p>
</form>
//php部分
<?php
$SQLAccessID="******";
$SQLpwd="*******";
$SQLHost="localhost";
$Link=mysql_connect($SQLHost,$SQLAccessID,$SQLpwd);
$sql = 'INSERT INTO `wpd`.`user_table` '
. ' (`UserName`, `UserNumber`, `UserAccount`, `UserPassword`,
`UserRegistDate`, `UserMail`) '
. ' VALUES '
. ' (\'$_POST["name"]\', \'$_POST["num"]\', \'$_POST["account"]\',
\'$_POST["password"]\', \'2009-12-26\', \'$_POST["mail"]\');';
mysql_query($sql,$Link);
?>
就很簡單要把form的值加進tabel內
可是不知道為什麼就是毫無反應....
VALUES內如果不用變數,用一般字元如"123","KKK"就可以順利新增
也有echo $_POST["***"]內的值出來觀察過 確定這部分沒錯
SQL語法是phpMyAdmin產生的 也試跑過了 都ok
請教各位前輩 到底是哪裡出錯了呢...囧>
--
t a ╭ ◥██◣╮ ╭◢█ ◣ ◢█ ◣ theanswer3 ╮
h n ║ █▌ ╰══════════════╯█▌ █ █ █ ║
e s ║ █▌ ◢█◣ ◢█◣ ◢◢◣◣ ◢█◣ ◢ ◤ ◥█ █ ╴ ║
w ║ █▌ █▌█ █◢█ ████ █◢█ ◢◤ ▄ ▄ █ ⊙ ̄ ﹀║
e ║ █▌ ◥██ ◥◤◥ ◥◤◥◤ ◥◤◥ ██ █ ◥█ ◤ ∕︳ ║
r 3╰═◥██◣═▄◤════════════════════▄▆▇▇▇▆╯
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.44.201.143
推 buganini:echo $sql; 然後貼到phpmyadmin跑跑看 12/26 02:50
→ buganini:雖然說你的quote好像就錯了.. 12/26 02:50