Page 1 of 1

Can not get(SELECT) data from database table

Posted: Wed Jul 28, 2021 3:01 am
by kevin963
Hi Guys

We have an old project that was used PHP5, ubuntu 14 and Joomla, I upgraded them and now it's PHP7, Ubuntu20 and Joomla 3.9.27. After I upgraded, I have tested almost all functions, such as create a new user(database) Joomla administrator panel ...

Anyway, the problem now is I can not select from the database, which it's a function because I still can log in to the website and I can insert new data to this table, I think connection for the database is ok, just for some specific tables.

Apache and MySQL Error logs don't have too much useful information.
There has another PHP file named toolbox.php, no sure how to influence each other.
Anyone can suggest a solution or way find the problem?
Thanks

Code: Select all

<div style="clear:both"></div>
<?php $qry_com="SELECT `name` FROM `pcbu_users` WHERE `id`= '$uid'";
	$db->setQuery($qry_com);$db->query();
	$resultcom = $db->loadRow(); ?>
	<h2 class="comname" style="text-align:center;margin-top:0;"><?php echo isset($resultcom[0]); ?></h2>
  <div class="accordion">
  <div class="container">
    <div class="accordion-section">
  <a class="accordion-section-title accd1" id="accd1" href="#accordion-1"><h2>Toolbox Forms</h2></a>
  <h2 class="sec-title">Toolbox Forms</h2>
  <?php
  $qryurl = "SELECT * FROM `pcbu_subscription` WHERE `companyID`= '$uid' AND `toolbox` = 'yes'";
$db->setQuery($qryurl);$db->query();
		$totaltool=$db->getNumRows();
		$row = $db->loadAssocList();
		if ($totaltool >= 1 ) {
		for ($i=0;$i<$totaltool;$i++ ){
		 if($row[$i]['toolbox'] == 'yes') { ?>
		 
  <a class="urlset" target="_blank" href="<?php echo JURI::root();?>toolbox?cid=<?php echo $row[$i]['companyID']; ?>&rno=<?php echo $row[$i]['randomtool']; ?>"><h2><small>(<?php echo JURI::root();?>toolbox?cid=<?php echo $row[$i]['companyID']; ?>&rno=<?php echo $row[$i]['randomtool']; ?>) </small></h2> </a>
  <?php } } } ?>
  <div id="accordion-1" class="accordion-section-content">
  <table id="toolbox" class="display" cellspacing="0" width="100%">
    <thead>
      <tr>
        <th>Date/Time</th>
        <th>Name</th>
        <th>Location</th>
		 <th>Topic</th>
        <th>Any Suggestion</th>
        <th>Further Action</th>
		<th>File/Records</th>
      </tr>
    </thead>
    <tbody>
	<?php 	
	$qry_result="SELECT * FROM `pcbu_toolbox` WHERE `companyID`= '$uid'";
	$db->setQuery($qry_result);$db->query();
	$total=$db->getNumRows();
	$result = $db->loadAssocList();
	if ($total >= 1 ) { //execute this only if we have some results
			$row = $db->loadAssocList();
			for ($i=0;$i<$total;$i++ ){		?>	
     <tr>
	 <td><?php echo $row[$i]['dateTime'];?></td>
	 <td><?php echo $row[$i]['tname'];?></td>
	 <td><?php echo $row[$i]['location'];?></td>
	 <td><?php echo $row[$i]['topic'];?></td>
	 <td><?php echo $row[$i]['anySuggestion'];?></td>
	 <td><?php if ($row[$i]['furtherAction'] == 'yes') { echo 'Yes'; } else { echo 'No'; } ?></td>
	 <td><?php if ($row[$i]['filRecord'] == 'yes') { echo 'Yes'; } else { echo 'No'; } ?></td>
	 </tr>
	 <?php } } ?>
    </tbody>
  </table>
</div>
</div>
</div>

Re: Can not get(SELECT) data from database table

Posted: Wed Jul 28, 2021 4:17 am
by kevin963
Found the problem
uid didn't get the value
I change

Code: Select all

// $uid = isset($_GET["uid"]);
to

Code: Select all

if(isset($_GET['uid']))
{
     $uid = $_GET['uid'];
}
Then, anything is ok.