<?php session_start();include("Conn/conn.php");$ISBN=$_POST["ISBN"];$B_Name=$_POST["bookName"];$B_Author=$_POST["B_Author"];$B_Pub=$_POST["B_Pub"];$B_Author=$_POST["B_Author"];$B_BuyTime=date("Y-m-d");$B_Num=$_POST["B_Num"];$Content=$_POST["content"];echo $B_Num."<br>";//测试输出语句echo $Content;//测试输出语句$sql1=mysql_query("insert into book1(ISBN,B_Name,B_Author,B_Pub,B_BuyTime)values('$ISBN','$B_Name','$B_Author','$B_Pub','$B_BuyTime')");$sql2=mysql_query("insert into book2(B_Num,ISBN,Borrowed,Ordered,Introduction)values('$B_Num','$ISBN','否','否','$Content')");echo "<script language='javascript'>alert('图书信息添加成功!');history.back();location.href='book.php';</script>";?><meta http-equiv="Content-Type" content="text/html; charset=gb2312">
这是另一个PHP文件单击“提交”按钮后执行的PHP文件,通过输出测试$B_Num和$Content明确这两个变量中都有值。执行后查看mysql数据库可知book1表中成功插入一行数据,但是book2表中并未插入数据,好像只有sql1语句执行了,sql2语句并没有执行,那位大侠帮帮我修改一下,能达到的同时向两个不同表中插入数据就行!
回复讨论(解决方案)
var_dump($sql1, $sql2);
贴出结果
前两行为echo $B_Num."
";与echo $Content;显示结果,后三行为添加var_dump($sql1, $sql2)后的输出内容
输出变量为NULL ?
$sql2=mysql_query("insert into book2(B_Num,ISBN,Borrowed,Ordered,Introduction)values('$B_Num','$ISBN','否','否','$Content')") or die(mysql_error());
这样看看有不有错误信息
前两行为echo $B_Num."
";与echo $Content;显示结果,后三行为添加var_dump($sql1, $sql2)后的输出内容 你加载哪里的呀?
要在 $sql2=mysql_query("insert into book2(B_Num.... 的下一行加
肯定是你的insert语句有问题。首先检查每个val是否与field类型匹配,然后检查有没有非空字段没有赋值的。
然后你的SQL语句用的是单引号包含的变量,双引号串中的内容可以被解释而且替换,而单引号串中的内容总被认为是普通字符。如果上面方法都不行,就把单引号换成双引号试试。
谢谢大家!问题解决了,真如你们所言原来就是一个中文逗号的问题。。。让我郁闷了半天。。。再次感谢!

ThebestapproachforsendingemailsinPHPisusingthePHPMailerlibraryduetoitsreliability,featurerichness,andeaseofuse.PHPMailersupportsSMTP,providesdetailederrorhandling,allowssendingHTMLandplaintextemails,supportsattachments,andenhancessecurity.Foroptimalu

The reason for using Dependency Injection (DI) is that it promotes loose coupling, testability, and maintainability of the code. 1) Use constructor to inject dependencies, 2) Avoid using service locators, 3) Use dependency injection containers to manage dependencies, 4) Improve testability through injecting dependencies, 5) Avoid over-injection dependencies, 6) Consider the impact of DI on performance.

PHPperformancetuningiscrucialbecauseitenhancesspeedandefficiency,whicharevitalforwebapplications.1)CachingwithAPCureducesdatabaseloadandimprovesresponsetimes.2)Optimizingdatabasequeriesbyselectingnecessarycolumnsandusingindexingspeedsupdataretrieval.

ThebestpracticesforsendingemailssecurelyinPHPinclude:1)UsingsecureconfigurationswithSMTPandSTARTTLSencryption,2)Validatingandsanitizinginputstopreventinjectionattacks,3)EncryptingsensitivedatawithinemailsusingOpenSSL,4)Properlyhandlingemailheaderstoa

TooptimizePHPapplicationsforperformance,usecaching,databaseoptimization,opcodecaching,andserverconfiguration.1)ImplementcachingwithAPCutoreducedatafetchtimes.2)Optimizedatabasesbyindexing,balancingreadandwriteoperations.3)EnableOPcachetoavoidrecompil

DependencyinjectioninPHPisadesignpatternthatenhancesflexibility,testability,andmaintainabilitybyprovidingexternaldependenciestoclasses.Itallowsforloosecoupling,easiertestingthroughmocking,andmodulardesign,butrequirescarefulstructuringtoavoidover-inje

PHP performance optimization can be achieved through the following steps: 1) use require_once or include_once on the top of the script to reduce the number of file loads; 2) use preprocessing statements and batch processing to reduce the number of database queries; 3) configure OPcache for opcode cache; 4) enable and configure PHP-FPM optimization process management; 5) use CDN to distribute static resources; 6) use Xdebug or Blackfire for code performance analysis; 7) select efficient data structures such as arrays; 8) write modular code for optimization execution.

OpcodecachingsignificantlyimprovesPHPperformancebycachingcompiledcode,reducingserverloadandresponsetimes.1)ItstorescompiledPHPcodeinmemory,bypassingparsingandcompiling.2)UseOPcachebysettingparametersinphp.ini,likememoryconsumptionandscriptlimits.3)Ad


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

WebStorm Mac version
Useful JavaScript development tools
