이 스크립트를 사용하여 :SQL 쿼리 ODBC
<?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와 잘 작동합니다.
ODBC와<?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));
?>
이 또한 작동 :
<?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;
}
내가 당신이 그것을 사용하기 전에 변수가 선언되지 않았기 때문에 어떤 도움이
(배열로
$_GET['test']
강제의 예는page.php?test[]=blah
것) 잘 작동합니다. – user1413631@ user1413631 즉, 쿼리 결과가 반환되지 않습니다. 내 게시물에 – Corbin
쿼리 에서이 라인을 제거했다 및 F_FAMILLE.FA_CodeFamille = ' ". $ myfamille." ' 이 스크립트는 으로 작동하지만 sqlsrv를 사용할 때 작동합니다 (수정 된 게시물 참조) – user1413631