Mysql数据库内加入查询给错误

问题描述:

SQL数据库三表使用内部联接,但它给予错误。图片中显示的错误。我不知道问题是什么。Mysql数据库内加入查询给错误

enter image description here

Regserver.php

<?php 

include 'Connection.php'; 

$reg = $_GET['reg']; 

$sql = "select RegNo,a.RollNo,b.Standard,b.stdid,c.DivisionID,c.Division,Std_Name as StudentName,Std_Address,DOB,ContactNo1 as FatherNo,ContactNo2 as MotherNo, 
            School_Name as SchoolName,Decide_Fees as DecideFees,ImagePath 
            from Std_Reg as a inner join StandardMaster as b on a.Standard = b.stdid 
            inner join DivisionMaster as c on a.Division =c.DivisionID 
            where RegNo= '$reg'"; 
//$sql = "select * from Std_Reg"; 
$stmt = sqlsrv_query($conn, $sql); 

do { 
    while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)){ 
     $result[] = $row; 
    } 
} while (sqlsrv_next_result($stmt)); 

if(count($result)>0) 
{ 
    $result1['status']=1;//"Login successfully"; 
    array_push($result,$result1); 
} 
else 
{ 
    //$result[]="null"; 
    $result1['status']=0;//"Record not found"; 
    array_push($result,$result1); 
} 
sqlsrv_free_stmt($stmt); 
sqlsrv_close($conn); //Close the connnectiokn first 

echo json_encode($result); //You will get the encoded array variable 

?> 
+1

U可以发布错误消息的文本? – tan

+0

注意:未定义变量:结果在C:\瓦帕\ WWW \项目\ Regserver.php上线21 – Zala

+0

说明:未定义变量:结果在C:\瓦帕\ WWW \项目\ Regserver.php上线21 – Zala

错误说你没有定义的变量

尝试使用

之前宣布它此前PHP 5.4:

$myArray = array();

PHP 5.4及更高版本

$myArray = [];

告诉我们,我,如果这不会为ü工作。

+0

此解决方案不起作用。我想查询语法错误 – Zala

+0

因为在使用早期的PHP文件中使用此代码执行成功地 – Zala

+0

只查询是不同的。 – Zala