mysqli_connect() using mamp

时间:2015-05-12 23:42:42

标签: php mysql mamp mamp-pro

I have MAMP up and running and can run php in my browser, but when i attempt to connect to a MySQL database the connection fails. How do I correct this? I have read that to fix this I need to public HttpResponseMessage GetDetails(int assignmentId) { var valuation = _valuationRepository.GetOneById(assignmentId); Mapper.CreateMap<UserLicenses, UserLicenseResponseModel>() .ForMember(dest => dest.State, opt => opt.MapFrom(src => src.States.StateCode)) .ForMember(dest => dest.UserId, opt => opt.MapFrom(src => src.UserId)) .ForMember(dest => dest.FullName, opt => opt.MapFrom(src => (src.UserProfile != null) ? (src.UserProfile.FirstName + ' ' + src.UserProfile.LastName) : " ")); Mapper.CreateMap<AdditionalExpenses, AdditionalExpensesResponseModel>(); Mapper.CreateMap<ValuationAssignment, ValuationAssignmentResponseModel>(); var model = Mapper.Map<ValuationAssignmentResponseModel>(valuationAssignment); return Request.CreateResponse(HttpStatusCode.OK, new { Assignment = model }); }

I attempted this but i have multiple "enable php_mysqli extension in PHP.ini. It’s disabled by default. look for the following line: extension=php_mysqli". files and the first one i clicked on did not even have the line PHP.ini

I would like to know how to fix this problem so that i can test websites on my computer and not have to upload to a web server, also once everything is set up properly what are the correct parameters for the mysqli_connect() function?

2 个答案:

答案 0 :(得分:0)

刚刚安装了MAMP来帮助你,MAMP文件夹中没有php.ini

文件夹中只有一个文件php.ini

C:\MAMP\conf\php5.6.3\

因为php5.6.3是我的MAMP安装的默认版本。

对于我的MAMP安装,MySQL的默认用户是root,密码是root

答案 1 :(得分:0)

我遇到了这个问题,我的mysqli()函数在多个在线服务器上使用后似乎无法正常工作。但不是在MAMP上!我按照上述所有说明查看了php.ini文件。

我的修复......

我的MAMP PHP版本设置为7.0.0(标准安装) 我把它改回5.6.13进行测试,一切都开始正常工作了!

我真的不确定是什么导致它,或者如何修复它以使用更高版本的PHP版本。

自版本5.6.13以来,也许有些东西发生了变化。

希望这有助于某人!如果您知道我的问题发生的原因,请回复!