For help! I encountered an inexplicable problem!

Source: Internet
Author: User
For help! I encountered an inexplicable problem! Thinkphp framework


Originally, wamp2.4 win7 could run on another computer. now, with another computer, wamp3.0 win10 cannot run. why? Is the configuration not properly configured?

The following code

Html:


Js:
$ ('# Add_user'). validate ({
SubmitHandler: function (form ){
$ ('# Add_user'). ajaxSubmit ({
Url: ThinkPHP ['module'] + '/User/add ',
Type: 'post ',
Success: function (data ){
Alert (data );
$ ('# Name'). val ("");
$ ('# Phone'). val ("");
$ ('# Id_card'). val ("");
$ ('# Health_card'). val ("");
$ ('# Contact_name'). val ("");
$ ('# Contact_phone'). val ("");
},
});

},
Rules :{
Name :{
Required: true,
},
Age :{
Required: true,
},
Phone :{
Required: true,
},
Id_card :{
Required: true,
},
},
Messages :{
Name :{
Required: 'Name cannot be blank ',
},
Age :{
Required: 'Age cannot be blank ',
},
Phone :{
Required: 'The phone cannot be blank ',
},
Id_card :{
Required: 'ID card cannot be blank ',
},
},
});

Controller:
Public function add (){
$ User = D ('user ');
$ Id = $ user-> add (I ('post. name '), I ('post. phone '), I ('post. id_card '), I ('post. health_card '), I ('post. hospitalized '), I ('post. address '), I ('post. contact_name '), I ('post. contact_phone '));
Echo $ id? $ Id: 0;

}

Model:
Public function add ($ name, $ phone, $ id_card, $ health_card, $ hospitalized, $ address, $ contact_name, $ contact_phone ){

// $ ID card number = '';
$ Birth = strlen ($ id_card) = 15? ('19'. substr ($ id_card, 6, 6): substr ($ id_card, 6, 8 );
$ Birth = substr ($ birth,). '-'. substr ($ birth,). '-'. substr ($ birth, 6, 2 );
List ($ year, $ month, $ day) = explode ("-", $ birth );
$ Year_diff = date ("Y")-$ year;
$ Month_diff = date ("m")-$ month;
$ Day_diff = date ("d")-$ day;
If ($ day_diff <0 | $ month_diff <0)
$ Year_diff --;




$ Age = $ year_diff;
$ Sex = substr ($ id_card, (strlen ($ id_card) = 15? -1:-2), 1) % 2? Male: female ';


$ Data = array (
'Name' => $ name,
'Age' => $ age,
'Sex '=> $ sex,
'Phone' => $ phone,
'Id _ card' => $ id_card,
'Health _ card' => $ health_card,
'Hospitalized' => $ hospitalized,
'Address' => $ address,
'Contact _ name' => $ contact_name,
'Contact _ phone' => $ contact_phone,
);



Return M ('user')-> add ($ data );
}

Firefox error: post xhr http: // localhost/aier/index. php/Home/User/add [HTTP/1.1 404 Not Found 35 ms]

:(
1146: Table 'aier. U' doesn' t exist [SQL statement]: REPLACE INTO 'u' () VALUES ()
Error location

FILE: D: \ wamp64 \ www \ aier \ ThinkPHP \ Library \ Think \ Db \ Driver. class. php LINE: 350
TRACE

#0 D: \ wamp64 \ www \ aier \ ThinkPHP \ Library \ Think \ Db \ Driver. class. php (350): E ('1970: table' aie... ')
#1 D: \ wamp64 \ www \ aier \ ThinkPHP \ Library \ Think \ Db \ Driver. class. php (237): Think \ Db \ Driver-> error ()
#2 D: \ wamp64 \ www \ aier \ ThinkPHP \ Library \ Think \ Db \ Driver. class. php (824): Think \ Db \ Driver-> execute ('replace INTO 'U... ', false)
#3 D: \ wamp64 \ www \ aier \ ThinkPHP \ Library \ Think \ Model. class. php (320): Think \ Db \ Driver-> insert ('20140901', 'u24234', '20140901 ')
#4 D: \ wamp64 \ www \ aier \ APP \ Home \ Controller \ UserController. class. php (12): Think \ Model-> add ('20160301', '20160301', '20160301 ','','','','','')
#5 [internal function]: Home \ Controller \ UserController-> add ()
#6 D: \ wamp64 \ www \ aier \ ThinkPHP \ Library \ Think \ App. class. php (173): ReflectionMethod-> invoke (Object (Home \ Controller \ UserController ))
#7 D: \ wamp64 \ www \ aier \ ThinkPHP \ Library \ Think \ App. class. php (110): Think \ App: invokeAction (Object (Home \ Controller \ UserController), 'ADD ')
#8 D: \ wamp64 \ www \ aier \ ThinkPHP \ Library \ Think \ App. class. php (204): Think \ App: exec ()
#9 D: \ wamp64 \ www \ aier \ ThinkPHP \ Library \ Think. class. php (120): Think \ App: run ()
#10 D: \ wamp64 \ www \ aier \ ThinkPHP. php (97): Think \ Think: start ()
#11 D: \ wamp64 \ www \ aier \ index. php (24): require ('d: \ wamp64 \ www \ ...')
#12 {main}


Originally, wamp2.4 win7 could run on another computer. now, with another computer, wamp3.0 win10 cannot run. why? Is the configuration not properly configured?


Reply to discussion (solution)

This is simply a problem with Win10. I changed win7 and I can use it now.

If 404 is reported, the configuration is incorrect.
But where did your next error message come from?


Table 'aier. U' doesn' t exist [SQL statement]: REPLACE INTO 'u' () VALUES ()
The table aier. u does not exist. it's your problem.

You know the problem.
Controller:
If you use $ user-> add directly, the database will be operated without model connection. for example, if I change $ user-> add of the controller to $ user-> dadd, Think \ Model will be reported: the dadd method does not exist!

$ User = D ('user ');
$ Id = $ user-> dadd (I ('post. name '), I ('post. phone '), I ('post. id_card '), I ('post. health_card '), I ('post. hospitalized '), I ('post. address '), I ('post. contact_name '), I ('post. contact_phone '));

What should I do? My tp version is 3.2.3

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.