PHP POST无法获得数据
Jun 06, 2016 pm 08:36 PM
<code><?php if (!empty($_POST['work_content'])) { include ("conn.php"); $sql = "insert into work ( work_id, work_content, work_time, work_salary, work_jiesuan, work_location, work_population, work_enterprise_title, release_time) values ( null, '$_POST[work_content]', '$_POST[work_time]', '$_POST[work_location]', '$_POST[work_salary]', '$_POST[work_jiesuan]', '$_POST[work_population]', '$_POST[work_enterprise_title]', now())"; mysql_query($sql); mysql_set_charset("utf-8"); } ?> </code>
无法得到数据..另外一张页面同样的方法都可以
回复内容:
<code><?php if (!empty($_POST['work_content'])) { include ("conn.php"); $sql = "insert into work ( work_id, work_content, work_time, work_salary, work_jiesuan, work_location, work_population, work_enterprise_title, release_time) values ( null, '$_POST[work_content]', '$_POST[work_time]', '$_POST[work_location]', '$_POST[work_salary]', '$_POST[work_jiesuan]', '$_POST[work_population]', '$_POST[work_enterprise_title]', now())"; mysql_query($sql); mysql_set_charset("utf-8"); } ?> </code>
无法得到数据..另外一张页面同样的方法都可以
如果$_POST没有,看看php://input
直接打印出post数组看
<code>php</code><code>var_dump($_POST); </code>
首先,你需要确认POST是否有数据,var_dump($_POST)试试。
其次需要确认sql没有问题,可以保存mysql_query的返回值,如果为false,就打印mysql_error试试。或者直接把$sql打印出来,在mysql客户端或者phpmyadmin里调试,看sql语句本身是否有问题。
需要注意的是,你直接在SQL里使用$_POST变量,这样有sql注入漏洞。建议用mysql_real_escape_string过滤。或者使用pdo bind。
这代码,看得真酸爽,wtf
接收一下mysql_query($sql)看下!

熱門文章

熱門文章

熱門文章標籤

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

適用於 Ubuntu 和 Debian 的 PHP 8.4 安裝和升級指南

如何設定 Visual Studio Code (VS Code) 進行 PHP 開發
