首页 \ 问答 \ 将数据插入mysql db时,Null Php变量(Null Php Variable when inserting data into mysql db)

将数据插入mysql db时,Null Php变量(Null Php Variable when inserting data into mysql db)

所以我正在使用Web服务开发一个Android项目。 我有一些问题,比如在我的数据库中插入一些数据时,我的php无法识别变量或类似的东西,它确实为数字插入值“0”,并且在使用邮递员测试后为字符串插入空格,甚至是应用本身。

这是我的PHP文件内容:

<?php
$con = mysqli_connect("...","...","...","...");

    $card_number = $_POST["card_number"];

    $query = "INSERT INTO card (card_number,card_solde,date_exp) VALUES ('$card_number',0,2024)";

    mysqli_query($con,$query) or die(mysqli_error($con));

    $response = array();
    $response["success"] = true;  
    echo json_encode($response);

    mysqli_close($con);
?>

这是表模式的图像和插入的结果。 https://imgur.com/aJvdbxF

谢谢youuu :))


So i'm working on an Android project using web services. I've got some problems like while inserting some data in my db, my php doesn't recognize the variable or something like that and it does insert value "0" for numbers and a blank space for Strings after testing with postman or even the app itself.

Here's my PHP file content :

<?php
$con = mysqli_connect("...","...","...","...");

    $card_number = $_POST["card_number"];

    $query = "INSERT INTO card (card_number,card_solde,date_exp) VALUES ('$card_number',0,2024)";

    mysqli_query($con,$query) or die(mysqli_error($con));

    $response = array();
    $response["success"] = true;  
    echo json_encode($response);

    mysqli_close($con);
?>

Here's an image for the table schema and the result of the insertion. https://imgur.com/aJvdbxF

Thank youuu :))


原文:https://stackoverflow.com/questions/37148574
更新时间:2022-12-26 14:12

最满意答案

假设客户端应用程序与WCF服务项目位于同一解决方案中,请单击客户端应用程序并选择“添加服务引用”。

将显示一个对话框,您可以通过单击右上角标有“发现”的按钮来选择服务。

假设绑定已正确设置并可用于WCF服务(通过app.config文件或类似文件),IDE将自动为您托管服务。 - 请注意,app.config应位于WCF服务项目中,除非解决方案中的另一个项目中已有指定的主机。

如果托管服务有任何问题,将出现一个新的对话框,服务端点的右侧列显示“错误”。 单击错误行将解释为什么存在问题并希望帮助您解决问题。


Assuming the Client Application is in the same solution as the WCF Service project, r-click the client application and choose "Add Service Reference".

A dialogue is displayed allowing you to select your Service by clicking the button in the top right labelled "Discover".

Assuming the binding is correctly set and available for the WCF Service (via an app.config file or similar) the IDE will automatically host the service for you. - note, the app.config should be located within the WCF Service project unless there is a designated host already available in another project within the solution.

If there are any issues hosting the service, a new dialogue will appear, with the right hand column for your service endpoints saying "Error". Clicking the errored line will explain why there is an issue and hopefully help you to resolve it.

相关问答

