PHP MySQL INSERT未插入,也未显示任何错误 [英] PHP MySQL INSERT not inserting nor any error is displayed

查看:101
本文介绍了PHP MySQL INSERT未插入,也未显示任何错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经获得了这段代码,因此可以通过PHP将值插入MySQL的表中.我已经尝试了所有可能的插入语法,但没有插入数据...这是我使用的代码.

I have got this code so insert values into a table in MySQL through PHP. I have tried all the possible Insert syntax, it does not insert the data... this are the codes that i used.

$param = "xyzxyz";
$param1 = "sdfdfg";
$sql = "INSERT INTO trail (User_Name, Quiz_ID) VALUES ('".$param."','".$param1."')";
$result = $mysql->query($sql);
if($result)
   echo "successful";
else
   echo mysql->error;
if(mysql->errno==0)
   echo "successful"
else
   echo mysql->error;

我什至尝试了以下sql语法

I even tried the following sql syntax

"INSERT INTO trail (User_Name, Quiz_ID) VALUES ('$param1','$param1')";

"INSERT INTO `trail` (`User_Name`, `Quiz_ID`) VALUES ('$param1','$param1')";

,我尝试了其他几个尝试,但没有一个将任何内容插入表中.这是MySQL中的表格;

and i tried several other none of them inserts anything into the table. and this is the table in MySQL;

trail

User_Name varchar(35)
Quiz_ID varchar(35)

它不插入任何内容,也不显示任何错误.而且我具有正确的数据库连接,因为我能够从表中进行选择.它只是棘手的插入.

It does not insert anything nor does it display any error. And I have the correct DB connection because i am able to Select from the table. Its just the insert that is tricky.

任何帮助将不胜感激.

谢谢

推荐答案

我的表是InnoDB表,当我将表更改为MyISAM时,插入工作正常.好吧,我以前从未遇到过这个问题.好吧,这暂时起到了作用.

My tables were InnoDB tables and when i changed my tables to MyISAM the insert worked fine. Well i have never encountered this problem before. Well that did the trick for the time being.

如果我想使用InnoDB引擎进行交易?我如何获取PHP以便能够在InnoDB表中插入值?任何人有任何建议吗?我正在使用WAMP服务器,而MySQL是5.5.24版.而且我确实在my.ini中更改了InnoDB conf,但这似乎也不起作用?

If i want to use InnoDB engine for transactions? How can i get php to be able to insert values in InnoDB table? Any one got any suggestion? And i am using WAMP server and the MySQL is version 5.5.24. And i did change the InnoDB conf in my.ini but that did not seem to work either?

这篇关于PHP MySQL INSERT未插入,也未显示任何错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