2012-10-22 2 views
1

에 아주 기본적인 (난 내가 connect_to_mysql을 설정하는 단계입니다, 기본적으로 MySQL은.이 정말 바보 같은 질문입니다 만약 내가 미리 사과 연결 mysql을/시험 문제

PHP &에서 newb입니다. PHP 파일 (5시 50분)에서 다음과 같이 : http://www.youtube.com/watch?v=YaII5QhNCH0

등이 여기에 표시 :. http://www.developphp.com/view_lesson.php?v=248

내가 MAMP를 사용하고있는 포트가/3306 (80)이다 그러나 나는 알고에서 그 그것을 말하는 MAMP 시작 페이지, 또한, 작동하지 않는, 다음 :

MySQL의

MySQL 데이터베이스 것은 phpMyAdmin을 함께 투여 될 수있다. 자신의 스크립트에서 MySQL 서버에 연결하려면

는 다음과 같은 연결 매개 변수를 사용하여

호스트 : localhost를 포트 : 3306 사용자 : 루트 암호 :

여기

내가 가지고있는 루트 :

 <?php 
    // Created BY Adam Khoury @ www.flashbuilding.com - 6/19/2008 
/* 
1: "die()" will exit the script and show an error statement if something goes wrong with  the  "connect" or "select" functions. 
2: A "mysql_connect()" error usually means your username/password are wrong 
3: A "mysql_select_db()" error usually means the database does not exist. 
*/ 
// Place db host name. Sometimes "localhost" but 
// sometimes looks like this: >>  ???mysql??.someserver.net 
$db_host = "localhost"; 
// Place the username for the MySQL database here 
$db_username = "builder2"; 
// Place the password for the MySQL database here 
$db_pass = "builder2"; 
// Place the name for the MySQL database here 
$db_name = "suitstore"; 

// Run the actual connection here 
mysql_connect("$localhost","$builder2","$builder2") or die ("could not connect to  mysql"); 
mysql_select_db("$suitstore") or die ("no database");    
?> 

:

이 connect_to_mysql.php입니다 내가 크롬에서 테스트 사이트를로드 할 때

<?php 
    // Connect to the file above here 
require "connect_to_mysql.php"; 

echo "<h1>Success in database connection! Happy Coding!</h1>"; 
// if no success the script would have died before this success message 
?> 

그래서, 그것은 말한다 : 검색하는 동안 웹 사이트에서 오류가 발생 서버 오류와이 test.php입니다. 유지 관리가 잘못되었거나 잘못 구성되었을 수 있습니다. 다음은 몇 가지 제안 사항입니다. 나중에이 웹 페이지를 다시 불러 오십시오. HTTP 오류 500 (내부 서버 오류) : 서버가 요청을 수행하는 동안 예기치 않은 조건이 발생했습니다.

DW에서 test.php를 열면 "이 사이트는 [Discover] [Preferences]"서버에서만 동적으로 관련된 파일을 찾을 수 있습니다 "라는 메시지가 나타납니다. 내가 발견 클릭하면

다음, 그것을 말한다 : "동적 관련 파일이 때문에 내부 서버 오류로 분석 할 수 없습니다 [재시도]."

감사합니다, 미안이 바보 같은 질문 경우. 나는 정말로 php/mysql에 대해 잭을 모른다.

+6

새로운 튜토리얼을 찾으려면 mysql_ * 함수를 사용하지 마십시오 (매뉴얼의 매우 큰 경고 참조). 나이를 고려하지 않고 튜토리얼 \ 책 \ 비디오를 사용하는 것은 위험합니다. –

+0

디버깅 할 때'error_reporting (E_ALL); ini_set ('display_errors', 1);'을 PHP 스크립트의 시작 부분에 추가하십시오. PHP 오류가 발생했을 가능성이 높지만 설정에 오류가 표시되지 않습니다. – drew010

+0

첫 번째 PHP 파일에서 첫 번째

답변

5

나는 그들이해야한다고 생각합니다.

mysql_connect($db_host,$db_username,$db_pass) or die ("could not connect to mysql"); 
mysql_select_db($db_name) or die ("no database"); 
관련 문제