 |
ดูโค้ดให้หน่อยค่ะว่าผิดตรงไหนรึเปล่าเขียนphpให้ติดต่อกับ mssql โดยผ่าน mysqlค่ะ |
|
 |
|
|
 |
 |
|
 
|
ประวัติการแก้ไข 2010-10-15 14:26:59
 |
 |
 |
 |
Date :
2010-10-15 14:26:20 |
By :
penpimonmink |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผิดตรง การ query อะครับ ลองดูใหม่ครับ ว่าผิดอย่างไร อาจจะเป็นตัวแปรผิดก็ได้ครับ
|
 |
 |
 |
 |
Date :
2010-10-15 14:42:31 |
By :
SOUL |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
<?
$host="KRABI-SERVER";
$username="homc";
$password="homc";
$db="KRABI";
$tb="PATIENT";
mssql_connect( $host,$username,$password) or die ("ติดต่อกับฐานข้อมูล Mssql ไม่ได้");
mssql_select_db($db) or die("เลือกฐานข้อมูลไม่ได้");
$sql="Select * From $tb";
$db_query=mssql_query($db,$sql);
$num_rows=mssql_num_rows($db_query); /* นับ Reccord ที่พบ*/
?>
<table width="91%" border="1" align="center">
<tr>
<td width="8%">
<div align="center">hn</div>
</td>
<td width="12%">
<div align="center">fristname</div>
</td>
<td width="11%">
<div align="center">lastname</div>
</td>
</tr>
</table>
<?
$a=0;
while($a < $num_rows)
{
$result = mssql_fetch_array($db_query);
$id=$result[hn];
$name=$result[fristname];
$surname=$result[lastname];
?>
<table width="91%" border="1" align="center">
<tr>
<td width="31%">
<div align="center"><?echo"$id";?></div>
<div align="center"></div></td>
<td width="35%">
<div align="center"><?echo"$name";?></div></td>
<td width="34%">
<div align="center"><?echo"$surname";?></div></td>
</tr>
</table>
<?
$a++;
}
echo"<center><br>จำนวน Reccord = $num_rows</center>";
mssql_close();
?>
เขียนแบบนี้ก็มีปัญหาเหมือนกัน เหมือนมันเรียกข้อมูลมาแสดงไม่ได้อ่ะค่ะ
มันบอกว่ามีปัญหาที่สองบรรทัดนี้ค่ะ
$db_query=mssql_query($db,$sql);
$num_rows=mssql_num_rows($db_query); /* นับ Reccord ที่พบ*/
|
 |
 |
 |
 |
Date :
2010-10-15 15:24:41 |
By :
lainhua |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองเอา $db เอาจาก query ดูนะ
=> $db_query=mssql_query($sql);
|
 |
 |
 |
 |
Date :
2010-10-15 16:13:32 |
By :
heng |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
$result = mssql_query($query) or die($query);
|
 |
 |
 |
 |
Date :
2010-10-15 16:25:35 |
By :
PlaKriM |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ทำได้แล้วค่ะ ขอบคุณนะคะ
|
 |
 |
 |
 |
Date :
2010-10-20 10:20:38 |
By :
lainhua |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|