$link = mysql_connect ( '127.0.0.1:3308' ,'root' ,'123456' );
if (! $link ) {
die( 'Could not connect: '. mysql_error ());
}
mysql_select_db("stu")or die(mysql_error());
mysql_query("set name utf-8");
$name = $_POST['name'];
$age = $_POST['age'];
$aihao= $_POST['aihao'];
$sql = "insert into student (u_name,u_age,u_xq)value('$name','$age','$aihao')";
$res =mysql_query($sql,$link) or die(mysql_error());
mysql_free_result($res) or die(mysql_error());
mysql_close($link);
echo "chenggong".$res;
以上是代码 为什么 Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in F:\PHPnow-1.5.6\htdocs\stu\addok.php on line 18
这样问题
数据库 连接成功可以 打印SQl语句 去数据库执行也可以 为什么总出这样错误 受不了 求大神 自学好辛苦的
回复讨论(解决方案)
数据库 也写不进去了 只能打印出SQL 去数据库执行 是可以的
mysql_free_result() 仅需要在考虑到返回很大的结果集时会占用多少内存时调用。在脚本结束后所有关联的内存都会被自动释放。
您执行的是 insert 指令,并不会返回结果集。所以并不存在结果集释放的问题
潜在的问题:
1、mysql_query("set name utf-8");
MySQL 只有 utf8 并无 utf-8
2、$sql = "insert into student (u_name,u_age,u_xq) value('$name','$age','$aihao')";
只有 values 并无 value
谢谢 兄弟
我改了 你看 还是写不进去
insert into student (u_name,u_age,u_xq)values('ee ','22','111')
Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in F:\PHPnow-1.5.6\htdocs\stu\addok.php on line 20
是不是 数据库 重启 或者安装配置问题
再说一遍!
执行 insert(update、delete等)指令只会返回逻辑值,用以表示是否执行成功
并没有结果集返回,所以也就没有释放
谢谢 知道了 版主 谢谢 感谢
free 已经吧结果集清了,还再去调用。。能不出错吗。。

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl

TomakePHPapplicationsfaster,followthesesteps:1)UseOpcodeCachinglikeOPcachetostoreprecompiledscriptbytecode.2)MinimizeDatabaseQueriesbyusingquerycachingandefficientindexing.3)LeveragePHP7 Featuresforbettercodeefficiency.4)ImplementCachingStrategiessuc

ToimprovePHPapplicationspeed,followthesesteps:1)EnableopcodecachingwithAPCutoreducescriptexecutiontime.2)ImplementdatabasequerycachingusingPDOtominimizedatabasehits.3)UseHTTP/2tomultiplexrequestsandreduceconnectionoverhead.4)Limitsessionusagebyclosin

Dependency injection (DI) significantly improves the testability of PHP code by explicitly transitive dependencies. 1) DI decoupling classes and specific implementations make testing and maintenance more flexible. 2) Among the three types, the constructor injects explicit expression dependencies to keep the state consistent. 3) Use DI containers to manage complex dependencies to improve code quality and development efficiency.

DatabasequeryoptimizationinPHPinvolvesseveralstrategiestoenhanceperformance.1)Selectonlynecessarycolumnstoreducedatatransfer.2)Useindexingtospeedupdataretrieval.3)Implementquerycachingtostoreresultsoffrequentqueries.4)Utilizepreparedstatementsforeffi


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

SublimeText3 Linux new version
SublimeText3 Linux latest version

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

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

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

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.
