私は実行しているコードに問題があります。ここに書かれているこのエラーは、次のとおりです。致命的なエラー:キャッチされていないエラー:ヌルのメンバ関数query()を呼び出す
Fatal error: Uncaught Error: Call to a member function query() on null in /home/nissah5/sjs.vedantabgp.com/includes/functions.php:25 Stack trace: #0 /home/nissah5/sjs.vedantabgp.com/includes/batch.php(6): searchstudent() #1 /home/nissah5/sjs.vedantabgp.com/index.php(8): include('/home/nissah5/s...') #2 {main} thrown in /home/nissah5/sjs.vedantabgp.com/includes/functions.php on line 25
私が書いたコードはここにあります。 行番号25は、$ query = $ db-> query($ query)を参照しています。
function searchstudent(){
connectdb();
$condition='1';
if(@$_GET['y']=='xii') $condition.=" and xii='".$_GET['yr']."'";
if(@$_GET['y']=='x') $condition.=" and x='".$_GET['yr']."'";
if(@$_GET['v']=='chapter') $condition.=" and chapter='".$_GET['chapter']."'";
$query="select name, x, xii, description, id from alumni where ".$condition;
echo $query;
$query=$db->query($query);
$row1=$query->fetchAll();
$query->closeCursor();
$i=1;
foreach ($row1 as $row){ $i=($i+1)%2; if($i==0){?>
<div class="row">
<div class="col-sm-5">
<img class="img-responsive" src="images/templatemo_image_4.jpg" alt="image 4" />
</div>
<?php searchrow($row);} else{ ?>
<div class="col-sm-1"></div>
<div class="col-sm-5">
<img class="img-responsive" src="images/templatemo_image_5.jpg" alt="image 5" />
</div>
<?php searchrow($row);?>
</div>
<?
}
}
if ($i==0) echo "</div>";
は}
エコーはあなたの問題はあなたのコード内から来ている
select name, x, xii, description, id from alumni where 1
https://secure.php.net/variables.scope !!! –
問題がありました(y) –