Why is the data requested by Ajax not saved in the database? Backstage with PHP write, you big God support a recruit

Source: Internet
Author: User
Tags php write
Why is the data requested by Ajax not saved in the database? Backstage with PHP write, you big God support a recruit

if (isset ($_get[' content ')) {
Get parameters from the request URL address
$view _name=$_get["name"];
$view _content=$_get["Content"];
$view _time=$_get["Time"];
$linkview =mysqli_connect ("localhost", "root", "xxxxxxx", "Wordstv") or Die ("Database connection failed:". Mysql_errno ());
$queryview = "INSERT into Wordstv_user_view (User_name,user_content,time,) VALUES ('". $view _name. "', '". $view _content. " , ' ". $view _time.");
[Email Protected]_query ($linkview, $queryview);
if ($resultview) {
echo $view _name. " &&& ". $view _content." &&& ". $view _time;
}
Mysqli_close ($linkview);
}
?>

------to solve the idea----------------------
First determine whether the data submitted by Ajax is correctly fetched.
In PHP, the top plus
$data = $_request;
file_get_contents (' Test.log ', Json_encode ($data), true);

See if you can get the data, and if so, find the problem in the incoming statement.
Otherwise, look for a problem in the JS Ajax-submitted statement.

[Email Protected]_query ($linkview, $queryview) or Die (Mysql_error ()); Here is also a look.
------to solve the idea----------------------
Content usually represents the body, generally larger than
If the entire transmitted data may exceed the 2K limit of the Get mode, you should use the Post method
From the point of view of reducing information leakage, it is more appropriate to use the POST method.

You directly put the incoming data into the library, if the incoming data contains special characters, will result in the insertion failure

You only output the information when the insert succeeds, but you do not respond when the insert fails
Both the success and failure of the operation should return information so that it is convenient to determine the problem
------to solve the idea----------------------
References:
Quote: References:

First determine whether the data submitted by Ajax is correctly fetched.
In PHP, the top plus
$data = $_request;
file_get_contents (' Test.log ', Json_encode ($data), true);

See if you can get the data, and if so, find the problem in the incoming statement.
Otherwise, look for a problem in the JS Ajax-submitted statement.

[Email Protected]_query ($linkview, $queryview) or Die (Mysql_error ()); Here is also a look.

Thank you, it's settled.


If the problem is solved, please paste the knot.
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.