这个脚本:
<?php
$myfamille=$_POST['myfamille'];
$conn = odbc_connect('sage','<Administrateur>','');
if (!$conn)
{exit("Connection Failed: " . $conn);}
$sql="Select F_ARTSTOCK.AR_Ref,AR_Design,AS_QteSto
FROM F_ARTICLE,F_FAMILLE,F_ARTSTOCK
where F_ARTICLE.FA_CodeFamille=F_FAMILLE.FA_CodeFamille
AND F_ARTICLE.AR_Ref=F_ARTSTOCK.AR_Ref
AND F_FAMILLE.FA_CodeFamille='".$myfamille."'
and F_ARTSTOCK.AS_QteSto <> 0";
$rs=odbc_exec($conn,$sql);
if (!$rs)
{exit("Error in SQL");}
while($e=odbc_fetch_object($rs))
{$output[]=$e;}
print(json_encode($output));
?>
给我这个错误:
Notice: Undefined variable: output in C:\wamp\www\articlecbase.php on line 24
请注意,删除此行会使代码正常工作,我不知道是什么问题
AND F_FAMILLE.FA_CodeFamille='".$myfamille."'
我也有一个类似的脚本,但使用 sql server 并且工作正常
<?php
$myservername=$_POST['myservername'];
$servername=".\\".$myservername;
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
$db_name="bijou";
$myfamille=$_POST['myfamille'];
$connectionInfo = array( "Database"=>$db_name, "UID"=>$myusername, "PWD"=>$mypassword);
$conn = sqlsrv_connect( $servername, $connectionInfo);
if (!$conn)
{exit("Connection Failed: " . $conn);}
$sql="Select F_ARTSTOCK.AR_Ref,AR_Design,AS_QteSto FROM F_Article,F_Famille,F_ARTSTOCK
where F_ARTICLE.FA_CodeFamille=F_FAMILLE.FA_CodeFamille
AND F_ARTICLE.AR_Ref=F_ARTSTOCK.AR_Ref
AND F_FAMILLE.FA_CodeFamille='".$myfamille."' and F_ARTSTOCK.AS_QteSto != .000000";
$rs=sqlsrv_query($conn,$sql);
if (!$rs)
{exit("Error in SQL");}
while($e=sqlsrv_fetch_object($rs))
{ $output[]=$e;}
print(json_encode($output));
?>
这也适用于 odbc 作品:
<?php
$myusername=$_POST['myusername'];
$conn = odbc_connect($myusername,'<Administrateur>','');
if (!$conn)
{exit("Connection Failed: " . $conn);}
$sql="SELECT FA_CodeFamille AS FA_CodeFamille,FA_Intitule AS FA_Intitule FROM F_FAMILLE";
$rs=odbc_exec($conn,$sql);
if (!$rs)
{exit("Error in SQL");}
while($e=odbc_fetch_object($rs))
{ $output[]=$e;}
print(json_encode($output));
?>
请帮我。问候
$output = array();
while($e=odbc_fetch_object($rs)) {
$output[] = $e;
}
在许多脚本上工作正常我有任何帮助请