ช่วยหน่อยคับพี่ๆ ผมติด Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\ar\insertstd.php on line 144
ผมผิดชุดนี้คับ บรรทัดที่ผมติ๊กไว้นะคับ
if ($idstd2 == "" || $idstd2 >= 'A') {
echo "failed...";
} else {
$sql = "select * from actteacher where idstd='$idstd2'";
$result = mysql_query($sql);
if (mysql_num_rows($result) == 0) { บรรทัดนี้คับ
$sqlin = "insert into actteacher (idstd, prefix, firstname, lastname, born, class, room, ordinal) values ('$idstd2', '$prefix2', '$firstname2', '$lastname2', '$born2', '$class2', '$room2', '$ordinal')";
$resultin = mysql_query($sqlin);
echo "new...";
} else {
$sqlup = "update actteacher set prefix='$prefix2', firstname='$firstname2', lastname='$lastname2', born='$born2', class='$class2', room='$room2', ordinal='$ordinal' where idstd='$idstd2'";
$resultup = mysql_query($sqlup);
echo "old...";
}
$free = mysql_free_result($result); นี่ด้วยคับ
echo $idstd2;
echo $prefix2 . $firstname2 . $lastname2;
echo $born2;
echo $class2;
echo $room2;
echo $ordinal2;
echo "success...<br>";
$sqlr = "select * from actteacher";
$resultr = mysql_query($sqlr);
while ($rs = mysql_fetch_array($resultr)) {
$idte = $rs['idstd'];
$prefix = $rs['prefix'];
$firstname = $rs['firstname'];
$lastname = $rs['lastname'];
$born = $rs['born'];
$class = $rs['class'];
$room = $rs['room'];
$ordinal = $rs['ordinal'];
echo $idstd;
echo $prefix . $firstname . $lastname;
echo $born;
echo $class;
echo $room;
echo $ordinal;
echo "<br>";
}
}
ช่วยมือใหม่ด้วยนะคับ ขอขอบคุณล่วงหน้าคับTag : - - - -
Date :
2011-04-07 22:06:57
By :
nut
View :
1466
Reply :
1
ใส่นี
$result = mysql_query($sql) or die(mysql_errror() . '<br />' . $sql);
แทน
$result = mysql_query($sql);
แล้วรันดูมี error ว่าอะไร
Date :
2011-04-08 01:04:18
By :
PlaKriM
Load balance : Server 01