Page 4 of 4

Re: How do I block user viewing out DB tables?

Posted: Thu Aug 29, 2013 2:41 pm
by simonmlewis
No error codes, no nothing. The code literally stops.

Re: How do I block user viewing out DB tables?

Posted: Tue Sep 03, 2013 3:58 am
by simonmlewis
The problem is, that it's not running the query at all, as far as I can tell.
I'm wondering if it is simply not using:

Code: Select all

include "dbconn.php";
It uses it if I use the mysql_ style of script.

I'm running both of these, the top one just to test as it works if I run it as test.php.

Code: Select all

$query = "SELECT email FROM admin WHERE type = 'admin'";
$result = $pdo->query($query);
while ($row = $result->fetch(PDO::FETCH_OBJ)) {
    echo "$row->email<br/>";
} 

$result = $db->query('SELECT id, catid, catname, uk_catname FROM products');
while ($row = $result->fetch(PDO::FETCH_OBJ)) {
      $categ = "$row->catname"; 
      $findcateg ="/ /"; 
      $replacecateg ="-"; 
      $categreplace = preg_replace ($findcateg, $replacecateg, $categ); 
			echo "<div class='submenu'><a href='/categ/$row->catid/$categreplace'>$row->catname</a></div>";
			}

Re: How do I block user viewing out DB tables?

Posted: Tue Sep 03, 2013 6:06 am
by Celauran
Can you post the code in dbconn then?

Re: How do I block user viewing out DB tables?

Posted: Tue Sep 03, 2013 6:08 am
by simonmlewis
Please see:
viewtopic.php?f=2&t=138317&p=687587#p687587
Since this is no longer about blocking users, but about using PDO, I felt it right to move this part to a more suitable thread.