更多
  • 听起来你已经注入了使用Unity的MVC控制器,并且你想要做的就是开始注入你所托管的WCF服务。 要注入WCF服务,您需要使用IInstanceProvider 。 完整的工作解决方案如下: http://orand.blogspot.com/2006/10/wcf-service-dependency-injection.html 你需要4个非常非常简单的类: MyServiceHostFactory MyServiceHost DependencyInjectionServiceBehavior D ...
  • RIA服务是一种服务器端技术,可以自动生成负责与服务器通信的客户端(Silverlight)对象,并提供客户端验证。 RIA服务中的主要对象是DomainService ,通常是连接到LinqToEntities模型的LinqToEntitiesDomainService。 在RIA服务中要记住的关键是它主要是一个复杂的构建技巧。 当您创建域服务并编译解决方案时,将生成您的域服务的客户端表示。 此客户端表示具有相同的界面。 假设您使用方法IQueryable GetCustomersBy ...
  • 要从其他解决方案访问WCF服务,您必须: 在您的实际项目中,右键单击WCF服务>在浏览器中查看(我假设WCF服务托管在IIS上)。 复制URL(它将是一个像http://localhost:12345/MyWCFService.svc这样的URL) 在新项目中,右键单击项目>添加服务引用 粘贴网址 希望能帮助到你 To access on a WCF service from another solution, you have to : On your actual project, right clic ...
  • DurableService使用内置的WCF功能,使用BasicHttpContextBinding或WSHttpContextBinding将状态(模块级变量)传递给客户端。 持久性机制取决于客户端上的HTTP cookie或用于在调用之间存储序列化数据的soap头。 您的平均肥皂消息大小将是100KB加上每次调用时操作参数保持的任何有效负载。 您还必须将CanCreateInstance和CompleteInstance语义设计到操作合同和应用程序逻辑中,以正确删除会话有效负载。 考虑到1000+ 并发 ...
  • 我们在我们的应用程序中使用内置的HttpRuntime缓存,它运行良好。 它很容易安装到位,因为您的服务器上无需安装任何内容。 此外,迁移到AppFabric缓存不应该在以后这么大。 也就是说,它还带来了一些限制,特别是如果您的服务不在同一个IIS应用程序中托管,因为缓存的对象将被复制到每个应用程序中。 如果您不打算缓存大量数据和/或如果您不打算长时间缓存它们,那么您应该没问题,因为您最终不会消耗太多RAM。 您似乎没有负载平衡的服务器,但在这种情况下,使用HttpRuntime缓存还意味着复制每台服务器上 ...
  • 清理解决方案有助于实现以下两点之一: 您重新启动了解决方案并重置了某些内容(连接池,线程,类加载器缓存等)。 尝试重新启动解决方案而不进行清洁,看看是否是这种情况 您的构建过程以某种方式为多个位置的相同代码生成DLL,当您执行基本构建时,只会更新其中一个。 这可能会导致接口不匹配,序列化版本不匹配或其他类似问题。 尝试在整个解决方案中搜索DLL名称,并查看它显示的位置数。 然后执行基本构建并查看其中有多少更改了时间戳。 同样,尝试使用FileMon来查看DLL实际加载的位置。 The fact that c ...
  • 您可以使用svcutil.exe的/namespace参数为生成的类指定不同的命名空间。 如果要在驻留在WCF客户端库中的客户端和服务器之间共享相同的datacontract定义,则可以完全跳过svcutil.exe并直接使用ChannelFactory 。 该链接有一个如何执行此操作的示例。 You can use the /namespace argument to svcutil.exe to specify a different namespace for generated classes. I ...
  • 假设客户端应用程序与WCF服务项目位于同一解决方案中,请单击客户端应用程序并选择“添加服务引用”。 将显示一个对话框,您可以通过单击右上角标有“发现”的按钮来选择服务。 假设绑定已正确设置并可用于WCF服务(通过app.config文件或类似文件),IDE将自动为您托管服务。 - 请注意,app.config应位于WCF服务项目中,除非解决方案中的另一个项目中已有指定的主机。 如果托管服务有任何问题,将出现一个新的对话框,服务端点的右侧列显示“错误”。 单击错误行将解释为什么存在问题并希望帮助您解决问题。 ...
  • 你链接的问题中的答案非常清楚,如果你在这两行之间阅读: 使用“Is One way”= true调用WCF日志记录服务,以便您的客户端程序不会等待日志记录完成。 设置WCF设置,以便客户端不会限制请求数 The answer in the question you linked to covers it quite well, if you read between the lines: Call the WCF logging service with "Is One way" = true, so th ...
  • 是的,可能有问题。 IIS中的应用程序池可以被回收,这意味着后台线程将被杀死,即使它正处于某些处理过程中。 实际上,只有在更新应用程序时才会出现问题(因为当应用程序池由于空闲超时而停止时应该完成记录器)。 因此,如果您在更新期间可以使用丢失的日志条目,那么您就没有问题。 Yes, there can be a problem. The application pool in IIS can get recycled which means that the background thread will be ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。