求高人检查下面的代码错在哪里。
代码如下,添加后提示添加失败。
<br /><meta http-equiv='Content-Type' content='text/html; charset=utf-8' /> <br /><?php<br />phpinfo();<br />//这是一个信息增、删、改操作处理页面<br /><br />//一、导入配置文件。<br /> require("dbconfig.php");<br />//二、链接MYSQL、并选择数据库。<br /> $link = @mysql_connect(HOST,USER,PASS) or die("数据库链接错误!");<br /> mysql_select_db(DBNAME,$link);<br />//三、根据action的值,来判断所操作,执行对应的代码。<br /> switch ($_GET["action"]){<br /> case "add": //执行添加<br /> //1、获取要添加的信息,并补充其它信息<br /> $title = $_POST["title"];<br /> $keywords = $_POST["keywords"];<br /> $author = $_POST["author"];<br /> $content = $_POST["content"];<br /> $addtime = time();<br /> //2、添加信息过过滤(省略)<br /> //3、拼装添加SQL语句,并执行添加操作<br /> $sql = "insert into news valuse(null,'{$title}','{$keywords}','{$author}','{$addtime}','{$content}')";<br />// echo $sql; //这一步打印正常。<br /> mysql_query($sql,$link);<br /> //4、判断是否添加成功,<br /> $id = mysql_insert_id($link);//判断刚刚添加的信息ID值值<br /> echo $id;<br /> break;<br /> if ($id>0){<br /> echo"<h3 id="添加成功">添加成功</h3>";<br /> }else{<br /> echo"<h3 id="添加失败">添加失败</h3>";<br /> }<br /> break;<br /> <br /> case "del": //执行删除<br /> <br /> break;<br /> <br /> case "update": //执行修改<br /> <br /> break;<br /> <br /> }<br />//四、关闭数据库<br />mysql_close($link);<br />?><br />
------解决方案--------------------
第一段:insert?into?news?valuse
第二段:insert into news values
一个是valuse另一个是valuse

PHPsessionscanstorestrings,numbers,arrays,andobjects.1.Strings:textdatalikeusernames.2.Numbers:integersorfloatsforcounters.3.Arrays:listslikeshoppingcarts.4.Objects:complexstructuresthatareserialized.

TostartaPHPsession,usesession_start()atthescript'sbeginning.1)Placeitbeforeanyoutputtosetthesessioncookie.2)Usesessionsforuserdatalikeloginstatusorshoppingcarts.3)RegeneratesessionIDstopreventfixationattacks.4)Considerusingadatabaseforsessionstoragei

Session regeneration refers to generating a new session ID and invalidating the old ID when the user performs sensitive operations in case of session fixed attacks. The implementation steps include: 1. Detect sensitive operations, 2. Generate new session ID, 3. Destroy old session ID, 4. Update user-side session information.

PHP sessions have a significant impact on application performance. Optimization methods include: 1. Use a database to store session data to improve response speed; 2. Reduce the use of session data and only store necessary information; 3. Use a non-blocking session processor to improve concurrency capabilities; 4. Adjust the session expiration time to balance user experience and server burden; 5. Use persistent sessions to reduce the number of data read and write times.

PHPsessionsareserver-side,whilecookiesareclient-side.1)Sessionsstoredataontheserver,aremoresecure,andhandlelargerdata.2)Cookiesstoredataontheclient,arelesssecure,andlimitedinsize.Usesessionsforsensitivedataandcookiesfornon-sensitive,client-sidedata.

PHPidentifiesauser'ssessionusingsessioncookiesandsessionIDs.1)Whensession_start()iscalled,PHPgeneratesauniquesessionIDstoredinacookienamedPHPSESSIDontheuser'sbrowser.2)ThisIDallowsPHPtoretrievesessiondatafromtheserver.

The security of PHP sessions can be achieved through the following measures: 1. Use session_regenerate_id() to regenerate the session ID when the user logs in or is an important operation. 2. Encrypt the transmission session ID through the HTTPS protocol. 3. Use session_save_path() to specify the secure directory to store session data and set permissions correctly.

PHPsessionfilesarestoredinthedirectoryspecifiedbysession.save_path,typically/tmponUnix-likesystemsorC:\Windows\TemponWindows.Tocustomizethis:1)Usesession_save_path()tosetacustomdirectory,ensuringit'swritable;2)Verifythecustomdirectoryexistsandiswrita


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

SublimeText3 Chinese version
Chinese version, very easy to use

Dreamweaver CS6
Visual web development tools

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

WebStorm Mac version
Useful JavaScript development tools
