How do I block user viewing out DB tables?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

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

Post by simonmlewis »

No error codes, no nothing. The code literally stops.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

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

Post 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>";
			}
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

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

Post by Celauran »

Can you post the code in dbconn then?
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

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

Post 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.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
Post Reply