php 버전에서 mysql 연동하는 부분과정에서 mysql부분은 제공을 하지 않는 버전을 쓰고 계셔서 발생되는 오류 입니다. 채택완료
php -v 통해 확인하면 PHP 5.6.22 (cli)
mysql --version mysql Ver 15.1 Distrib 10.1.13-MariaDB, for Linux (x86_64) using readline 5.1
php 버전에서 mysql 연동하는 부분과정에서 mysql부분은 제공을 하지 않는 버전을 쓰고 계셔서 발생되는 오류 입니다.
어떻게 버젼을 변경할 수 있는건가요?
1. php up/sam.php 실행하면 아래와 같이 나옵니다.
PHP Fatal error: Call to undefined function mysql_connect() in /home/wpeed79/public_html/up/sam.php on line 3
Fatal error: Call to undefined function mysql_connect() in /home/wpeed79/public_html/up/sam.php on line 3
2. 브라우져에서 도메인/up/sam.php 실행하면 아래와 같이 나옵니다.
결과 ===> Records deleted: -1 Records deleted: -1
$link = mysql_connect('localhost', 'abc7', 'abc.7'); if (!$link) { die('Could not connect: ' . mysql_error()); } mysql_select_db('abc7');
$resul = mysql_query ("SELECT count(*) from bt_site") or die ("잘못된 질의를 실행했습니다!!");
/* this should return the correct numbers of deleted records */ mysql_query('DELETE FROM mytable WHERE id < 10'); printf("Records deleted: %d\n", mysql_affected_rows());
/* with a where clause that is never true, it should return 0 */ mysql_query('DELETE FROM mytable WHERE 0'); printf("Records deleted: %d\n", mysql_affected_rows());
?>
답변 2개
- https://www.php.net/manual/en/intro.mysql.php
This extension was deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0. Instead, the https://www.php.net/manual/en/book.mysqli.php">MySQLi or https://www.php.net/manual/en/ref.pdo-mysql.php">PDO_MySQL extension should be used. See also https://www.php.net/manual/en/mysqlinfo.api.choosing.php">MySQL: choosing an API guide and https://www.php.net/manual/en/faq.databases.php#faq.databases.mysql.deprecated">related FAQ for more information. Alternatives to this function include:
이왕이면 변경을 추천합니다만…
- https://phpschool.com/gnuboard4/bbs/board.php?bo_table=tipntech&wr_id=80533
간단하게 김정균 님의 MySQL 래퍼 함수 파일 받아서 소스 상단(공통 호출되는 파일이면 편안)에 한 줄 추가해주면, 기존 구 버전의 MySQL 함수를 사용하는 코드를 그대로 사용할 수 있습니다.
답변에 대한 댓글 1개
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인