Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/p3.php on line 23
위와 같이 에러가 납니다. $row = mysql_fetch_array($res) 의 어디가 문젠가요?
[code]
include 'db_connect.php'; // db connect$result = "SELECT Id, Password, Email, Gender, Zipcode FROM sung2 WHERE Username = '".$_GET['username']."'";
$res = mysql_query($result);
while ($row = mysql_fetch_array($res)) { // line 23 에러나는 부분
print $row['Id'];
print $row['Username'];
print $row['Password'];
print $row['Email'];
print $row['Gender'];
print $row['Zipcode'];
}[/code]
|
답변 7개 / 댓글 6개
채택된 답변
+20 포인트
db_connect.php 파일이 잘못 된건 아닌지 확인 다시 한번 해보시는게 좋을 듯합니다.
mysql_query에 오류간 있는것 같은데요
mysql_query() or die(mysql_error())
해보세요
mysql_query() or die(mysql_error())
해보세요
답변에 대한 댓글 3개
$result = mysql_query("SELECT * FROM sung2 WHERE Username = '".$_GET['username']."'");
if (!$result)
{
die('Invalid query');
}
$res = mysql_query($result)
while ($row = mysql_fetch_array($res)) { // line 31*******************
echo $row['Id'];
echo $row['Username'];
echo $row['Password'];
echo $row['Email'];
echo $row['Gender'];
echo $row['Zipcode'];
}
위와 같이 하니 아래와 같이 Parse error 가 납니다...
Parse error: syntax error, unexpected T_WHILE in /p3.php on line 31
if (!$result)
{
die('Invalid query');
}
$res = mysql_query($result)
while ($row = mysql_fetch_array($res)) { // line 31*******************
echo $row['Id'];
echo $row['Username'];
echo $row['Password'];
echo $row['Email'];
echo $row['Gender'];
echo $row['Zipcode'];
}
위와 같이 하니 아래와 같이 Parse error 가 납니다...
Parse error: syntax error, unexpected T_WHILE in /p3.php on line 31
이전 문제는 제가 테이블명을 잘못 입력하고 3주 동안 중노동했습니다. 죄송합니다....
[code]
$username = $_GET["username"];
$email = $_GET["email"];
$zip = $_GET["zip"];
$bio = $_GET["bio"];
$website = $_GET["website"];
$major = $_GET["major"];
$color = $_GET["color"];
// connect DB
include 'db_connect.php'; // include localhost, username, password, database
mysql_query("UPDATE `sung2` SET `Email`='$email', `Zipcode`='$zip', `Bio`='$bio', `Website_URL`='$website', `Major`='$major', `Color`='$color' WHERE `Username` = '".$_GET['username']."'");
[/code]
위와 같이 mysql_query 문 작성하니 에러가 납니다.
[code]
$username = $_GET["username"];
$email = $_GET["email"];
$zip = $_GET["zip"];
$bio = $_GET["bio"];
$website = $_GET["website"];
$major = $_GET["major"];
$color = $_GET["color"];
// connect DB
include 'db_connect.php'; // include localhost, username, password, database
mysql_query("UPDATE `sung2` SET `Email`='$email', `Zipcode`='$zip', `Bio`='$bio', `Website_URL`='$website', `Major`='$major', `Color`='$color' WHERE `Username` = '".$_GET['username']."'");
[/code]
위와 같이 mysql_query 문 작성하니 에러가 납니다.
$result 밑에 echo $result; 하신 후에 나온 쿼리문을 phpmyadmin에 넣어 보세요.
그러면 어떤 게 문제인지 나올 겁니다.
답변을 작성하려면 로그인이 필요합니다.