을 통해 MySQL을 삽입하기되지 않는다 (이 3 열이 포함되어 있습니다).데이터가 나는 테이블에 하나 개의 요소를 삽입하려고 PHP
코드 :
<?php
require 'connect.db.php';
$msg = 'msg';
mysql_query("INSERT INTO messages('Message') VALUES ('$msg')");
$result1 = mysql_query("SELECT * FROM messages ORDER by Msg_ID DESC");
while ($extract = mysql_fetch_array(result1)) {
echo $extract['Message'];
}
?>
나는이 오류가 무엇입니까 그것을 실행하는 경우 : mysqli를 사용 후
Notice: Use of undefined constant result1 - assumed 'result1' in C:\xampp\htdocs\SocialNetwork\chat\chat.php on line 7
Warning: mysql_fetch_array() expects parameter 1 to be resource, string given in C:\xampp\htdocs\SocialNetwork\chat\chat.php on line 70
데이터가 DB에 삽입지고 있지 않습니다 ..
오류 (대체를 MySQL의) :
Warning: mysqli_query() expects at least 2 parameters, 1 given in C:\xampp\htdocs\SocialNetwork\chat\chat.php on line 6
Warning: mysqli_query() expects at least 2 parameters, 1 given in C:\xampp\htdocs\SocialNetwork\chat\chat.php on line 7
Notice: Use of undefined constant result1 - assumed 'result1' in C:\xampp\htdocs\SocialNetwork\chat\chat.php on line 8
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, string given in C:\xampp\htdocs\SocialNetwork\chat\chat.php on line 8
사용 mysqli : 그래서 지금 당신이
mysqli_
기능으로 전환,좋아을, 여기 다른 이야기입니다 MySQL이 사용되지 PHP 7 – Kumar
제거된다 *** http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php ([mysql_로 '*'기능을 사용하여 STOP]주세요) *** [이 확장 기능] (http://php.net/manual/en/migration70.removed-exts-sapis.ph p)가 PHP 7에서 제거되었습니다. [PDO]에 대한 [prepared] (http://en.wikipedia.org/wiki/Prepared_statement) 문장에 대해 알아보십시오. (http://php.net/manual/en/pdo.prepared -statements.php)와 [MySQLi (http://php.net/manual/en/mysqli.quickstart.prepared-statements.php)와 [정말 아주 쉽게, PDO를 사용하는 것이 좋습니다 (HTTP : // jayblanchard. net/demystifying_php_pdo.html). –
[Little Bobby] (http://bobby-tables.com/)에서 *** [귀하의 스크립트는 SQL 주입 공격의 위험에 있습니다.] (http://stackoverflow.com/questions/60174/how-can- i-prevent-sql-in-php) ***. 심지어 [이스케이프 문자열] (http://stackoverflow.com/questions/5741187/sql-injection-that-gets-around-mysql-real-escape-string) 안전하지 않습니다! *** SQL 인젝션! *** * 더 이상 아침 식사가 아닙니다! * –