Php

     
I downloaded downloading XAMPPhường for my learning lesson. After I finished theinstall, I can use it normally. But when I try to connect lớn MySquốc lộ I keep return this error.

Bạn đang xem: Php

function connect() $link=mysql_connect("DB_HOST","DB_USER","DB_PWD") or die("连接失败Error:".mysql_error().":".mysql_error()); mysql_select_db(DB_DBNAME); return $link;

*

*

First, Kindly ensure the MySQL service is running.

mở cửa XAMPP Control PanelCliông chồng on Start button corresponding to lớn MySQL module.

Then, Try checking khổng lồ see if the PHP MySquốc lộ extension module is being loaded:

Run the above sầu code/page & tìm kiếm for mysql.If it"s not there, add the following lớn the php.ini file:

extension=php_mysql.dllUpdate: mysql_* functions have been removed in PHP 7. You probably have a php7 in XAMPPhường. Please use PDO or mysqli_connect("DB_HOST","DB_USER","DB_PWD") instead of mysql_connect().

Xem thêm: Tại Sao Bạn Bè Không Chia Sẻ Được Bài Viết Của Tôi, Các Tính Năng Chia Sẻ Trong Facebook Bạn Cần Biết


*

First of all looking at your code; you have sầu this part:

function connect() $link=mysql_connect("DB_HOST","DB_USER","DB_PWD") or die("连接失败Error:".mysql_error().":".mysql_error()); mysql_select_db(DB_DBNAME); return $link; After you have sầu closed the php tag("?>"); meaning what comes after the closing php tag is not part of your php code. So try inserting the closing php tag at the over of your code. Something like this:

As for your code; I would simply rewrite it as:

Then try connecting lớn your MySQL database.


*

Thanks for contributing an answer khổng lồ Staông chồng Overflow!

Please be sure to lớn answer the question. Provide details and nói qua your research!

But avoid

Asking for help, clarification, or responding to lớn other answers.Making statements based on opinion; baông chồng them up with references or personal experience.

To learn more, see our tips on writing great answers.


Post Your Answer Discard

By clicking “Post Your Answer”, you agree lớn our terms of service, privacy policy and cookie policy


Not the answer you're looking for? Browse other questions tagged mysql xampp or ask your own question.


*

site kiến thiết / hình ảnh sản phẩm © 2021 Stack Exchange Inc; web1_user contributions licensed under cc by-sa. rev2021.5.14.39304


Your privacy

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and discthua information in accordance with our Cookie Policy.