我在 SQL 中使用长 INSERT 请求时遇到问题,我的请求在我更新它之前工作得很好,但现在该指令不会在我的数据库中插入任何内容,也不会发出任何错误消息。 这是代码:
try
{
/* On connecte à la base de données MySQL */
$bdd = new PDO('mysql:host=myhost;dbname=mydbname', 'root', 'mypass');
/* On définit la requête SQL à exécuter */
$requeteInscription = 'INSERT INTO interventions
(utilisateur_id, nom_proprietaire,
num_tel_proprietaire, courriel_proprietaire,
informations_bien, interet, delai,
plan_2D, plan_3D, visite_virtuelle,
shooting_photo, annee_construction,
installation_gaz, cle_agence, cave,
garage, type_bien, surface, adresse)
VALUES ("'.$utilisateurId.'","'.$nomProprietaire.'","'
.$numTelProprietaire.'","'.$courrielProprietaire.'","'
.$infosBien.'","'.$delai.'","'
.$plan2D.'","'.$plan3D.'","'.$visiteVirtuelle.'","'
.$shootingPhoto.'","'.$anneeConstruction.'","'
.$installationGaz.'","'.$cleAgence.'","'.$cave.'","'
.$garage.'","'.$typeBien.'","'.$surface.'","'.$adresse.'")';
sleep(1);
$requete = $bdd->prepare($requeteInscription);
$requete->execute();
echo '#1';
}
catch(PDOException $e)
{
echo('Erreur! : '.$e->getMessage().'</br>');
die();
}
这是我在 requeteInscription 上回显时返回的请求:
INSERT INTO interventions (utilisateur_id, nom_proprietaire, num_tel_proprietaire, courriel_proprietaire, informations_bien, interet, delai, plan_2D, plan_3D, visite_virtuelle, shooting_photo, annee_construction, installation_gaz, cle_agence, cave, garage, type_bien, surface, adresse) VALUES ("5","Cyrille ","946458","hidden.email@stackoverflow.com","Local d'activité","Entre 4 et 6 jours.","Oui","Non","1","Non","1","2","0","1","1","3","123","Hdhdhd")
我没有看到语法错误在哪里(我猜这是一个语法错误,因为当我这样做时,它永远不会给我返回错误消息)
最佳答案
您在插入查询中缺少一个值。 请在插入查询中再添加一个值。剩下的查询没问题。
插入干预措施(utilisateur_id、nom_proprietaire、num_tel_proprietaire、courriel_proprietaire、informations_bien、interet、delai、plan_2D、plan_3D、visite_virtuelle、shooting_photo、annee_construction、installation_gaz、cle_agence、cave、garage、type_bien、surface、addresse)VALUES(“5” "Cyrille","946458","hidden.email@stackoverflow.com","Local d'activité","Entre 4 et 6 jours.","Oui","Non","1","Non""1","2","0","1","1","3","123","HDHDHD","");
关于php - INSERT 请求在没有错误消息的情况下不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39287965/
我好像记得Lua有类似Ruby的method_missing的东西。还是我记错了? 最佳答案 表的metatable的__index和__newindex可以用于与Ruby的method_missing相同的效果。 关于ruby-难道Lua没有和Ruby的method_missing相媲美的东西吗?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/7732154/
我有一个奇怪的问题:我在rvm上安装了rubyonrails。一切正常,我可以创建项目。但是在我输入“railsnew”时重新启动后,我有“程序'rails'当前未安装。”。SystemUbuntu12.04ruby-v"1.9.3p194"gemlistactionmailer(3.2.5)actionpack(3.2.5)activemodel(3.2.5)activerecord(3.2.5)activeresource(3.2.5)activesupport(3.2.5)arel(3.0.2)builder(3.0.0)bundler(1.1.4)coffee-rails(
这是在Ruby中设置默认值的常用方法:classQuietByDefaultdefinitialize(opts={})@verbose=opts[:verbose]endend这是一个容易落入的陷阱:classVerboseNoMatterWhatdefinitialize(opts={})@verbose=opts[:verbose]||trueendend正确的做法是:classVerboseByDefaultdefinitialize(opts={})@verbose=opts.include?(:verbose)?opts[:verbose]:trueendend编写Verb
在我的Controller中,我通过以下方式在我的index方法中支持HTML和JSON:respond_todo|format|format.htmlformat.json{renderjson:@user}end在浏览器中拉起它时,它会自然地以HTML呈现。但是,当我对/user资源进行内容类型为application/json的curl调用时(因为它是索引方法),我仍然将HTML作为响应。如何获取JSON作为响应?我还需要说明什么? 最佳答案 您应该将.json附加到请求的url,提供的格式在routes.rb的路径中定义。这
我想在一个没有Sass引擎的类中使用Sass颜色函数。我已经在项目中使用了sassgem,所以我认为搭载会像以下一样简单:classRectangleincludeSass::Script::FunctionsdefcolorSass::Script::Color.new([0x82,0x39,0x06])enddefrender#hamlengineexecutedwithcontextofself#sothatwithintemlateicouldcall#%stop{offset:'0%',stop:{color:lighten(color)}}endend更新:参见上面的#re
如果您尝试在Ruby中的nil对象上调用方法,则会出现NoMethodError异常并显示消息:"undefinedmethod‘...’fornil:NilClass"然而,有一个tryRails中的方法,如果它被发送到一个nil对象,它只返回nil:require'rubygems'require'active_support/all'nil.try(:nonexisting_method)#noNoMethodErrorexceptionanymore那么try如何在内部工作以防止该异常? 最佳答案 像Ruby中的所有其他对象
rails中是否有任何规定允许站点的所有AJAXPOST请求在没有authenticity_token的情况下通过?我有一个调用Controller方法的JqueryPOSTajax调用,但我没有在其中放置任何真实性代码,但调用成功。我的ApplicationController确实有'request_forgery_protection'并且我已经改变了config.action_controller.consider_all_requests_local在我的environments/development.rb中为false我还搜索了我的代码以确保我没有重载ajaxSend来发送
大家好!我想知道Ruby中未使用语法ClassName.method_name调用的方法是如何工作的。我头脑中的一些是puts、print、gets、chomp。可以在不使用点运算符的情况下调用这些方法。为什么是这样?他们来自哪里?我怎样才能看到这些方法的完整列表? 最佳答案 Kernel中的所有方法都可用于Object类的所有对象或从Object派生的任何类。您可以使用Kernel.instance_methods列出它们。 关于没有类的Ruby方法?,我们在StackOverflow
我最近决定从我的系统中卸载RVM。在thispage提出的一些论点说服我:实际上,我的决定是,我根本不想担心Ruby的多个版本。我只想使用1.9.2-p290版本而不用担心其他任何事情。但是,当我在我的Mac上运行ruby--version时,它告诉我我的版本是1.8.7。我四处寻找如何简单地从我的Mac上卸载这个Ruby,但奇怪的是我没有找到任何东西。似乎唯一想卸载Ruby的人运行linux,而使用Mac的每个人都推荐RVM。如何从我的Mac上卸载Ruby1.8.7?我想升级到1.9.2-p290版本,并且我希望我的系统上只有一个版本。 最佳答案
我真的为这个而疯狂。我一直在搜索答案并尝试我找到的所有内容,包括相关问题和stackoverflow上的答案,但仍然无法正常工作。我正在使用嵌套资源,但无法使表单正常工作。我总是遇到错误,例如没有路线匹配[PUT]"/galleries/1/photos"表格在这里:/galleries/1/photos/1/edit路线.rbresources:galleriesdoresources:photosendresources:galleriesresources:photos照片Controller.rbdefnew@gallery=Gallery.find(params[:galle